mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Create hid_driver_get_data
This commit is contained in:
parent
e2fde41124
commit
d15ad86705
1
driver.h
1
driver.h
@ -210,7 +210,6 @@ typedef struct driver
|
|||||||
|
|
||||||
void *font_osd_data;
|
void *font_osd_data;
|
||||||
void *video_shader_data;
|
void *video_shader_data;
|
||||||
void *hid_data;
|
|
||||||
void *camera_data;
|
void *camera_data;
|
||||||
void *location_data;
|
void *location_data;
|
||||||
void *recording_data;
|
void *recording_data;
|
||||||
|
@ -133,10 +133,9 @@ static void iohidmanager_hid_device_report(void *data,
|
|||||||
CFIndex reportLength)
|
CFIndex reportLength)
|
||||||
{
|
{
|
||||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data;
|
||||||
driver_t *driver = driver_get_ptr();
|
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)hid_driver_get_data();
|
||||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
|
||||||
|
|
||||||
if (adapter)
|
if (hid && adapter)
|
||||||
pad_connection_packet(&hid->slots[adapter->slot], adapter->slot,
|
pad_connection_packet(&hid->slots[adapter->slot], adapter->slot,
|
||||||
adapter->data, reportLength + 1);
|
adapter->data, reportLength + 1);
|
||||||
}
|
}
|
||||||
@ -147,8 +146,7 @@ static void iohidmanager_hid_device_report(void *data,
|
|||||||
static void iohidmanager_hid_device_input_callback(void *data, IOReturn result,
|
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();
|
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)hid_driver_get_data();
|
||||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
|
||||||
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,11 +222,10 @@ 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();
|
|
||||||
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 = (iohidmanager_hid_t*)hid_driver_get_data();
|
||||||
|
|
||||||
if (adapter && (adapter->slot < MAX_USERS))
|
if (hid && adapter && (adapter->slot < MAX_USERS))
|
||||||
{
|
{
|
||||||
input_config_autoconfigure_disconnect(adapter->slot, adapter->name);
|
input_config_autoconfigure_disconnect(adapter->slot, adapter->name);
|
||||||
|
|
||||||
@ -299,8 +296,7 @@ static void iohidmanager_hid_device_add(void *data, IOReturn result,
|
|||||||
uint16_t dev_vid, dev_pid;
|
uint16_t dev_vid, dev_pid;
|
||||||
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
driver_t *driver = driver_get_ptr();
|
iohidmanager_hid_t *hid = (iohidmanager_hid_t*)hid_driver_get_data();
|
||||||
iohidmanager_hid_t *hid = driver ? (iohidmanager_hid_t*)driver->hid_data : NULL;
|
|
||||||
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)
|
struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)
|
||||||
calloc(1, sizeof(*adapter));
|
calloc(1, sizeof(*adapter));
|
||||||
|
|
||||||
|
@ -33,52 +33,44 @@ static bool hid_joypad_init(void *data)
|
|||||||
|
|
||||||
static bool hid_joypad_query_pad(unsigned pad)
|
static bool hid_joypad_query_pad(unsigned pad)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->query_pad((void*)hid_driver_get_data(), pad);
|
||||||
return generic_hid->query_pad(driver->hid_data, pad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_joypad_free(void)
|
static void hid_joypad_free(void)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
generic_hid->free((void*)hid_driver_get_data());
|
||||||
generic_hid->free(driver->hid_data);
|
|
||||||
generic_hid = NULL;
|
generic_hid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hid_joypad_button(unsigned port, uint16_t joykey)
|
static bool hid_joypad_button(unsigned port, uint16_t joykey)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->button((void*)hid_driver_get_data(), port, joykey);
|
||||||
return generic_hid->button(driver->hid_data, port, joykey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t hid_joypad_get_buttons(unsigned port)
|
static uint64_t hid_joypad_get_buttons(unsigned port)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->get_buttons((void*)hid_driver_get_data(), port);
|
||||||
return generic_hid->get_buttons(driver->hid_data, port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis)
|
static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->axis((void*)hid_driver_get_data(), port, joyaxis);
|
||||||
return generic_hid->axis(driver->hid_data, port, joyaxis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_joypad_poll(void)
|
static void hid_joypad_poll(void)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
generic_hid->poll((void*)hid_driver_get_data());
|
||||||
generic_hid->poll(driver->hid_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hid_joypad_rumble(unsigned pad,
|
static bool hid_joypad_rumble(unsigned pad,
|
||||||
enum retro_rumble_effect effect, uint16_t strength)
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->set_rumble((void*)hid_driver_get_data(), pad, effect, strength);
|
||||||
return generic_hid->set_rumble(driver->hid_data, pad, effect, strength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *hid_joypad_name(unsigned pad)
|
static const char *hid_joypad_name(unsigned pad)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
return generic_hid->name((void*)hid_driver_get_data(), pad);
|
||||||
return generic_hid->name(driver->hid_data, pad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input_device_driver_t hid_joypad = {
|
input_device_driver_t hid_joypad = {
|
||||||
|
@ -40,6 +40,8 @@ static hid_driver_t *hid_drivers[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const void *hid_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hid_driver_find_handle:
|
* hid_driver_find_handle:
|
||||||
* @idx : index of driver to get handle to.
|
* @idx : index of driver to get handle to.
|
||||||
@ -55,6 +57,11 @@ const void *hid_driver_find_handle(int idx)
|
|||||||
return drv;
|
return drv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void *hid_driver_get_data(void)
|
||||||
|
{
|
||||||
|
return hid_data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hid_driver_find_ident:
|
* hid_driver_find_ident:
|
||||||
* @idx : index of driver to get handle to.
|
* @idx : index of driver to get handle to.
|
||||||
@ -95,10 +102,9 @@ const hid_driver_t *input_hid_init_first(void)
|
|||||||
|
|
||||||
for (i = 0; hid_drivers[i]; i++)
|
for (i = 0; hid_drivers[i]; i++)
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
hid_data = hid_drivers[i]->init();
|
||||||
driver->hid_data = hid_drivers[i]->init();
|
|
||||||
|
|
||||||
if (driver->hid_data)
|
if (hid_data)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Found HID driver: \"%s\".\n",
|
RARCH_LOG("Found HID driver: \"%s\".\n",
|
||||||
hid_drivers[i]->ident);
|
hid_drivers[i]->ident);
|
||||||
|
@ -85,6 +85,8 @@ const char* config_get_hid_driver_options(void);
|
|||||||
**/
|
**/
|
||||||
const hid_driver_t *input_hid_init_first(void);
|
const hid_driver_t *input_hid_init_first(void);
|
||||||
|
|
||||||
|
const void *hid_driver_get_data(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user