From 56c038b6f64fa84be9a8440ff9641105606afe9b Mon Sep 17 00:00:00 2001 From: Marcus Rowe Date: Wed, 14 Aug 2024 20:25:13 +1000 Subject: [PATCH] Add mouse sensitivity enum constants --- pvsneslib/include/snes/input.h | 12 +++++++ .../input/mouse-data-test/mouse-data-test.c | 6 ++-- snes-examples/input/mouse/mouse.c | 35 +++++++------------ 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/pvsneslib/include/snes/input.h b/pvsneslib/include/snes/input.h index 86b36774..0f9024de 100644 --- a/pvsneslib/include/snes/input.h +++ b/pvsneslib/include/snes/input.h @@ -76,6 +76,18 @@ typedef enum SUPERSCOPE_BITS SSC_NOISE = BIT(8), //!< superscope NOISE flag. } SUPERSCOPE_BITS; +/*! + * \brief Mouse sensitivity values + * + * enum values for the mouse sensitivity. + */ +typedef enum MOUSE_SENSITIVITY +{ + MOUSE_SLOW = 0, //!< slow sensitivity + MOUSE_MEDIUM = 1, //!< medium sensitivity + MOUSE_FAST = 2, //!< fast sensitivity +} MOUSE_SENSITIVITY; + extern u16 pad_keys[5]; //!< current pad value extern u16 pad_keysold[5]; //!< previous pad value extern u16 pad_keysdown[5]; //!< newly pressed down pad keys diff --git a/snes-examples/input/mouse-data-test/mouse-data-test.c b/snes-examples/input/mouse-data-test/mouse-data-test.c index c3f90599..bcb18bfe 100644 --- a/snes-examples/input/mouse-data-test/mouse-data-test.c +++ b/snes-examples/input/mouse-data-test/mouse-data-test.c @@ -162,13 +162,13 @@ int main(void) if (padsDown(JOYPAD_PORT) & (KEY_Y | KEY_X | KEY_A | KEY_L | KEY_R)) { if (padsDown(JOYPAD_PORT) & KEY_Y) { - mouseSetSensitivity(MOUSE_PORT, 0); + mouseSetSensitivity(MOUSE_PORT, MOUSE_SLOW); } if (padsDown(JOYPAD_PORT) & KEY_X) { - mouseSetSensitivity(MOUSE_PORT, 1); + mouseSetSensitivity(MOUSE_PORT, MOUSE_MEDIUM); } if (padsDown(JOYPAD_PORT) & KEY_A) { - mouseSetSensitivity(MOUSE_PORT, 2); + mouseSetSensitivity(MOUSE_PORT, MOUSE_FAST); } if (padsDown(JOYPAD_PORT) & KEY_R) { mouseCycleSensitivity(MOUSE_PORT); diff --git a/snes-examples/input/mouse/mouse.c b/snes-examples/input/mouse/mouse.c index 966ecf91..56db0e57 100644 --- a/snes-examples/input/mouse/mouse.c +++ b/snes-examples/input/mouse/mouse.c @@ -10,15 +10,6 @@ ---------------------------------------------------------------------------------*/ #include -#ifndef MOUSE_SPEED -#define MOUSE_SPEED - -#define slow 0 -#define normal 1 -#define fast 2 - -#endif - extern char snesfont, snespal, cursorsprite, cursorsprite_end, cursorpal, buttonsmap, buttonstiles, buttonstiles_end, buttonspal; char hex_string[4]; @@ -52,7 +43,7 @@ int main(void) consoleDrawText(11, 1, "MOUSE TEST"); // Enable mouse reading and set the initial mouse sensitivity - initMouse(slow); + initMouse(MOUSE_SLOW); WaitForVBlank(); // Let's make sure we read mouse for the first time after initMouse() @@ -294,15 +285,15 @@ int main(void) { if ((p1_mouse_x > 0x44) && (p1_mouse_x < 0x64)) { - mouseSetSensitivity(0, slow); // Queue a set sensitivity command + mouseSetSensitivity(0, MOUSE_SLOW); // Queue a set sensitivity command } if ((p1_mouse_x > 0x6C) && (p1_mouse_x < 0x94)) { - mouseSetSensitivity(0, normal); // Queue a set sensitivity command + mouseSetSensitivity(0, MOUSE_MEDIUM); // Queue a set sensitivity command } if ((p1_mouse_x > 0x9C) && (p1_mouse_x < 0xBC)) { - mouseSetSensitivity(0, fast); // Queue a set sensitivity command + mouseSetSensitivity(0, MOUSE_FAST); // Queue a set sensitivity command } } } @@ -314,15 +305,15 @@ int main(void) { if ((p2_mouse_x > 0x44) && (p2_mouse_x < 0x64)) { - mouseSetSensitivity(1, slow); // Queue a set sensitivity command + mouseSetSensitivity(1, MOUSE_SLOW); // Queue a set sensitivity command } if ((p2_mouse_x > 0x6C) && (p2_mouse_x < 0x94)) { - mouseSetSensitivity(1, normal); // Queue a set sensitivity command + mouseSetSensitivity(1, MOUSE_MEDIUM); // Queue a set sensitivity command } if ((p2_mouse_x > 0x9C) && (p2_mouse_x < 0xBC)) { - mouseSetSensitivity(1, fast); // Queue a set sensitivity command + mouseSetSensitivity(1, MOUSE_FAST); // Queue a set sensitivity command } } } @@ -339,15 +330,15 @@ int main(void) // Show reported sensitivity switch (mouseSensitivity[0]) { - case slow: + case MOUSE_SLOW: dmaCopyVram(&buttonsmap + 0x60, 0x6188, 0x0A); // SLOW button pressed dmaCopyVram(&buttonsmap + 0xA0, 0x61A8, 0x0A); // SLOW button pressed break; - case normal: + case MOUSE_MEDIUM: dmaCopyVram(&buttonsmap + 0x6A, 0x618D, 0x0C); // NORMAL button pressed dmaCopyVram(&buttonsmap + 0xAA, 0x61AD, 0x0C); // NORMAL button pressed break; - case fast: + case MOUSE_FAST: dmaCopyVram(&buttonsmap + 0x76, 0x6193, 0x0A); // FAST button pressed dmaCopyVram(&buttonsmap + 0xB6, 0x61B3, 0x0A); // FAST button pressed break; @@ -369,15 +360,15 @@ int main(void) switch (mouseSensitivity[1]) { - case slow: + case MOUSE_SLOW: dmaCopyVram(&buttonsmap + 0x60, 0x6308, 0x0A); // SLOW button pressed dmaCopyVram(&buttonsmap + 0xA0, 0x6328, 0x0A); // SLOW button pressed break; - case normal: + case MOUSE_MEDIUM: dmaCopyVram(&buttonsmap + 0x6A, 0x630D, 0x0C); // NORMAL button pressed dmaCopyVram(&buttonsmap + 0xAA, 0x632D, 0x0C); // NORMAL button pressed break; - case fast: + case MOUSE_FAST: dmaCopyVram(&buttonsmap + 0x76, 0x6313, 0x0A); // FAST button pressed dmaCopyVram(&buttonsmap + 0xB6, 0x6333, 0x0A); // FAST button pressed break;