-
Notifications
You must be signed in to change notification settings - Fork 31
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
AppleJack (Pippin) controller support #117
Conversation
AdbMouse and AdbKeyboard are subdevices of the CUDA device alongside AdbBus. This doesn't make sense because conceptually, ADB devices hang off of the ADB bus, not CUDA itself. An ADB bus can exist without a CUDA present, for example Egret on older 68K Macs and the PMU on newer Power Macs. Therefore, make the ADB device list a subhierarchy of AdbBus instead. Add a new "adb_devices" property belonging to AdbBus that can allow users to specify ADB devices on the command line at machine creation time, independent of the emulated bus's host. Make this property default to "Mouse,Keyboard" to preserve existing behavior.
Add new GamepadButton enum with bits corresponding to AppleJack button bits. Both the AppleJack controller and the SDL GameController coincidentally define one d-pad, two shoulder buttons, four face buttons, and three system buttons. This makes mapping modern game controllers to the AppleJack straightforward.
All AppleJack controllers start in mouse emulation mode, behaving exactly like ADB mice. Only upon receiving a Listen command on register 3 with handler ID 0x46 does the AppleJack switch protocols, albeit such a change consisting merely of expanding register 0's buffer size to 4 bytes. In this state, the first 2 bytes remain defined as they are for an ADB mouse; the additional 16 bits carry the respective states of each of the AppleJack controller's remaining 11 buttons out of a possible supported 16. For backward compatibility, honor both mouse clicks and shoulder button presses on the host when considering the state of the emulated trigger buttons.
Leave a keyboard attached for compatibility.
I like it.
|
Very cool; looking forward to that! I didn't pursue that here because it was apparent to me that DingusPPC does not yet support multiple ADB devices of the same type, and I wanted to limit the scope of this PR to just AppleJack support. Officially, Pippin supports up to four AppleJack controllers at once, though I'm not sure if/how anything enforces this given that there can be up to 15 devices present on an ADB. In any case, Pippin consoles only have two P-ADB ports (though rare Y-adapters exist).
When this gets fixed then it should be straightforward to support more than one AppleJack controller at once, too. Multiple AppleJacks are distinguished by their ADB addresses.
In main.cpp I just open the first game controller I find, providing just one source of game controller events. I define a
Yes, the SDL GameController API assigns each game controller its own ID. This patch only supports one gamepad, for a pretty important reason (IMO): DingusPPC won't run any of the multiplayer Pippin games yet, so I'd have no way to verify that multiple emulated controllers actually work. ;)
One issue with the legacy SDL joystick API is that there's no standardization regarding what buttons/axes/hats/trackballs on a given controller map to in terms of software IDs. So while some older joysticks might provide a better analogue to classic ADB devices, configuring them would likely be a manual process for the user per joystick. This is why I chose to implement AppleJack support here in terms of the newer GameController API: the A/B/X/Y buttons are guaranteed to be in the same location from gamepad to gamepad, so I map them to their respective corresponding locations on the AppleJack controller. I verified this with both an Xbox 360 controller and a Logitech Dual Action controller. Neither required any manual mapping beyond what I'm doing in hostevents_sdl.cpp. |
We'll be able to test multiple Pippin controllers using normal Power Mac emulation - same for any emulated ADB devices. There are apps for classic Mac OS to dump ADB packets. I would like to research the HID support that SDL has to enumerate devices and buttons and axis and such. In macOS, USBProber.app can dump the HID report descriptors of a device. ControllerMate.app is an app that can visually view and script HID devices. It includes USBProber internally in the ControllerMate Profile. |
Add support for the Pippin controller, now that rudimentary support for Pippin is present. Use SDL's GameController API for a consistent button mapping across popular modern gamepads. Refactor AdbMouse to support passing mouse specifications at construction time in addition to hardcoding via a preprocessor macro. Likewise, add new "adb_devices" property to allow for users to specify at launch which ADB devices should be emulated, rather than hardcoding mouse and keyboard for all machine types.