mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(OSX) apple->buttons refactored away
This commit is contained in:
parent
018db7c081
commit
08bb85e509
@ -167,7 +167,7 @@ static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple,
|
||||
|
||||
int32_t cocoa_input_find_any_button(uint32_t port)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||
|
||||
@ -175,25 +175,30 @@ int32_t cocoa_input_find_any_button(uint32_t port)
|
||||
return -1;
|
||||
|
||||
if (apple->joypad)
|
||||
{
|
||||
apple->joypad->poll();
|
||||
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->poll();
|
||||
|
||||
ret = cocoa_input_find_any_button_ret(apple, apple->buttons[port], port);
|
||||
if (apple->joypad->get_buttons)
|
||||
ret = cocoa_input_find_any_button_ret(apple, apple->joypad->get_buttons(port), port);
|
||||
}
|
||||
|
||||
if (ret != -1)
|
||||
return ret;
|
||||
|
||||
if (apple && apple->sec_joypad && apple->sec_joypad->get_buttons)
|
||||
|
||||
if (apple->sec_joypad)
|
||||
{
|
||||
apple->sec_joypad->poll();
|
||||
ret = cocoa_input_find_any_button_ret(apple, apple->sec_joypad->get_buttons(port), port);
|
||||
apple->sec_joypad->poll();
|
||||
|
||||
if (ret != -1)
|
||||
return ret;
|
||||
if (apple->sec_joypad->get_buttons)
|
||||
{
|
||||
apple->sec_joypad->poll();
|
||||
ret = cocoa_input_find_any_button_ret(apple, apple->sec_joypad->get_buttons(port), port);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != -1)
|
||||
return ret;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,10 @@ typedef struct
|
||||
uint32_t touch_count;
|
||||
|
||||
uint32_t mouse_buttons;
|
||||
int16_t mouse_x_last;
|
||||
int16_t mouse_y_last;
|
||||
int16_t window_pos_x;
|
||||
int16_t window_pos_y;
|
||||
int16_t mouse_x_last;
|
||||
int16_t mouse_y_last;
|
||||
int16_t window_pos_x;
|
||||
int16_t window_pos_y;
|
||||
int16_t mouse_rel_x;
|
||||
int16_t mouse_rel_y;
|
||||
int16_t mouse_wu;
|
||||
@ -54,13 +54,12 @@ typedef struct
|
||||
|
||||
uint32_t key_state[MAX_KEYS];
|
||||
|
||||
uint32_t buttons[MAX_USERS];
|
||||
int8_t hats[NUM_HATS][2];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
bool small_keyboard_active;
|
||||
#endif
|
||||
|
||||
|
||||
const input_device_driver_t *sec_joypad;
|
||||
const input_device_driver_t *joypad;
|
||||
} cocoa_input_data_t;
|
||||
|
@ -26,6 +26,7 @@ typedef struct apple_hid
|
||||
{
|
||||
IOHIDManagerRef ptr;
|
||||
joypad_connection_t *slots;
|
||||
uint32_t buttons[MAX_USERS];
|
||||
int16_t axes[MAX_USERS][6];
|
||||
} iohidmanager_hid_t;
|
||||
|
||||
@ -61,18 +62,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)
|
||||
{
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
driver_t *driver = driver_get_ptr();
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||
#endif
|
||||
uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port);
|
||||
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
||||
|
||||
if (joykey == NO_BTN)
|
||||
return false;
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
if (!apple)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/* Check hat. */
|
||||
if (GET_HAT_DIR(joykey))
|
||||
@ -80,10 +74,7 @@ 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)
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
|| ((apple->buttons[port] & (1 << joykey)) != 0)
|
||||
#endif
|
||||
return ((buttons & (1 << joykey)) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0)
|
||||
;
|
||||
return false;
|
||||
}
|
||||
@ -157,9 +148,6 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
||||
#endif
|
||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
||||
IOHIDElementRef element = IOHIDValueGetElement(value);
|
||||
uint32_t type = IOHIDElementGetType(element);
|
||||
@ -224,9 +212,9 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
||||
unsigned id = use - 1;
|
||||
|
||||
if (state)
|
||||
BIT64_SET(apple->buttons[adapter->slot], id);
|
||||
BIT64_SET(hid->buttons[adapter->slot], id);
|
||||
else
|
||||
BIT64_CLEAR(apple->buttons[adapter->slot], id);
|
||||
BIT64_CLEAR(hid->buttons[adapter->slot], id);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -238,9 +226,6 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
||||
static void iohidmanager_hid_device_remove(void *data, IOReturn result, void* sender)
|
||||
{
|
||||
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;
|
||||
#endif
|
||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
||||
|
||||
@ -248,9 +233,7 @@ static void iohidmanager_hid_device_remove(void *data, IOReturn result, void* se
|
||||
{
|
||||
input_config_autoconfigure_disconnect(adapter->slot, adapter->name);
|
||||
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
||||
apple->buttons[adapter->slot] = 0;
|
||||
#endif
|
||||
hid->buttons[adapter->slot] = 0;
|
||||
memset(hid->axes[adapter->slot], 0, sizeof(hid->axes));
|
||||
|
||||
pad_connection_pad_deinit(&hid->slots[adapter->slot], adapter->slot);
|
||||
|
Loading…
x
Reference in New Issue
Block a user