Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse support #274

Merged
merged 2 commits into from
Apr 7, 2024
Merged

Mouse support #274

merged 2 commits into from
Apr 7, 2024

Conversation

DigiDwrf
Copy link
Contributor

@DigiDwrf DigiDwrf commented Apr 3, 2024

OK, usage goes like this:

snes_mouse has to be turned on (snes_mouse = 1). This is set 0 by default after consoleInit().
This will tell the system to read from a mouse, if it is found.
Mouse and pads can be used simultaneously, on any ports. Externs in the pad.h file goes like this:

snes_mouse; /*!< \brief 1 if Mouse is going to be used */

mouseConnect[2];        /*! \brief 1 if Mouse present */
mouseButton[2];         /*! \brief 1 if button is pressed, stays for a bit and then it gets released (Click mode). */
mousePressed[2];        /*! \brief 1 if button is pressed, stays until is unpressed (Turbo mode). */
mouse_x[2], mouse_y[2]; /*! \brief Mouse acceleration. daaaaaaa, d = direction (0: up/left, 1: down/right), a = acceleration. */
mouseSpeedSet[2];          /*! \brief Mouse speed setting. 0: slow, 1: normal, 2: fast */

the number inside array specifies port (0 or 1).
I recommend using this code structure to convert raw acceleration into usable values:

u16 p1_mouse_x = 0x80;
u16 p1_mouse_y = 0x70;
u16 p2_mouse_x = 0x80;
u16 p2_mouse_y = 0x70;

 if (mouse_x[0] & 0x80)
    p1_mouse_x -= mouse_x[0] & 0x7F;
else
    p1_mouse_x += mouse_x[0] & 0x7F;
if (mouse_y[0] & 0x80)
    p1_mouse_y -= mouse_y[0] & 0x7F;
else
    p1_mouse_y += mouse_y[0] & 0x7F;

All other aspects are specified inside the example ROM. Happy mousing!

and some other fixes from previous commit
@alekmaul alekmaul merged commit bc5c31a into alekmaul:develop Apr 7, 2024
@danboid
Copy link

danboid commented Jun 13, 2024

Hi @DigiDwrf

Have you tested mouse support with the Hyperkin optical mice as well as the Nintendo mouse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants