mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 09:39:56 +00:00
(OSX) Add HAVE_COCOA and HAVE_COCOATOUCH ifdefs to iohidmanager_hid.c
This commit is contained in:
parent
a095ccbdb6
commit
1489839384
@ -60,11 +60,17 @@ static uint64_t iohidmanager_hid_joypad_get_buttons(void *data, unsigned port)
|
|||||||
static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey)
|
static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||||
|
#endif
|
||||||
uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port);
|
uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port);
|
||||||
|
|
||||||
if (!apple || joykey == NO_BTN)
|
if (joykey == NO_BTN)
|
||||||
return false;
|
return false;
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
|
if (!apple)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check hat. */
|
/* Check hat. */
|
||||||
if (GET_HAT_DIR(joykey))
|
if (GET_HAT_DIR(joykey))
|
||||||
@ -72,8 +78,11 @@ static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t j
|
|||||||
|
|
||||||
/* Check the button. */
|
/* Check the button. */
|
||||||
if ((port < MAX_USERS) && (joykey < 32))
|
if ((port < MAX_USERS) && (joykey < 32))
|
||||||
return ((apple->buttons[port] & (1 << joykey)) != 0) ||
|
return ((buttons & (1 << joykey)) != 0)
|
||||||
((buttons & (1 << joykey)) != 0);
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
|
|| ((apple->buttons[port] & (1 << joykey)) != 0)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,16 +98,24 @@ static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad,
|
|||||||
static int16_t iohidmanager_hid_joypad_axis(void *data, unsigned port, uint32_t joyaxis)
|
static int16_t iohidmanager_hid_joypad_axis(void *data, unsigned port, uint32_t joyaxis)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||||
|
#endif
|
||||||
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
||||||
int16_t val = 0;
|
int16_t val = 0;
|
||||||
|
|
||||||
if (!apple || joyaxis == AXIS_NONE)
|
if (joyaxis == AXIS_NONE)
|
||||||
return 0;
|
return 0;
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
|
if (!apple)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||||
{
|
{
|
||||||
val = apple->axes[port][AXIS_NEG_GET(joyaxis)];
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
|
val += apple->axes[port][AXIS_NEG_GET(joyaxis)];
|
||||||
|
#endif
|
||||||
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_NEG_GET(joyaxis));
|
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_NEG_GET(joyaxis));
|
||||||
|
|
||||||
if (val >= 0)
|
if (val >= 0)
|
||||||
@ -106,7 +123,9 @@ static int16_t iohidmanager_hid_joypad_axis(void *data, unsigned port, uint32_t
|
|||||||
}
|
}
|
||||||
else if(AXIS_POS_GET(joyaxis) < 4)
|
else if(AXIS_POS_GET(joyaxis) < 4)
|
||||||
{
|
{
|
||||||
val = apple->axes[port][AXIS_POS_GET(joyaxis)];
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
|
val += apple->axes[port][AXIS_POS_GET(joyaxis)];
|
||||||
|
#endif
|
||||||
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_POS_GET(joyaxis));
|
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_POS_GET(joyaxis));
|
||||||
|
|
||||||
if (val <= 0)
|
if (val <= 0)
|
||||||
@ -147,7 +166,9 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
|||||||
void* sender, IOHIDValueRef value)
|
void* sender, IOHIDValueRef value)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||||
|
#endif
|
||||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
||||||
IOHIDElementRef element = IOHIDValueGetElement(value);
|
IOHIDElementRef element = IOHIDValueGetElement(value);
|
||||||
uint32_t type = IOHIDElementGetType(element);
|
uint32_t type = IOHIDElementGetType(element);
|
||||||
@ -187,8 +208,10 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
|||||||
if (use != axis_use_ids[i])
|
if (use != axis_use_ids[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
apple->axes[adapter->slot][i] =
|
apple->axes[adapter->slot][i] =
|
||||||
((val * 2.0f) - 1.0f) * 32767.0f;
|
((val * 2.0f) - 1.0f) * 32767.0f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -204,10 +227,12 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
|||||||
CFIndex state = IOHIDValueGetIntegerValue(value);
|
CFIndex state = IOHIDValueGetIntegerValue(value);
|
||||||
unsigned id = use - 1;
|
unsigned id = use - 1;
|
||||||
|
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
if (state)
|
if (state)
|
||||||
BIT64_SET(apple->buttons[adapter->slot], id);
|
BIT64_SET(apple->buttons[adapter->slot], id);
|
||||||
else
|
else
|
||||||
BIT64_CLEAR(apple->buttons[adapter->slot], id);
|
BIT64_CLEAR(apple->buttons[adapter->slot], id);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -218,7 +243,9 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
|||||||
static void iohidmanager_hid_device_remove(void *data, IOReturn result, void* sender)
|
static void iohidmanager_hid_device_remove(void *data, IOReturn result, void* sender)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||||
|
#endif
|
||||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
||||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
||||||
|
|
||||||
@ -226,8 +253,10 @@ static void iohidmanager_hid_device_remove(void *data, IOReturn result, void* se
|
|||||||
{
|
{
|
||||||
input_config_autoconfigure_disconnect(adapter->slot, adapter->name);
|
input_config_autoconfigure_disconnect(adapter->slot, adapter->name);
|
||||||
|
|
||||||
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||||
apple->buttons[adapter->slot] = 0;
|
apple->buttons[adapter->slot] = 0;
|
||||||
memset(apple->axes[adapter->slot], 0, sizeof(apple->axes));
|
memset(apple->axes[adapter->slot], 0, sizeof(apple->axes));
|
||||||
|
#endif
|
||||||
|
|
||||||
pad_connection_pad_deinit(&hid->slots[adapter->slot], adapter->slot);
|
pad_connection_pad_deinit(&hid->slots[adapter->slot], adapter->slot);
|
||||||
free(adapter);
|
free(adapter);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user