-
Notifications
You must be signed in to change notification settings - Fork 16
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
Joystick input for Windows & Linux #380
Conversation
// 4. Update the last state to match the new data returned | ||
// 5. If nothing is different, set pendingState = false; | ||
JOYINFOEX winEvent = {0}; | ||
// what the hell kind of API requires this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows API!
} | ||
} | ||
} while (0); | ||
#elif defined(EMU_LINUX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so too but in fairness to windows I wrapped the linux API pretty tightly and just made the windows one comply with that which looks a bit more ugly lol
case DPAD_AXIS_Y: | ||
{ | ||
buttonBit_t curState = 0; | ||
if (joystickExt.axisData[DPAD_AXIS_X] < 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So on the actual Swadge the D-Pad is four discrete buttons, but here's it's a proper D-Pad, so the hardware can handle simultaneous up/down presses while the joystick cannot. I don't think it matters, just a point of interest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah that's true, probably not something we'd realistically need to support anyway. This is also just how the swadge maps the D-pad in gamepad mode, and I guess it's pretty standard since a switch controller also maps its D-pad the same way.
Description
Joystick inputs! They work on Windows and Linux, I haven't attempted OSX at all.
On both platforms, the joystick must be connected before the emulator starts. If the joystick is disconnected, the emulator will not attempt to reconnect to it.
Also in support of arcade-y things, I fixed the emulator display not being centered properly in fullscreen and some other situations that come up more often now that the LEDs have moved.
Test Instructions
It's more or less plug and play! On Windows, will open the first joystick device available. On Linux, will open
/dev/input/js0
.Ticket Links
Readiness Checklist
make format
to format the changesmake cppcheck
and checked thatcppcheck_result.txt
has no warnings for the changes/*! \file
comments with Design Philosophy, Usage, and Example sections for new headers.make docs
and checked thatdoxy_warnings.txt
has no warnings for the new code