mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-22 02:44:38 +00:00
Merge pull request #2016 from slotek/master
Restore generic Mac OS X joypad functionality
This commit is contained in:
commit
b602d465b4
@ -105,7 +105,7 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return pad;
|
||||
}
|
||||
|
||||
void pad_connection_pad_deinit(joypad_connection_t *joyconn, uint32_t pad)
|
||||
|
@ -59,9 +59,11 @@ 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)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||
uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port);
|
||||
|
||||
if (joykey == NO_BTN)
|
||||
if (!apple || joykey == NO_BTN)
|
||||
return false;
|
||||
|
||||
/* Check hat. */
|
||||
@ -70,7 +72,8 @@ static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t j
|
||||
|
||||
/* Check the button. */
|
||||
if ((port < MAX_USERS) && (joykey < 32))
|
||||
return ((buttons & (1 << joykey)) != 0);
|
||||
return ((apple->buttons[port] & (1 << joykey)) != 0) ||
|
||||
((buttons & (1 << joykey)) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -85,22 +88,26 @@ static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad,
|
||||
|
||||
static int16_t iohidmanager_hid_joypad_axis(void *data, unsigned port, uint32_t joyaxis)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
||||
int16_t val = 0;
|
||||
|
||||
if (joyaxis == AXIS_NONE)
|
||||
if (!apple || joyaxis == AXIS_NONE)
|
||||
return 0;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
val = pad_connection_get_axis(&hid->slots[port], port, AXIS_NEG_GET(joyaxis));
|
||||
val = apple->axes[port][AXIS_NEG_GET(joyaxis)];
|
||||
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_NEG_GET(joyaxis));
|
||||
|
||||
if (val >= 0)
|
||||
val = 0;
|
||||
}
|
||||
else if(AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
val = pad_connection_get_axis(&hid->slots[port], port, AXIS_POS_GET(joyaxis));
|
||||
val = apple->axes[port][AXIS_POS_GET(joyaxis)];
|
||||
val += pad_connection_get_axis(&hid->slots[port], port, AXIS_POS_GET(joyaxis));
|
||||
|
||||
if (val <= 0)
|
||||
val = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user