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

USB Joystick support? #142

Open
Danfun64 opened this issue Nov 11, 2017 · 15 comments
Open

USB Joystick support? #142

Danfun64 opened this issue Nov 11, 2017 · 15 comments

Comments

@Danfun64
Copy link

I don't understand why, but Basilisk II and Sheepshaver have never supported USB Joysticks, or more importantly Analog Joysticks. I've been curious as to whether such support will be added in ever. Anybody have any info on that front?

@rickyzhang82
Copy link
Contributor

You know why. Because people who can program have no interest to implement this, while people who want this feature but have no expertise to do this (I'm not implying or referring you in either category)

In any case, you can think about how to implement this by reading networking in BII. It is a good learning path.

@DMJC
Copy link

DMJC commented Sep 23, 2020

How hard is it to implement an ADB device emulator? There were ADB joysticks back in the 1990s. Surely it'd be possible to map the values from say a linux /dev/js device to a virtual ADB device? Would it be easier to load the Thrustmaster drivers for macOS and then map the values from the host OS, or would you implement a driver from scratch as well as the Host OS Mapping?

@MaddTheSane
Copy link

MaddTheSane commented Sep 23, 2020

Or USB pass-thru. Although that would be limited to Mac OS 8.1 or later and PowerPC.

@lovrenco
Copy link

This would be good option to have. For example, WinUAE (Amiga emulator) has this option.
Strange that main Mac 060/PPC emulators do not have it.

@DMJC
Copy link

DMJC commented Jul 17, 2022

I found some developer documentation on ADB devices: https://developer.apple.com/library/archive/technotes/hw/hw_01.html#Extended Based on this I suspect that a joystick is either going to present itself as either a mouse, or a miscellaneous device. Based on models of joystick I've found, it's likely the quickest thing to implement would be a 4-5 button joystick with X/Y axis and 5 buttons (e.g a CH Mouse Stick II), that identifies itself to the OS as a mouse, but map joystick inputs to it. There is a three-axis joystick I've found called a Gravis Mac Blackhawk. It has 4 buttons and a scroll wheel in addition to X/Y axes. It also has custom drivers. I suspect it appears to the OS as 2 mice and then the drivers do some magic to make it a coherent device.

@DMJC
Copy link

DMJC commented Jul 17, 2022

I also found this super useful website (you will want to translate from French.) In it the author talks about multiple ADB devices.
https://www-journaldulapin-com.translate.goog/2020/04/06/gravis-joystick-ii/?_x_tr_sl=fr&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp Most joysticks are just presented to the OS as Keyboard/Mouse devices. I suggest implementing a selection menu where you can select which device ID to present to the OS, have the Gravis Mouse stick 1 and 2 as options, as well as a gravis gamepad and Microsoft Sidewinder 3D Pro. These devices should all act as mouse/keyboard emulators and are simple to implement, simply add a system for binding joystick buttons and axes to keyboard buttons/mouse axes in Basilisk/Sheepshaver. He also has documentation on the Thrustmaster FCS system. I suspect this is a lot harder to implement as it has it's own protocol it talks in: https://www-journaldulapin-com.translate.goog/2020/03/19/joystick-adb/?_x_tr_sl=fr&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp

@rickyzhang82
Copy link
Contributor

First, forget about USB passthrough. It is not how BII works to handle HID.

Secondly, the way it works in BII is that you trigger an event in the host and then BII translate that event into the event in the guest OS. Take SDL2 as an example (see here), SDL2 intercept your joystick's event in your host OS and then translate into ADB event in the guest OS.

It should be an easy fix. For sure, you should read the mapping from the table storing form an external file just like the way the existing keyboard code does.

Hope this helps.

@DMJC
Copy link

DMJC commented Jul 19, 2022

It helped a lot, I've started to code up some support for it. I am also reaching out to people to try to get some Apple device ID's sadly lsadb on Linux hasn't got any id's other than keyboards/mice, but I've reached out to some people both online and irl who might be able to help me get some. I've already implemented most of the event handler code, luckily I've used libSDL for joystick handling before so it's been pretty straightforward. Once I have something useful I'll do a pull request.

@DMJC
Copy link

DMJC commented Jul 22, 2022

Quick update, I got this working, my joystick is pretending to be a mouse, but in Super Wing Commander it's working in joystick mode. Looks like ADB Joysticks are probably just Extended mouse devices. I haven't got multi-button working yet, but it'll happen soon.

@rickyzhang82
Copy link
Contributor

Sweet. Do show a demo in a screencast. Don't forget to send a PR. Have a good weekend!

@DMJC
Copy link

DMJC commented Jul 23, 2022

I've just been able to make my joystick code resolution independent. This means the joystick will behave correctly at 640x480, 1024x768 or any other resolution in between. This is an important part of the code. I am now moving on to focus on getting more buttons than the first Button working. I will update progress in this thread until I do the pull request itself. The code is quite simple and easy to debug. Currently I am just binding the first joystick automatically, however I have two USB joysticks here so I might tinker with having the used device be selectable via the GUI.

@DMJC
Copy link

DMJC commented Aug 1, 2022

My Gravis Mousestick II just arrived! I've got a friend loaning me a G3 Power Mac soon. I'm going to sniff the ADB id and see if I can make an identical device appear in Basilisk 2.

@catdogmat
Copy link

Hi @DMJC! I was just wondering if you ever finished this? I would love for it to be added so I can put sheepshaver on my arcade machine.

@DMJC
Copy link

DMJC commented Mar 1, 2024 via email

@catdogmat
Copy link

Alright, that would be great! Thanks.

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

No branches or pull requests

6 participants