elnormous / ouzel

C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
The Unlicense
990 stars 112 forks source link

macOS game controller problem #51

Open urcereal opened 3 years ago

urcereal commented 3 years ago

Getting Unknown axis runtime error with PS3 and PS4 V2 controllers. With the PS3 controller axis = 1 (kHIDUsage_GD_Pointer?) in getAxisIndex.

For PS4 V2 axis = 57 (0x39) which is kHIDUsage_GD_Hatswitch. The type is kIOHIDElementTypeInput_Misc and the usagePage is kHIDPage_GenericDesktop. This then calls getAxisIndex at line 106 of GamepadDeviceIOKit.cpp.

Running on macOS 11.2 using Xcode 12.4

urcereal commented 3 years ago

Quick fix would be to add 1 to the axisMap so that we can return the none value if anything other than X, Y, Z, RX, RY, RZ is detected which would match the buttonMap I think. The getAxisIndex returns the none index for out of range values.