From 9aeb214a9e61c4de456b0dfe92edf7828fa35452 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Sat, 16 Mar 2024 17:42:41 +0100 Subject: [PATCH] Fix/align button state names, ignore IDEA files --- .gitignore | 3 +++ playdate_example/src/playdate_example.nim | 12 ++++++------ src/playdate/system.nim | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 4a0815f..637f30c 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ $RECYCLE.BIN/ tests/t_* !tests/t_*.* tests/playdate_tests + +# IntelliJ IDEA +.idea \ No newline at end of file diff --git a/playdate_example/src/playdate_example.nim b/playdate_example/src/playdate_example.nim index f343e6e..2b4c352 100644 --- a/playdate_example/src/playdate_example.nim +++ b/playdate_example/src/playdate_example.nim @@ -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 diff --git a/src/playdate/system.nim b/src/playdate/system.nim index b55fd34..6f22205 100644 --- a/src/playdate/system.nim +++ b/src/playdate/system.nim @@ -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)))