mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-24 12:15:37 +00:00
Reworked Mac OS X joystick code to use the 10.5+ HID Manager API.
Besides being a little more simple to use than the earlier IOKit HID API, and less likely to be deprecated, it also has the added benefit of working with the Sony DualShock 4 controller in Bluetooth mode out of the box, whereas the previous API has a bug that makes it report bad data for the controller. Cleaned up several other things in this code, having gone over every line of it. The remaining deprecated calls are also gone.
This commit is contained in:
parent
abe2ac2cb4
commit
0deb54c024
File diff suppressed because it is too large
Load diff
|
@ -22,34 +22,18 @@
|
|||
|
||||
#ifndef SDL_JOYSTICK_IOKIT_H
|
||||
|
||||
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/hid/IOHIDKeys.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
|
||||
struct recElement
|
||||
{
|
||||
IOHIDElementCookie cookie; /* unique value which identifies element, will NOT change */
|
||||
long usagePage, usage; /* HID usage */
|
||||
long min; /* reported min value possible */
|
||||
long max; /* reported max value possible */
|
||||
#if 0
|
||||
/* TODO: maybe should handle the following stuff somehow? */
|
||||
|
||||
long scaledMin; /* reported scaled min value possible */
|
||||
long scaledMax; /* reported scaled max value possible */
|
||||
long size; /* size in bits of data return from element */
|
||||
Boolean relative; /* are reports relative to last report (deltas) */
|
||||
Boolean wrapping; /* does element wrap around (one value higher than max is min) */
|
||||
Boolean nonLinear; /* are the values reported non-linear relative to element movement */
|
||||
Boolean preferredState; /* does element have a preferred state (such as a button) */
|
||||
Boolean nullState; /* does element have null state */
|
||||
#endif /* 0 */
|
||||
IOHIDElementRef elementRef;
|
||||
uint32_t usagePage, usage; /* HID usage */
|
||||
SInt32 min; /* reported min value possible */
|
||||
SInt32 max; /* reported max value possible */
|
||||
|
||||
/* runtime variables used for auto-calibration */
|
||||
long minReport; /* min returned value */
|
||||
long maxReport; /* max returned value */
|
||||
SInt32 minReport; /* min returned value */
|
||||
SInt32 maxReport; /* max returned value */
|
||||
|
||||
struct recElement *pNext; /* next element in list */
|
||||
};
|
||||
|
@ -57,19 +41,17 @@ typedef struct recElement recElement;
|
|||
|
||||
struct joystick_hwdata
|
||||
{
|
||||
IOHIDDeviceRef deviceRef; /* HIDManager device handle */
|
||||
io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
|
||||
IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */
|
||||
IONotificationPortRef notificationPort; /* port to be notified on joystick removal */
|
||||
io_iterator_t portIterator; /* iterator for removal callback */
|
||||
|
||||
char product[256]; /* name of product */
|
||||
long usage; /* usage page from IOUSBHID Parser.h which defines general usage */
|
||||
long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */
|
||||
uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */
|
||||
uint32_t usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */
|
||||
|
||||
long axes; /* number of axis (calculated, not reported by device) */
|
||||
long buttons; /* number of buttons (calculated, not reported by device) */
|
||||
long hats; /* number of hat switches (calculated, not reported by device) */
|
||||
long elements; /* number of total elements (should be total of above) (calculated, not reported by device) */
|
||||
int axes; /* number of axis (calculated, not reported by device) */
|
||||
int buttons; /* number of buttons (calculated, not reported by device) */
|
||||
int hats; /* number of hat switches (calculated, not reported by device) */
|
||||
int elements; /* number of total elements (should be total of above) (calculated, not reported by device) */
|
||||
|
||||
recElement *firstAxis;
|
||||
recElement *firstButton;
|
||||
|
|
Loading…
Reference in a new issue