Skip to content

Commit

Permalink
Fix/align button state names, ignore IDEA files
Browse files Browse the repository at this point in the history
  • Loading branch information
ninovanhooff authored Mar 16, 2024
1 parent f664dda commit 9aeb214
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ $RECYCLE.BIN/
tests/t_*
!tests/t_*.*
tests/playdate_tests

# IntelliJ IDEA
.idea
12 changes: 6 additions & 6 deletions playdate_example/src/playdate_example.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ var y = int(LCD_ROWS / 2) + 32

proc update(): int =
# playdate is the global PlaydateAPI instance, available when playdate/api is imported
let buttonsState = playdate.system.getButtonsState()
let buttonState = playdate.system.getButtonState()

if kButtonRight in buttonsState.current:
if kButtonRight in buttonState.current:
x += 10
if kButtonLeft in buttonsState.current:
if kButtonLeft in buttonState.current:
x -= 10
if kButtonUp in buttonsState.current:
if kButtonUp in buttonState.current:
y -= 10
if kButtonDown in buttonsState.current:
if kButtonDown in buttonState.current:
y += 10

if kButtonA in buttonsState.pushed:
if kButtonA in buttonState.pushed:
samplePlayer.play(1, 1.0)

let goalX = x.toFloat
Expand Down
2 changes: 1 addition & 1 deletion src/playdate/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ proc setUpdateCallback*(this: ptr PlaydateSys, update: PDCallbackFunction) =
this.setUpdateCallback(privateUpdate, playdate)
# ---

proc getButtonsState* (this: ptr PlaydateSys): tuple[current: PDButtons, pushed: PDButtons, released: PDButtons] =
proc getButtonState* (this: ptr PlaydateSys): tuple[current: PDButtons, pushed: PDButtons, released: PDButtons] =
privateAccess(PlaydateSys)
var current, pushed, released: uint32
this.getButtonState(cast[ptr PDButton](addr(current)), cast[ptr PDButton](addr(pushed)), cast[ptr PDButton](addr(released)))
Expand Down

0 comments on commit 9aeb214

Please sign in to comment.