dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Getting a bluetooth tank mouse working #806

Closed DidierMalenfant closed 6 months ago

DidierMalenfant commented 6 months ago

I've somehow only discovered this project now, late to the party I know...

My Macbook Trackpad works great but my bluetooth Tank Mouse doesn't.

Screenshot 2024-01-02 at 17 45 42

Where can I begin trying to diagnose this? I'm a developer and I can contribute time and code if it helps.

dirkwhoffmann commented 6 months ago

Welcome on board!

The entry point for debugging game pad devices is function hidInputValueAction in file GUI/Peripherals/GamePad.swift. You should check if this function is called when your device is plugged in and how the received values compare to what's expected inside this function.

    func hidInputValueAction(context: UnsafeMutableRawPointer?,
                             result: IOReturn,
                             sender: UnsafeMutableRawPointer?,
                             value: IOHIDValue) {

        let element   = IOHIDValueGetElement(value)
        let intValue  = Int(IOHIDValueGetIntegerValue(value))
        let usagePage = Int(IOHIDElementGetUsagePage(element))
        let usage     = Int(IOHIDElementGetUsage(element))

        // track("usagePage = \(usagePage) usage = \(usage) value = \(intValue)")

        var events: [GamePadAction]?

        if usagePage == kHIDPage_Button {

            // track("button = \(usage)")

            switch hScheme {

            case Schemes.B4B7:

                switch usage {
                case 5: events = intValue != 0 ? [.PULL_UP] : [.RELEASE_Y]
                case 6: events = intValue != 0 ? [.PULL_RIGHT] : [.RELEASE_X]
                case 7: events = intValue != 0 ? [.PULL_DOWN] : [.RELEASE_Y]
                case 8: events = intValue != 0 ? [.PULL_LEFT] : [.RELEASE_X]
                default: events = intValue != 0 ? [.PRESS_FIRE] : [.RELEASE_FIRE]
                }

         ...
DidierMalenfant commented 6 months ago

Thank you! Glad to be here...

Actually this will just be my official first bone-headed issue (there will be more I'm sure :)

Turns out the tank mouse appears as a separate selection than the default trackpad in the mouse menu. Selecting it works as expected...