mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
MOve input_joypad_analog call to inside retroarch.c instead of the
input driver itself, and make function static
This commit is contained in:
parent
2a0c490913
commit
689ac432d6
@ -1462,9 +1462,6 @@ static int16_t android_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(android->joypad, joypad_info,
|
||||
port, idx, id, binds[port]);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && BIT_GET(android_key_state[ANDROID_KEYBOARD_PORT], rarch_keysym_lut[id]);
|
||||
|
@ -48,8 +48,10 @@ int32_t cocoa_input_find_any_key(void)
|
||||
if (apple->joypad)
|
||||
apple->joypad->poll();
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->poll();
|
||||
#endif
|
||||
|
||||
return apple_keyboard_find_any_key();
|
||||
}
|
||||
@ -89,6 +91,7 @@ int32_t cocoa_input_find_any_button(uint32_t port)
|
||||
if (ret != -1)
|
||||
return ret;
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
{
|
||||
apple->sec_joypad->poll();
|
||||
@ -101,6 +104,7 @@ int32_t cocoa_input_find_any_button(uint32_t port)
|
||||
ret = cocoa_input_find_any_button_ret(apple, &state, port);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret != -1)
|
||||
return ret;
|
||||
@ -116,8 +120,10 @@ int32_t cocoa_input_find_any_axis(uint32_t port)
|
||||
if (apple && apple->joypad)
|
||||
apple->joypad->poll();
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
if (apple && apple->sec_joypad)
|
||||
apple->sec_joypad->poll();
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
@ -126,7 +132,9 @@ int32_t cocoa_input_find_any_axis(uint32_t port)
|
||||
if (abs(value) > 0x4000)
|
||||
return (value < 0) ? -(i + 1) : i + 1;
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
value = apple->sec_joypad ? apple->sec_joypad->axis(port, i) : value;
|
||||
#endif
|
||||
|
||||
if (abs(value) > 0x4000)
|
||||
return (value < 0) ? -(i + 1) : i + 1;
|
||||
@ -190,8 +198,10 @@ static void cocoa_input_poll(void *data)
|
||||
|
||||
if (apple->joypad)
|
||||
apple->joypad->poll();
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->poll();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||
@ -345,18 +355,6 @@ static int16_t cocoa_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = 0;
|
||||
#ifdef HAVE_MFI
|
||||
ret = input_joypad_analog(apple->sec_joypad, joypad_info, port,
|
||||
idx, id, binds[port]);
|
||||
#endif
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(apple->joypad, joypad_info, port,
|
||||
idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && apple_key_state[rarch_keysym_lut[(enum retro_key)id]];
|
||||
@ -383,8 +381,10 @@ static void cocoa_input_free(void *data)
|
||||
if (apple->joypad)
|
||||
apple->joypad->destroy();
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->destroy();
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_KEYS; i++)
|
||||
apple_key_state[i] = 0;
|
||||
@ -429,10 +429,12 @@ static void cocoa_input_grab_mouse(void *data, bool state)
|
||||
|
||||
static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data)
|
||||
{
|
||||
#ifdef HAVE_MFI
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (apple && apple->sec_joypad)
|
||||
return apple->sec_joypad;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.def.h"
|
||||
#endif
|
||||
|
||||
#include "../input_driver.h"
|
||||
|
||||
/* Input responder */
|
||||
@ -49,7 +53,9 @@ typedef struct
|
||||
int16_t mouse_wl;
|
||||
int16_t mouse_wr;
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad;
|
||||
#endif
|
||||
const input_device_driver_t *joypad;
|
||||
} cocoa_input_data_t;
|
||||
|
||||
|
@ -87,9 +87,6 @@ static int16_t ctr_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(ctr->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -634,15 +634,8 @@ static int16_t dinput_input_state(void *data,
|
||||
di->state[rarch_keysym_lut[(enum retro_key)id]] & 0x80;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = dinput_pressed_analog(di, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(di->joypad, joypad_info,
|
||||
port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return dinput_pressed_analog(di, binds[port], idx, id);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
{
|
||||
settings = config_get_ptr();
|
||||
|
@ -176,9 +176,6 @@ static int16_t gx_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(gx->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
#ifdef HW_RVL
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
|
@ -162,14 +162,9 @@ static int16_t linuxraw_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = linuxraw_analog_pressed(
|
||||
return linuxraw_analog_pressed(
|
||||
linuxraw, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(linuxraw->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -79,8 +79,6 @@ static int16_t ps2_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(ps2->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -135,9 +135,6 @@ static int16_t ps3_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(
|
||||
ps3->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
#if 0
|
||||
case RETRO_DEVICE_SENSOR_ACCELEROMETER:
|
||||
|
@ -85,8 +85,6 @@ static int16_t ps4_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(ps4->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -251,8 +251,6 @@ static int16_t ps3_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(ps3->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (psl1ght_keyboard_port_input_pressed(ps3, id));
|
||||
|
@ -328,8 +328,6 @@ static int16_t psp_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(psp->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
#ifdef VITA
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
|
@ -840,10 +840,7 @@ static int16_t qnx_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(qnx->joypad, joypad_info,
|
||||
port, idx, id, binds[port]);
|
||||
return 0;
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return qnx_keyboard_pressed(qnx, id);
|
||||
case RETRO_DEVICE_POINTER:
|
||||
|
@ -566,16 +566,10 @@ static int16_t rwebinput_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = rwebinput_analog_pressed(
|
||||
return rwebinput_analog_pressed(
|
||||
rwebinput, joypad_info, binds[port],
|
||||
idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(
|
||||
rwebinput->joypad, joypad_info, port,
|
||||
idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return rwebinput_key_pressed(rwebinput, id);
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
|
@ -235,13 +235,7 @@ static int16_t sdl_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = sdl_analog_pressed(sdl, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(sdl->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return sdl_analog_pressed(sdl, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
if (config_get_ptr()->uints.input_mouse_index[ port ] == 0)
|
||||
|
@ -422,9 +422,6 @@ static int16_t switch_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(sw->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
#ifdef HAVE_LIBNX
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
|
@ -1049,13 +1049,8 @@ static int16_t udev_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = udev_analog_pressed(binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(udev->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return udev_analog_pressed(binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && udev_keyboard_pressed(udev, id);
|
||||
|
||||
|
@ -131,13 +131,7 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
&& uwp_keyboard_pressed(bind_plus->key))
|
||||
pressed_plus = 0x7fff;
|
||||
|
||||
pressed_keyboard = pressed_plus + pressed_minus;
|
||||
if (pressed_keyboard != 0)
|
||||
return pressed_keyboard;
|
||||
|
||||
/* Then, process the joypad bindings */
|
||||
return input_joypad_analog(uwp->joypad,
|
||||
joypad_info, port, idx, id, binds);
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t uwp_input_state(void *data,
|
||||
|
@ -334,13 +334,7 @@ static int16_t input_wl_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = input_wl_analog_pressed(wl, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(
|
||||
wl->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return input_wl_analog_pressed(wl, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return input_wl_state_kb(wl, binds, port, device, idx, id);
|
||||
|
@ -164,9 +164,6 @@ static int16_t wiiu_input_state(void *data,
|
||||
return 1;
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(wiiu->joypad,
|
||||
joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
case RETRO_DEVICE_POINTER:
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
|
@ -664,9 +664,6 @@ static int16_t winraw_input_state(void *d,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(wr->joypad, joypad_info,
|
||||
port, index, id, binds[port]);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id);
|
||||
|
@ -352,14 +352,8 @@ static int16_t x_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
{
|
||||
int16_t ret = x_pressed_analog(x11, binds[port], idx, id);
|
||||
if (!ret)
|
||||
ret = input_joypad_analog(x11->joypad, joypad_info,
|
||||
port, idx,
|
||||
id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return x_pressed_analog(x11, binds[port], idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return (id < RETROK_LAST) && x_keyboard_pressed(x11, id);
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
|
@ -92,8 +92,6 @@ static int16_t xdk_input_state(void *data,
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(xdk->joypad, joypad_info, port, index, id, binds[port]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -312,31 +312,6 @@ const input_device_driver_t *input_joypad_init_driver(
|
||||
break; \
|
||||
}
|
||||
|
||||
/**
|
||||
* input_joypad_analog:
|
||||
* @drv : Input device driver handle.
|
||||
* @port : User number.
|
||||
* @idx : Analog key index.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_LEFT
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_RIGHT
|
||||
* - RETRO_DEVICE_INDEX_ANALOG_BUTTON
|
||||
* @ident : Analog key identifier.
|
||||
* E.g.:
|
||||
* - RETRO_DEVICE_ID_ANALOG_X
|
||||
* - RETRO_DEVICE_ID_ANALOG_Y
|
||||
* @binds : Binds of user.
|
||||
*
|
||||
* Gets analog value of analog key identifiers @idx and @ident
|
||||
* from user with number @port with provided keybinds (@binds).
|
||||
*
|
||||
* Returns: analog value on success, otherwise 0.
|
||||
**/
|
||||
int16_t input_joypad_analog(const input_device_driver_t *driver,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned port, unsigned idx, unsigned ident,
|
||||
const struct retro_keybind *binds);
|
||||
|
||||
/**
|
||||
* input_joypad_set_rumble:
|
||||
* @drv : Input device driver handle.
|
||||
|
25
retroarch.c
25
retroarch.c
@ -2758,6 +2758,10 @@ static void driver_location_stop(void);
|
||||
static bool driver_location_start(void);
|
||||
static void driver_camera_stop(void);
|
||||
static bool driver_camera_start(void);
|
||||
static int16_t input_joypad_analog(const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned port, unsigned idx, unsigned ident,
|
||||
const struct retro_keybind *binds);
|
||||
|
||||
#ifdef HAVE_ACCESSIBILITY
|
||||
static bool is_accessibility_enabled(struct rarch_state *p_rarch);
|
||||
@ -23248,6 +23252,25 @@ static int16_t input_state(unsigned port, unsigned device,
|
||||
p_rarch->current_input_data, &joypad_info,
|
||||
p_rarch->libretro_input_binds, port, device, idx, id);
|
||||
|
||||
if ( (device == RETRO_DEVICE_ANALOG) &&
|
||||
(ret == 0))
|
||||
{
|
||||
const input_device_driver_t *joypad =
|
||||
p_rarch->current_input->get_joypad_driver(
|
||||
p_rarch->current_input_data);
|
||||
const input_device_driver_t *sec_joypad =
|
||||
input_driver_get_sec_joypad_driver();
|
||||
if (p_rarch->libretro_input_binds[port])
|
||||
{
|
||||
if (sec_joypad)
|
||||
ret = input_joypad_analog(sec_joypad, &joypad_info,
|
||||
port, idx, id, p_rarch->libretro_input_binds[port]);
|
||||
if (joypad && (ret == 0))
|
||||
ret = input_joypad_analog(joypad, &joypad_info,
|
||||
port, idx, id, p_rarch->libretro_input_binds[port]);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (p_rarch->input_driver_flushing_input == 0)
|
||||
&& !p_rarch->input_driver_block_libretro_input)
|
||||
{
|
||||
@ -25313,7 +25336,7 @@ int16_t button_is_pressed(
|
||||
*
|
||||
* Returns: analog value on success, otherwise 0.
|
||||
**/
|
||||
int16_t input_joypad_analog(const input_device_driver_t *drv,
|
||||
static int16_t input_joypad_analog(const input_device_driver_t *drv,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
unsigned port, unsigned idx, unsigned ident,
|
||||
const struct retro_keybind *binds)
|
||||
|
Loading…
x
Reference in New Issue
Block a user