mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-19 09:23:01 +00:00
Move driver->input_data to input_driver.c
This commit is contained in:
parent
ea18f0f5e3
commit
5e1b2b3bfa
1
driver.h
1
driver.h
@ -211,7 +211,6 @@ typedef struct driver
|
||||
|
||||
void *font_osd_data;
|
||||
void *video_shader_data;
|
||||
void *input_data;
|
||||
void *hid_data;
|
||||
void *camera_data;
|
||||
void *location_data;
|
||||
|
@ -28,8 +28,7 @@
|
||||
|
||||
int32_t cocoa_input_find_any_key(void)
|
||||
{
|
||||
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*)input_driver_get_data();
|
||||
|
||||
if (!apple)
|
||||
return 0;
|
||||
@ -58,8 +57,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 = -1;
|
||||
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*)input_driver_get_data();
|
||||
|
||||
if (!apple)
|
||||
return -1;
|
||||
@ -95,8 +93,7 @@ int32_t cocoa_input_find_any_button(uint32_t port)
|
||||
int32_t cocoa_input_find_any_axis(uint32_t port)
|
||||
{
|
||||
int i;
|
||||
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*)input_driver_get_data();
|
||||
|
||||
if (apple && apple->joypad)
|
||||
apple->joypad->poll();
|
||||
|
@ -49,8 +49,7 @@ static bool qnx_joypad_init(void *data)
|
||||
|
||||
static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver->input_data;
|
||||
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
||||
|
||||
if (!qnx || port_num >= MAX_PADS)
|
||||
return false;
|
||||
@ -60,8 +59,7 @@ static bool qnx_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
|
||||
static uint64_t qnx_joypad_get_buttons(unsigned port_num)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver->input_data;
|
||||
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
||||
|
||||
if (!qnx || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
@ -74,8 +72,7 @@ static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver->input_data;
|
||||
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
||||
|
||||
if (!qnx || joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
@ -121,8 +118,7 @@ static void qnx_joypad_poll(void)
|
||||
|
||||
static bool qnx_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
qnx_input_t *qnx = (qnx_input_t*)driver->input_data;
|
||||
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
|
||||
return (qnx && pad < MAX_USERS && qnx->pad_state[pad]);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ struct turbo_buttons
|
||||
unsigned count;
|
||||
};
|
||||
|
||||
static void *main_input_data;
|
||||
static bool flushing_input;
|
||||
static bool block_libretro_input;
|
||||
static bool block_hotkey;
|
||||
@ -154,7 +155,7 @@ bool input_driver_set_rumble_state(unsigned port,
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->set_rumble)
|
||||
return input->set_rumble(driver->input_data,
|
||||
return input->set_rumble(main_input_data,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
@ -165,7 +166,7 @@ int16_t input_driver_state(const struct retro_keybind **retro_keybinds,
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
return input->input_state(driver->input_data, retro_keybinds,
|
||||
return input->input_state(main_input_data, retro_keybinds,
|
||||
port, device, index, id);
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ const input_device_driver_t *input_driver_get_joypad_driver(void)
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->get_joypad_driver)
|
||||
return input->get_joypad_driver(driver->input_data);
|
||||
return input->get_joypad_driver(main_input_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -185,7 +186,7 @@ const input_device_driver_t *input_driver_get_sec_joypad_driver(void)
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->get_sec_joypad_driver)
|
||||
return input->get_sec_joypad_driver(driver->input_data);
|
||||
return input->get_sec_joypad_driver(main_input_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -195,7 +196,7 @@ uint64_t input_driver_get_capabilities(void)
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->get_capabilities)
|
||||
return input->get_capabilities(driver->input_data);
|
||||
return input->get_capabilities(main_input_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -206,7 +207,7 @@ bool input_driver_grab_mouse(bool state)
|
||||
|
||||
if (input->grab_mouse)
|
||||
{
|
||||
input->grab_mouse(driver->input_data, state);
|
||||
input->grab_mouse(main_input_data, state);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -219,7 +220,7 @@ void input_driver_set(const input_driver_t **input, void **input_data)
|
||||
if (input && input_data)
|
||||
{
|
||||
*input = driver->input;
|
||||
*input_data = driver->input_data;
|
||||
*input_data = main_input_data;
|
||||
}
|
||||
|
||||
driver->input_data_own = true;
|
||||
@ -231,7 +232,7 @@ void input_driver_keyboard_mapping_set_block(bool value)
|
||||
const input_driver_t *input = input_get_ptr(driver);
|
||||
|
||||
if (input->keyboard_mapping_set_block)
|
||||
driver->input->keyboard_mapping_set_block(driver->input_data, value);
|
||||
driver->input->keyboard_mapping_set_block(main_input_data, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,9 +249,9 @@ bool input_sensor_set_state(unsigned port,
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (driver->input && driver->input_data &&
|
||||
if (driver->input && main_input_data &&
|
||||
driver->input->set_sensor_state)
|
||||
return driver->input->set_sensor_state(driver->input_data,
|
||||
return driver->input->set_sensor_state(main_input_data,
|
||||
port, action, rate);
|
||||
return false;
|
||||
}
|
||||
@ -259,9 +260,9 @@ float input_sensor_get_input(unsigned port, unsigned id)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (driver->input && driver->input_data &&
|
||||
if (driver->input && main_input_data &&
|
||||
driver->input->get_sensor_input)
|
||||
return driver->input->get_sensor_input(driver->input_data,
|
||||
return driver->input->get_sensor_input(main_input_data,
|
||||
port, id);
|
||||
return 0.0f;
|
||||
}
|
||||
@ -271,7 +272,7 @@ bool input_driver_key_pressed(unsigned key)
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (driver->input && driver->input->key_pressed)
|
||||
return driver->input->key_pressed(driver->input_data, key);
|
||||
return driver->input->key_pressed(main_input_data, key);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -290,7 +291,7 @@ static retro_input_t input_driver_keys_pressed(void)
|
||||
state = input_driver_key_pressed(key);
|
||||
|
||||
if (key >= RARCH_FIRST_META_KEY)
|
||||
state |= input->meta_key_pressed(driver->input_data, key);
|
||||
state |= input->meta_key_pressed(main_input_data, key);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
state |= input_overlay_key_pressed(key);
|
||||
@ -505,7 +506,7 @@ int16_t input_state(unsigned port, unsigned device,
|
||||
if (!flushing_input && !block_libretro_input)
|
||||
{
|
||||
if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD)))
|
||||
res = input->input_state(driver->input_data, libretro_input_binds, port, device, idx, id);
|
||||
res = input->input_state(main_input_data, libretro_input_binds, port, device, idx, id);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
input_state_overlay(&res, port, device, idx, id);
|
||||
@ -607,7 +608,7 @@ retro_input_t input_keys_pressed(void)
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
binds[i] = settings->input.binds[i];
|
||||
|
||||
if (!driver->input || !driver->input_data)
|
||||
if (!driver->input || !main_input_data)
|
||||
return 0;
|
||||
|
||||
turbo_btns.count++;
|
||||
@ -643,20 +644,19 @@ retro_input_t input_keys_pressed(void)
|
||||
}
|
||||
|
||||
|
||||
void *input_driver_get_data(void)
|
||||
{
|
||||
return main_input_data;
|
||||
}
|
||||
|
||||
void **input_driver_get_data_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver)
|
||||
return NULL;
|
||||
return (void**)&driver->input_data;
|
||||
return (void**)&main_input_data;
|
||||
}
|
||||
|
||||
bool input_driver_data_ptr_is_same(void *data)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver)
|
||||
return false;
|
||||
return (driver->input_data == data);
|
||||
return (main_input_data == data);
|
||||
}
|
||||
|
||||
bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
|
||||
@ -669,23 +669,23 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
|
||||
{
|
||||
case RARCH_INPUT_CTL_HAS_CAPABILITIES:
|
||||
if (driver->input &&
|
||||
driver->input->get_capabilities && driver->input_data)
|
||||
driver->input->get_capabilities && main_input_data)
|
||||
return true;
|
||||
return false;
|
||||
case RARCH_INPUT_CTL_POLL:
|
||||
input->poll(driver->input_data);
|
||||
input->poll(main_input_data);
|
||||
return true;
|
||||
case RARCH_INPUT_CTL_INIT:
|
||||
if (driver && driver->input)
|
||||
driver->input_data = driver->input->init();
|
||||
main_input_data = driver->input->init();
|
||||
|
||||
if (!driver->input_data)
|
||||
if (!main_input_data)
|
||||
return false;
|
||||
return true;
|
||||
case RARCH_INPUT_CTL_DEINIT:
|
||||
if (!driver || !driver->input)
|
||||
return false;
|
||||
driver->input->free(driver->input_data);
|
||||
driver->input->free(main_input_data);
|
||||
return true;
|
||||
case RARCH_INPUT_CTL_DESTROY:
|
||||
flushing_input = false;
|
||||
@ -694,16 +694,16 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data)
|
||||
memset(&turbo_btns, 0, sizeof(turbo_buttons_t));
|
||||
if (!driver)
|
||||
return false;
|
||||
driver->input_data = NULL;
|
||||
main_input_data = NULL;
|
||||
return true;
|
||||
case RARCH_INPUT_CTL_GRAB_STDIN:
|
||||
if (input->grab_stdin)
|
||||
return input->grab_stdin(driver->input_data);
|
||||
return input->grab_stdin(main_input_data);
|
||||
return false;
|
||||
case RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED:
|
||||
if (input->keyboard_mapping_is_blocked)
|
||||
return driver->input->keyboard_mapping_is_blocked(
|
||||
driver->input_data);
|
||||
main_input_data);
|
||||
return false;
|
||||
case RARCH_INPUT_CTL_FIND_DRIVER:
|
||||
{
|
||||
|
@ -268,6 +268,8 @@ retro_input_t input_keys_pressed(void);
|
||||
|
||||
bool input_driver_ctl(enum rarch_input_ctl_state state, void *data);
|
||||
|
||||
void *input_driver_get_data(void);
|
||||
|
||||
void **input_driver_get_data_ptr(void);
|
||||
|
||||
bool input_driver_data_ptr_is_same(void *data);
|
||||
|
@ -48,9 +48,6 @@ void apple_rarch_exited(void)
|
||||
{
|
||||
NSEventType event_type;
|
||||
cocoa_input_data_t *apple = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver)
|
||||
return;
|
||||
[super sendEvent:event];
|
||||
|
||||
event_type = event.type;
|
||||
@ -110,7 +107,7 @@ void apple_rarch_exited(void)
|
||||
NSPoint pos;
|
||||
NSPoint mouse_pos;
|
||||
|
||||
apple = (cocoa_input_data_t*)driver->input_data;
|
||||
apple = (cocoa_input_data_t*)input_driver_get_data();
|
||||
if (!apple)
|
||||
return;
|
||||
|
||||
@ -148,7 +145,7 @@ void apple_rarch_exited(void)
|
||||
case NSLeftMouseDown:
|
||||
case NSRightMouseDown:
|
||||
case NSOtherMouseDown:
|
||||
apple = (cocoa_input_data_t*)driver->input_data;
|
||||
apple = (cocoa_input_data_t*)input_driver_get_data();
|
||||
if (!apple)
|
||||
return;
|
||||
apple->mouse_buttons |= 1 << event.buttonNumber;
|
||||
@ -157,7 +154,7 @@ void apple_rarch_exited(void)
|
||||
case NSLeftMouseUp:
|
||||
case NSRightMouseUp:
|
||||
case NSOtherMouseUp:
|
||||
apple = (cocoa_input_data_t*)driver->input_data;
|
||||
apple = (cocoa_input_data_t*)input_driver_get_data();
|
||||
if (!apple)
|
||||
return;
|
||||
apple->mouse_buttons &= ~(1 << event.buttonNumber);
|
||||
|
@ -108,8 +108,7 @@ extern float cocoagl_gfx_ctx_get_native_scale(void);
|
||||
static void handle_touch_event(NSArray* touches)
|
||||
{
|
||||
unsigned i;
|
||||
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*)input_driver_get_data();
|
||||
float scale = cocoagl_gfx_ctx_get_native_scale();
|
||||
|
||||
if (!apple)
|
||||
|
Loading…
x
Reference in New Issue
Block a user