(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)
|
int32_t cocoa_input_find_any_button(uint32_t port)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = -1;
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
|
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;
|
return -1;
|
||||||
|
|
||||||
if (apple->joypad)
|
if (apple->joypad)
|
||||||
|
{
|
||||||
apple->joypad->poll();
|
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)
|
if (ret != -1)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (apple && apple->sec_joypad && apple->sec_joypad->get_buttons)
|
if (apple->sec_joypad)
|
||||||
{
|
{
|
||||||
apple->sec_joypad->poll();
|
apple->sec_joypad->poll();
|
||||||
ret = cocoa_input_find_any_button_ret(apple, apple->sec_joypad->get_buttons(port), port);
|
|
||||||
|
|
||||||
if (ret != -1)
|
if (apple->sec_joypad->get_buttons)
|
||||||
return ret;
|
{
|
||||||
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ typedef struct
|
||||||
uint32_t touch_count;
|
uint32_t touch_count;
|
||||||
|
|
||||||
uint32_t mouse_buttons;
|
uint32_t mouse_buttons;
|
||||||
int16_t mouse_x_last;
|
int16_t mouse_x_last;
|
||||||
int16_t mouse_y_last;
|
int16_t mouse_y_last;
|
||||||
int16_t window_pos_x;
|
int16_t window_pos_x;
|
||||||
int16_t window_pos_y;
|
int16_t window_pos_y;
|
||||||
int16_t mouse_rel_x;
|
int16_t mouse_rel_x;
|
||||||
int16_t mouse_rel_y;
|
int16_t mouse_rel_y;
|
||||||
int16_t mouse_wu;
|
int16_t mouse_wu;
|
||||||
|
@ -54,13 +54,12 @@ typedef struct
|
||||||
|
|
||||||
uint32_t key_state[MAX_KEYS];
|
uint32_t key_state[MAX_KEYS];
|
||||||
|
|
||||||
uint32_t buttons[MAX_USERS];
|
|
||||||
int8_t hats[NUM_HATS][2];
|
int8_t hats[NUM_HATS][2];
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
bool small_keyboard_active;
|
bool small_keyboard_active;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const input_device_driver_t *sec_joypad;
|
const input_device_driver_t *sec_joypad;
|
||||||
const input_device_driver_t *joypad;
|
const input_device_driver_t *joypad;
|
||||||
} cocoa_input_data_t;
|
} cocoa_input_data_t;
|
||||||
|
|
|
@ -26,6 +26,7 @@ typedef struct apple_hid
|
||||||
{
|
{
|
||||||
IOHIDManagerRef ptr;
|
IOHIDManagerRef ptr;
|
||||||
joypad_connection_t *slots;
|
joypad_connection_t *slots;
|
||||||
|
uint32_t buttons[MAX_USERS];
|
||||||
int16_t axes[MAX_USERS][6];
|
int16_t axes[MAX_USERS][6];
|
||||||
} iohidmanager_hid_t;
|
} 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)
|
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);
|
uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port);
|
||||||
|
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data;
|
||||||
|
|
||||||
if (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))
|
||||||
|
@ -80,10 +74,7 @@ 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 ((buttons & (1 << joykey)) != 0)
|
return ((buttons & (1 << joykey)) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0)
|
||||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
|
||||||
|| ((apple->buttons[port] & (1 << joykey)) != 0)
|
|
||||||
#endif
|
|
||||||
;
|
;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -157,9 +148,6 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
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;
|
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);
|
||||||
|
@ -224,9 +212,9 @@ static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
||||||
unsigned id = use - 1;
|
unsigned id = use - 1;
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
BIT64_SET(apple->buttons[adapter->slot], id);
|
BIT64_SET(hid->buttons[adapter->slot], id);
|
||||||
else
|
else
|
||||||
BIT64_CLEAR(apple->buttons[adapter->slot], id);
|
BIT64_CLEAR(hid->buttons[adapter->slot], id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
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)
|
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;
|
|
||||||
#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;
|
||||||
|
|
||||||
|
@ -248,9 +233,7 @@ 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)
|
hid->buttons[adapter->slot] = 0;
|
||||||
apple->buttons[adapter->slot] = 0;
|
|
||||||
#endif
|
|
||||||
memset(hid->axes[adapter->slot], 0, sizeof(hid->axes));
|
memset(hid->axes[adapter->slot], 0, sizeof(hid->axes));
|
||||||
|
|
||||||
pad_connection_pad_deinit(&hid->slots[adapter->slot], adapter->slot);
|
pad_connection_pad_deinit(&hid->slots[adapter->slot], adapter->slot);
|
||||||
|
|
Loading…
Reference in New Issue