USB Joystick in Qemu/Mac OS 9.2.2 ?

About Qemu-system-ppc, a PPC Mac emulator for Windows, macOS and Linux that can run Mac OS 9.0 up to Mac OS X 10.5

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by galgot »

Hi,
is there a way to make OS 9.2.2 recognize a usb joystick with Qemu ?
I tried playing one of my fav combat flight sim, Warbird 2.77, and to my surprise its very smooth and playable with the mouse. Alas my old Cyborg3D usb joystick isn’t seen by 9.2.2 :/
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by adespoton »

Have you tried this?

https://unix.stackexchange.com/question ... mmand-line
-device usb-host,hostbus=bus,hostaddr=addr
Pass through the host device identified by bus and addr

-device usb-host,vendorid=vendor,productid=product
Pass through the host device identified by vendor and product ID

But they don't mention that you can do

-device usb-host,hostbus=bus,hostport=port

For example...

If I run lsusb -t and get

/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
|__ Port 10: Dev 8, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 11: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 12M

I could decide to pass these by

-device usb-host,hostbus=3,hostport=10 \
-device usb-host,hostbus=3,hostport=11 \

And those correspond to the physical slots.

However the bus and port will differ for a USB 3.0 slot depending on if a USB 2.0 device or USB 3.0 device is plugged into it, but the port for each device will remain consistent.

Such variance does not exist for USB 2.0 slots.

/* update: USB Hubs */

Use dots to separate the ports. So if you had ...

/: Bus 03
|__ Port 2: some stuff
|__ Port 1: some stuff

You would use -device usb-host,hostbus=3,hostport=2.1
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by galgot »

Yaw ! it works :)

Image

Image

Image

Thank you Sir !
I used

Code: Select all

-device usb-host,hostbus=0,hostport=1 \
Now if only we could have a good working sound. I'm using a Screamer-enabled build on 10.11, but there is no sound in this game. And system wise , its just random sounds...
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by adespoton »

You could always try USB audio instead. Since your joystick works, the USB audio interface might too :)
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by galgot »

Nope :/ Adding

Code: Select all

-device usb-audio
To my command doesn't do with my current build.
On other I've tried, it make it crash or very unstable .
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

There is a difference between -device usb-audio and pass-through of an existing usb-device with e.g., -device usb-host,hostbus=3,hostport=14
In MacOS host you can find the info to pass-through in the system profiler's USB information (like this: 0x14e00000 / 3)

In Linux you can find what to pass-through by using lsusb -t
I've tried passing through a logitech usb audio headset in Linux host. It shows up in Mac OS 9.2 as three devices on a bus, but will not play sound. You have to run Qemu as root to allow it access to the device.
OSX 10.3 guest then sees the output and input channel, but will not play or record sound. OSX 10.4 does not even recognise the headset as audio device.

Pass-through will interfere with e.g, the usb mouse so I run -M mac99 (which uses cuda mouse and keyboard), not -M mac99,via=pmu (which uses usb mouse and keyboard).

Any usb-devices that Qemu accesses while OSX host already has some driver installed for them will not be accessible by the guest. This is a known issue with libusb on Mac OSX hosts.
It might be possible to unload the kext that locked access to a device if you know which one. Apple provides a AppleUSBAudio.kext.
I tried unloading that with sudo kextunload /System/Library/Extensions/AppleUSBAudio.kext before starting Qemu.
Qemu then is dead slow, and locks up every few seconds.

Best,
Cat_7
fargo
Space Cadet
Posts: 6
Joined: Thu Feb 06, 2020 6:03 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by fargo »

Cat_7 wrote:Any usb-devices that Qemu accesses while OSX host already has some driver installed for them will not be accessible by the guest. This is a known issue with libusb on Mac OSX hosts.
It might be possible to unload the kext that locked access to a device if you know which one. Apple provides a AppleUSBAudio.kext.
I tried unloading that with sudo kextunload /System/Library/Extensions/AppleUSBAudio.kext before starting Qemu.
Qemu then is dead slow, and locks up every few seconds.
I'm trying to mount Imation SuperDisk Drive on MacOS 9.2 (guest) running on macOS 10.15 (host). The guest can recognize the drive only if I run qemu-system-ppc as a super user (sudo), but any inserted floppy in this case appears under the host system!

How can I know the kext that the host system uses in order to unload it?

Thank you.
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

I wouldn't know. Unloading kexts that support disks might be unadvisable.

What is your command line?
I would first try to unmount the disk from within Disk Utility (but not eject) and then start Qemu as root

EDIT: forget this:
If that doesn't work, then check the device name for a mounted disk in Disk Utility. It will be something like disk3s0
Unmount the disk from Disk Utility and add to your command line fd0 /dev/xxxxxx (where xxxxxx is the device name you found with Disk Utiltily. Start Qemu as root.
However, I do not know whether Qemu-system-ppc running Mac OS supports floppies at all.
EDIT: adding fd0 will not work, it is unsupported in qemu-system-ppc.

ANOTHER EDIT: I tried this with a floppy disk image file, and it didn't work.
You might also check our guide about reading cdroms from the host:
https://www.emaculation.com/doku.php/pp ... _a_real_cd
and adapt it for reading a floppy.

Best,
Cat_7
fargo
Space Cadet
Posts: 6
Joined: Thu Feb 06, 2020 6:03 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by fargo »

Thank you Cat_7

Here are the steps I did:
  1. Unmount floppy (/dev/disk4) from host
  2. Launch goest using this command:

    Code: Select all

    sudo ./qemu-system-ppc -L pc-bios -M mac99,via=pmu -m 128 \
    -drive file=MacOS92.img,format=raw,media=disk -boot c \
    -usb -device usb-host,vendorid=0x0718,productid=0x0002
    The floppy drive starts reading the disk and is automatically re-mounted to the host system!
  3. Unmount the floppy again
  4. Switch to combat_monitor0 view.
  5. Enter:

    Code: Select all

    change floppy0 /dev/disk4
  6. The floppy drive starts rotating and the following message appears on the console:

    Code: Select all

    WARNING: Image format was not specified for '/dev/disk4' and probing guessed raw.
             Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
             Specify the 'raw' format explicitly to remove the restrictions.
  7. No floppy icon appears on the guest system's desktop as one would expect.
Here is a screenshot of the USB info from the guest system:
Image
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

Hi,

Yes, I was afraid you would end up with this. This is as far as I got too with a floppy image. I know no solution.
Your superdrive might fail due to usb limitations in qemu or disk reading limitations in qemu.

Edit: did you install the driver in Mac OS? Something like this:
https://www.macintoshrepository.org/257 ... driver-3-3
Edit2: it seems the driver is included in Mac OS, so no need for an additional one.

Best,
Cat_7

ps: 4. Switch to combat_monitor0 view. Lets not do that ;-) lets switch to the compat_monitor view ;-)
fargo
Space Cadet
Posts: 6
Joined: Thu Feb 06, 2020 6:03 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by fargo »

Cat_7 wrote:Yes, I was afraid you would end up with this. This is as far as I got too with a floppy image. I know no solution.
Your superdrive might fail due to usb limitations in qemu or disk reading limitations in qemu.
Hmm, what about using QEMU for Windows (instead of the macSO version I'm currently using)? I think I've read that the USB support in Windows (or maybe Linux?) is better than that found in the macOS version.
Cat_7 wrote:ps: 4. Switch to combat_monitor0 view. Lets not do that ;-) lets switch to the compat_monitor view ;-)
Sorry, but I didn't get this comment :roll: :oops:

Thank you.
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

Hi,
Hmm, what about using QEMU for Windows (instead of the macSO version I'm currently using)? I think I've read that the USB support in Windows (or maybe Linux?) is better than that found in the macOS version.
Linux would be the choice to go to, to have any chance of success. At least there you can find and disable the driver to load. No idea whether it will actually work.
Sorry, but I didn't get this comment
Ah: this monitor is not called combat monitor, but compat monitor.

Best,
Cat_7
fargo
Space Cadet
Posts: 6
Joined: Thu Feb 06, 2020 6:03 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by fargo »

Cat_7 wrote:Linux would be the choice to go to, to have any chance of success. At least there you can find and disable the driver to load. No idea whether it will actually work.
Ok, I'll try to install Linux on a computer and see. I'll report back here with any result.
Cat_7 wrote:Ah: this monitor is not called combat monitor, but compat monitor.
Oh, my bad! I didn't notice that :oops:

Thank you.
CaptainKoloth
Space Cadet
Posts: 2
Joined: Tue Mar 31, 2020 12:19 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by CaptainKoloth »

Sorry to resurrect this thread, but I'm having the same problem; can anybody help me?

I'm brand new to Mac emulation but have finally gotten Mac 9.2 up and running in QEMU. However, when I try to follow these steps and assign my USB joystick via manufacturer and device ID, I get the message:

libusb: warning [hid_abort transfers] cancel failed: [1168] element not found.

Also happens when I try to go by port. I'm clearly doing something wrong; can someone provide guidance for an idiot on how to find the right port values or other information I need to pass through my joystick to QEMU? I'm brand new to QEMU and finding it a little baffling...
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

Hi,

Yes, qemu command lines can be baffling. But versatile...
What is your host system? Your command line?

Best,
Cat_7
CaptainKoloth
Space Cadet
Posts: 2
Joined: Tue Mar 31, 2020 12:19 pm

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by CaptainKoloth »

Windows 10, running QEMU emulating PPC.
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: USB Joystick in Qemu/Mac OS 9.2.2 ?

Post by Cat_7 »

I can't be completely sure, but you will most probably not be able to pass through successfully on Windows.
Libusb (needed to do the passing) has issues on Windows.

Best,
Cat_7
Post Reply