mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
(SDL input) Build fix - and further cleanups in other
drivers
This commit is contained in:
parent
1979b42834
commit
6ddbf911e3
@ -1418,6 +1418,32 @@ bool android_run_events(void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool android_is_pressed(
|
||||||
|
android_input_t *android,
|
||||||
|
settings_t *settings,
|
||||||
|
rarch_joypad_info_t *joypad_info,
|
||||||
|
const struct retro_keybind *binds,
|
||||||
|
unsigned port, unsigned id)
|
||||||
|
{
|
||||||
|
const struct retro_keybind *bind = &binds[id];
|
||||||
|
/* Auto-binds are per joypad, not per user. */
|
||||||
|
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||||
|
? binds[id].joykey : joypad_info->auto_binds[i].joykey;
|
||||||
|
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||||
|
? binds[id].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||||
|
|
||||||
|
if ((uint16_t)joykey != NO_BTN
|
||||||
|
&& android->joypad->button(
|
||||||
|
joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (((float)abs(android->joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||||
|
/ 0x8000) > joypad_info->axis_threshold)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int16_t android_input_state(void *data,
|
static int16_t android_input_state(void *data,
|
||||||
rarch_joypad_info_t *joypad_info,
|
rarch_joypad_info_t *joypad_info,
|
||||||
const struct retro_keybind **binds, unsigned port, unsigned device,
|
const struct retro_keybind **binds, unsigned port, unsigned device,
|
||||||
@ -1439,37 +1465,24 @@ static int16_t android_input_state(void *data,
|
|||||||
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
|
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
|
||||||
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
|
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
|
||||||
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||||
if ((uint16_t)joykey != NO_BTN && android->joypad->button(
|
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
if (
|
||||||
{
|
android_keyboard_port_input_pressed(binds[port], i)
|
||||||
ret |= (1 << i);
|
|| android_is_pressed(
|
||||||
continue;
|
android, settings, joypad_info, binds[port],
|
||||||
}
|
port, i)
|
||||||
if (((float)abs(android->joypad->axis(
|
)
|
||||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (android_keyboard_port_input_pressed(binds[port], i))
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Auto-binds are per joypad, not per user. */
|
if (
|
||||||
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
|
android_keyboard_port_input_pressed(binds[port], id)
|
||||||
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
|
|| android_is_pressed(
|
||||||
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
|
android, settings, joypad_info, binds[port],
|
||||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
port, id))
|
||||||
if ((uint16_t)joykey != NO_BTN && android->joypad->button(
|
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
|
||||||
return 1;
|
|
||||||
if (((float)abs(android->joypad->axis(
|
|
||||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
|
||||||
return 1;
|
|
||||||
if (android_keyboard_port_input_pressed(binds[port], id))
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -545,8 +545,8 @@ static bool dinput_is_pressed(
|
|||||||
{
|
{
|
||||||
const struct retro_keybind *bind = &binds[id];
|
const struct retro_keybind *bind = &binds[id];
|
||||||
/* Auto-binds are per joypad, not per user. */
|
/* Auto-binds are per joypad, not per user. */
|
||||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||||
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
|
||||||
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
|
||||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||||
|
|
||||||
@ -560,7 +560,8 @@ static bool dinput_is_pressed(
|
|||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||||
|
/ 0x8000) > joypad_info->axis_threshold)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -594,10 +595,7 @@ static int16_t dinput_input_state(void *data,
|
|||||||
if (binds[port][i].valid)
|
if (binds[port][i].valid)
|
||||||
if (dinput_is_pressed(
|
if (dinput_is_pressed(
|
||||||
di, settings, joypad_info, binds[port], port, i))
|
di, settings, joypad_info, binds[port], port, i))
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -89,10 +89,10 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind *
|
|||||||
return pressed_plus + pressed_minus;
|
return pressed_plus + pressed_minus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t sdl_joypad_device_state(sdl_input_t *sdl,
|
static bool sdl_is_pressed(sdl_input_t *sdl,
|
||||||
rarch_joypad_info_t *joypad_info,
|
rarch_joypad_info_t *joypad_info,
|
||||||
const struct retro_keybind *binds,
|
const struct retro_keybind *binds,
|
||||||
unsigned port, unsigned id, enum input_device_type *device)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
/* Auto-binds are per joypad, not per user. */
|
/* Auto-binds are per joypad, not per user. */
|
||||||
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
const uint64_t joykey = (binds[id].joykey != NO_BTN)
|
||||||
@ -101,26 +101,17 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl,
|
|||||||
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||||
|
|
||||||
if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key))
|
if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key))
|
||||||
{
|
return true;
|
||||||
*device = INPUT_DEVICE_TYPE_KEYBOARD;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((uint16_t)joykey != NO_BTN && sdl->joypad->button(
|
if ((uint16_t)joykey != NO_BTN && sdl->joypad->button(
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
{
|
return true;
|
||||||
*device = INPUT_DEVICE_TYPE_JOYPAD;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((float)abs(sdl->joypad->axis(joypad_info->joy_idx, joyaxis))
|
if (((float)abs(sdl->joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||||
/ 0x8000) > joypad_info->axis_threshold)
|
/ 0x8000) > joypad_info->axis_threshold)
|
||||||
{
|
return true;
|
||||||
*device = INPUT_DEVICE_TYPE_JOYPAD;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id)
|
static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id)
|
||||||
@ -154,6 +145,7 @@ static int16_t sdl_pointer_device_state(sdl_input_t *sdl,
|
|||||||
unsigned idx, unsigned id, bool screen)
|
unsigned idx, unsigned id, bool screen)
|
||||||
{
|
{
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
|
const int edge_detect = 32700;
|
||||||
bool inside = false;
|
bool inside = false;
|
||||||
int16_t res_x = 0;
|
int16_t res_x = 0;
|
||||||
int16_t res_y = 0;
|
int16_t res_y = 0;
|
||||||
@ -226,7 +218,6 @@ static int16_t sdl_input_state(void *data,
|
|||||||
const struct retro_keybind **binds,
|
const struct retro_keybind **binds,
|
||||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
enum input_device_type type = INPUT_DEVICE_TYPE_NONE;
|
|
||||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
@ -239,12 +230,9 @@ static int16_t sdl_input_state(void *data,
|
|||||||
|
|
||||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
{
|
{
|
||||||
if (sdl_joypad_device_state(
|
if (sdl_is_pressed(
|
||||||
sdl, joypad_info, binds[port], port, i, &type))
|
sdl, joypad_info, binds[port], port, i))
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -252,8 +240,8 @@ static int16_t sdl_input_state(void *data,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (id < RARCH_BIND_LIST_END)
|
if (id < RARCH_BIND_LIST_END)
|
||||||
if (sdl_joypad_device_state(sdl,
|
if (sdl_is_pressed(sdl,
|
||||||
joypad_info, binds[port], port, id, &type))
|
joypad_info, binds[port], port, id))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1025,10 +1025,7 @@ static int16_t udev_input_state(void *data,
|
|||||||
{
|
{
|
||||||
if (udev_is_pressed(
|
if (udev_is_pressed(
|
||||||
udev, joypad_info, binds[port], port, i))
|
udev, joypad_info, binds[port], port, i))
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -660,10 +660,7 @@ static int16_t winraw_input_state(void *d,
|
|||||||
if (binds[port][i].valid)
|
if (binds[port][i].valid)
|
||||||
if (winraw_is_pressed(
|
if (winraw_is_pressed(
|
||||||
wr, mouse, joypad_info, binds[port], port, i))
|
wr, mouse, joypad_info, binds[port], port, i))
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -676,10 +673,7 @@ static int16_t winraw_input_state(void *d,
|
|||||||
if (binds[port][i].valid)
|
if (binds[port][i].valid)
|
||||||
if (winraw_is_pressed(
|
if (winraw_is_pressed(
|
||||||
wr, mouse, joypad_info, binds[port], port, i))
|
wr, mouse, joypad_info, binds[port], port, i))
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user