mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(input drivers) Cleanups
This commit is contained in:
parent
05e3a1d7e5
commit
a7a03984f1
@ -1512,12 +1512,12 @@ static int16_t android_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN && android->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(android->joypad->axis(
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
if (android_keyboard_port_input_pressed(binds[port], id))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -352,17 +352,17 @@ static int16_t cocoa_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
|
||||
return true;
|
||||
return 1;
|
||||
if ((uint16_t)joykey != NO_BTN && apple->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(apple->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
if ((uint16_t)joykey != NO_BTN && apple->sec_joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(apple->sec_joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -95,9 +95,9 @@ static int16_t ctr_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && ctr->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(ctr->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -617,7 +617,7 @@ static int16_t dinput_input_state(void *data,
|
||||
{
|
||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] & 0x80)
|
||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
@ -628,12 +628,12 @@ static int16_t dinput_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
|
||||
if (dinput_mouse_button_pressed(di, port, binds[port][id].mbutton))
|
||||
return true;
|
||||
return 1;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& di->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -649,7 +649,7 @@ static int16_t dinput_input_state(void *data,
|
||||
port, idx, id, binds[port]);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
return dinput_mouse_state(di, port, id);
|
||||
@ -729,7 +729,7 @@ static int16_t dinput_input_state(void *data,
|
||||
{
|
||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][new_id].key]] & 0x80)
|
||||
if ((new_id == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
@ -740,12 +740,13 @@ static int16_t dinput_input_state(void *data,
|
||||
? binds[port][new_id].joyaxis : joypad_info->auto_binds[new_id].joyaxis;
|
||||
|
||||
if (dinput_mouse_button_pressed(di, port, binds[port][new_id].mbutton))
|
||||
return true;
|
||||
return 1;
|
||||
if ((uint16_t)joykey != NO_BTN
|
||||
&& di->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
&& di->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return 1;
|
||||
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -124,13 +124,13 @@ static int16_t dos_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && dos->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(dos->joypad->axis(
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
|
||||
if (dos_keyboard_port_input_pressed(binds[port], id))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
|
@ -186,9 +186,9 @@ static int16_t gx_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && gx->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(gx->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -163,12 +163,12 @@ static int16_t linuxraw_input_state(void *data,
|
||||
if (((id < RARCH_BIND_LIST_END) && binds[port]->valid &&
|
||||
linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]]
|
||||
))
|
||||
return true;
|
||||
return 1;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && linuxraw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(linuxraw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -71,7 +71,8 @@ static int16_t ps2_input_state(void *data,
|
||||
continue;
|
||||
}
|
||||
if (((float)abs(ps2->joypad->axis(
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000)
|
||||
> joypad_info->axis_threshold)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
@ -90,9 +91,9 @@ static int16_t ps2_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && ps2->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(ps2->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -127,7 +127,8 @@ static int16_t ps3_input_state(void *data,
|
||||
continue;
|
||||
}
|
||||
else if (((float)abs(ps3->joypad->axis(
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
joypad_info->joy_idx, joyaxis)) / 0x8000)
|
||||
> joypad_info->axis_threshold)
|
||||
{
|
||||
ret |= (1 << i);
|
||||
continue;
|
||||
@ -146,9 +147,9 @@ static int16_t ps3_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(ps3->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -93,9 +93,9 @@ static int16_t ps4_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && ps4->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(ps4->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -162,11 +162,7 @@ static void ps3_input_poll(void *data)
|
||||
|
||||
#ifdef HAVE_MOUSE
|
||||
static int16_t ps3_mouse_device_state(ps3_input_t *ps3,
|
||||
unsigned user, unsigned id)
|
||||
{
|
||||
RARCH_LOG("alive " __FILE__ ":%d\n", __LINE__);
|
||||
}
|
||||
|
||||
unsigned user, unsigned id) { }
|
||||
#endif
|
||||
|
||||
static bool psl1ght_keyboard_port_input_pressed(ps3_input_t *ps3, unsigned id)
|
||||
@ -262,11 +258,11 @@ static int16_t ps3_input_state(void *data,
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && ps3->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(ps3->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][id].key))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -94,36 +94,39 @@ typedef struct psp_input
|
||||
|
||||
static void psp_input_poll(void *data)
|
||||
{
|
||||
#ifdef VITA
|
||||
unsigned int i = 0;
|
||||
int key_sym = 0;
|
||||
unsigned key_code = 0;
|
||||
uint8_t mod_code = 0;
|
||||
uint16_t mod = 0;
|
||||
uint8_t modifiers[2] = { 0, 0 };
|
||||
bool key_held = false;
|
||||
int numReports = 0;
|
||||
int mouse_velocity_x = 0;
|
||||
int mouse_velocity_y = 0;
|
||||
SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT];
|
||||
SceHidMouseReport m_reports[SCE_HID_MAX_REPORT];
|
||||
#endif
|
||||
psp_input_t *psp = (psp_input_t*)data;
|
||||
|
||||
if (psp && psp->joypad)
|
||||
psp->joypad->poll();
|
||||
|
||||
#ifdef VITA
|
||||
unsigned int i = 0;
|
||||
int key_sym = 0;
|
||||
unsigned key_code = 0;
|
||||
uint8_t mod_code = 0;
|
||||
uint16_t mod = 0;
|
||||
uint8_t modifiers[2] = { 0, 0 };
|
||||
bool key_held = false;
|
||||
int numReports = 0;
|
||||
int mouse_velocity_x = 0;
|
||||
int mouse_velocity_y = 0;
|
||||
SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT];
|
||||
SceHidMouseReport m_reports[SCE_HID_MAX_REPORT];
|
||||
|
||||
if (psp->keyboard_hid_handle > 0)
|
||||
{
|
||||
numReports = sceHidKeyboardRead(psp->keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
|
||||
numReports = sceHidKeyboardRead(
|
||||
psp->keyboard_hid_handle,
|
||||
(SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
|
||||
|
||||
if (numReports < 0) {
|
||||
if (numReports < 0)
|
||||
psp->keyboard_hid_handle = 0;
|
||||
}
|
||||
else if (numReports) {
|
||||
else if (numReports)
|
||||
{
|
||||
modifiers[0] = k_reports[numReports - 1].modifiers[0];
|
||||
modifiers[1] = k_reports[numReports - 1].modifiers[1];
|
||||
mod = 0;
|
||||
mod = 0;
|
||||
if (modifiers[0] & 0x11)
|
||||
mod |= RETROKMOD_CTRL;
|
||||
if (modifiers[0] & 0x22)
|
||||
@ -145,23 +148,21 @@ static void psp_input_poll(void *data)
|
||||
mod_code = modifier_lut[i][1];
|
||||
key_code = input_keymaps_translate_keysym_to_rk(key_sym);
|
||||
if (i < 8)
|
||||
{
|
||||
key_held = (modifiers[0] & mod_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
key_held = (modifiers[1] & mod_code);
|
||||
}
|
||||
|
||||
if (key_held && !(psp->keyboard_state[key_sym]))
|
||||
{
|
||||
psp->keyboard_state[key_sym] = true;
|
||||
input_keyboard_event(true, key_code, 0, mod, RETRO_DEVICE_KEYBOARD);
|
||||
input_keyboard_event(true, key_code, 0, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
else if (!key_held && (psp->keyboard_state[key_sym]))
|
||||
{
|
||||
psp->keyboard_state[key_sym] = false;
|
||||
input_keyboard_event(false, key_code, 0, mod, RETRO_DEVICE_KEYBOARD);
|
||||
input_keyboard_event(false, key_code, 0, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,14 +175,20 @@ static void psp_input_poll(void *data)
|
||||
if (psp->prev_keys[i])
|
||||
{
|
||||
psp->keyboard_state[psp->prev_keys[i]] = false;
|
||||
key_code = input_keymaps_translate_keysym_to_rk(psp->prev_keys[i]);
|
||||
input_keyboard_event(false, key_code, 0, mod, RETRO_DEVICE_KEYBOARD);
|
||||
key_code =
|
||||
input_keymaps_translate_keysym_to_rk(
|
||||
psp->prev_keys[i]);
|
||||
input_keyboard_event(false, key_code, 0, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
if (key_sym)
|
||||
{
|
||||
psp->keyboard_state[key_sym] = true;
|
||||
key_code = input_keymaps_translate_keysym_to_rk(key_sym);
|
||||
input_keyboard_event(true, key_code, 0, mod, RETRO_DEVICE_KEYBOARD);
|
||||
key_code =
|
||||
input_keymaps_translate_keysym_to_rk(
|
||||
key_sym);
|
||||
input_keyboard_event(true, key_code, 0, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
psp->prev_keys[i] = key_sym;
|
||||
}
|
||||
@ -191,7 +198,9 @@ static void psp_input_poll(void *data)
|
||||
|
||||
if (psp->mouse_hid_handle > 0)
|
||||
{
|
||||
numReports = sceHidMouseRead(psp->mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
|
||||
numReports = sceHidMouseRead(psp->mouse_hid_handle,
|
||||
(SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
|
||||
|
||||
if (numReports > 0)
|
||||
{
|
||||
for (i = 0; i <= numReports - 1; i++)
|
||||
@ -199,31 +208,19 @@ static void psp_input_poll(void *data)
|
||||
uint8_t buttons = m_reports[i].buttons;
|
||||
|
||||
if (buttons & 0x1)
|
||||
{
|
||||
psp->mouse_button_left = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
psp->mouse_button_left = false;
|
||||
}
|
||||
|
||||
if (buttons & 0x2)
|
||||
{
|
||||
psp->mouse_button_right = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
psp->mouse_button_right = false;
|
||||
}
|
||||
|
||||
if (buttons & 0x4)
|
||||
{
|
||||
psp->mouse_button_middle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
psp->mouse_button_middle = false;
|
||||
}
|
||||
|
||||
mouse_velocity_x += m_reports[i].rel_x;
|
||||
mouse_velocity_y += m_reports[i].rel_y;
|
||||
@ -235,27 +232,20 @@ static void psp_input_poll(void *data)
|
||||
psp->mouse_x += mouse_velocity_x;
|
||||
psp->mouse_y += mouse_velocity_y;
|
||||
if (psp->mouse_x < 0)
|
||||
{
|
||||
psp->mouse_x = 0;
|
||||
}
|
||||
else if (psp->mouse_x > MOUSE_MAX_X)
|
||||
{
|
||||
psp->mouse_x = MOUSE_MAX_X;
|
||||
}
|
||||
|
||||
if (psp->mouse_y < 0)
|
||||
{
|
||||
psp->mouse_y = 0;
|
||||
}
|
||||
else if (psp->mouse_y > MOUSE_MAX_Y)
|
||||
{
|
||||
psp->mouse_y = MOUSE_MAX_Y;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VITA
|
||||
static int16_t psp_input_mouse_state(psp_input_t *psp, unsigned id, bool screen)
|
||||
static int16_t psp_input_mouse_state(
|
||||
psp_input_t *psp, unsigned id, bool screen)
|
||||
{
|
||||
int val = 0;
|
||||
switch (id)
|
||||
@ -271,9 +261,7 @@ static int16_t psp_input_mouse_state(psp_input_t *psp, unsigned id, bool screen)
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
if (screen)
|
||||
{
|
||||
val = psp->mouse_x;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = psp->mouse_x_delta;
|
||||
@ -282,9 +270,7 @@ static int16_t psp_input_mouse_state(psp_input_t *psp, unsigned id, bool screen)
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||
if (screen)
|
||||
{
|
||||
val = psp->mouse_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = psp->mouse_y_delta;
|
||||
@ -349,9 +335,9 @@ static int16_t psp_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && psp->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(psp->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -100,7 +100,8 @@ typedef struct qnx_input
|
||||
|
||||
extern screen_context_t screen_ctx;
|
||||
|
||||
static void qnx_init_controller(qnx_input_t *qnx, qnx_input_device_t* controller)
|
||||
static void qnx_init_controller(
|
||||
qnx_input_t *qnx, qnx_input_device_t* controller)
|
||||
{
|
||||
if (!qnx)
|
||||
return;
|
||||
@ -716,7 +717,7 @@ static void qnx_input_poll(void *data)
|
||||
for (;;)
|
||||
{
|
||||
bps_event_t *event = NULL;
|
||||
int rc = bps_get_event(&event, 0);
|
||||
int rc = bps_get_event(&event, 0);
|
||||
|
||||
if(rc == BPS_SUCCESS)
|
||||
{
|
||||
@ -833,20 +834,20 @@ static int16_t qnx_input_state(void *data,
|
||||
}
|
||||
else
|
||||
if (qnx_is_pressed(qnx, joypad_info, binds[port], port, id))
|
||||
return true;
|
||||
return 1;
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
if (binds[port])
|
||||
return input_joypad_analog(qnx->joypad, joypad_info,
|
||||
port, idx, id, binds[port]);
|
||||
return 0;
|
||||
return 0;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return qnx_keyboard_pressed(qnx, id);
|
||||
case RETRO_DEVICE_POINTER:
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
return qnx_pointer_input_state(qnx, idx, id, device == RARCH_DEVICE_POINTER_SCREEN);
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -114,7 +114,8 @@ static int16_t sdl_joypad_device_state(sdl_input_t *sdl,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((float)abs(sdl->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
if (((float)abs(sdl->joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
{
|
||||
*device = INPUT_DEVICE_TYPE_JOYPAD;
|
||||
return 1;
|
||||
@ -167,8 +168,9 @@ static int16_t sdl_pointer_device_state(sdl_input_t *sdl,
|
||||
vp.full_width = 0;
|
||||
vp.full_height = 0;
|
||||
|
||||
if (!(video_driver_translate_coord_viewport_wrap(&vp, sdl->mouse_abs_x, sdl->mouse_abs_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
if (!(video_driver_translate_coord_viewport_wrap(
|
||||
&vp, sdl->mouse_abs_x, sdl->mouse_abs_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
return 0;
|
||||
|
||||
if (screen)
|
||||
@ -251,7 +253,7 @@ static int16_t sdl_input_state(void *data,
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (sdl_joypad_device_state(sdl,
|
||||
joypad_info, binds[port], port, id, &type))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
@ -366,15 +368,18 @@ static void sdl_input_poll(void *data)
|
||||
sdl_poll_mouse(sdl);
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_MOUSEWHEEL) > 0)
|
||||
while (SDL_PeepEvents(&event, 1,
|
||||
SDL_GETEVENT, SDL_KEYDOWN, SDL_MOUSEWHEEL) > 0)
|
||||
#else
|
||||
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYEVENTMASK) > 0)
|
||||
while (SDL_PeepEvents(&event, 1,
|
||||
SDL_GETEVENT, SDL_KEYEVENTMASK) > 0)
|
||||
#endif
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
|
||||
{
|
||||
uint16_t mod = 0;
|
||||
unsigned code = input_keymaps_translate_keysym_to_rk(event.key.keysym.sym);
|
||||
unsigned code = input_keymaps_translate_keysym_to_rk(
|
||||
event.key.keysym.sym);
|
||||
|
||||
if (event.key.keysym.mod & KMOD_SHIFT)
|
||||
mod |= RETROKMOD_SHIFT;
|
||||
|
@ -16,19 +16,24 @@
|
||||
#ifdef HAVE_LIBNX
|
||||
#include <switch.h>
|
||||
|
||||
#define MULTITOUCH_LIMIT 4 /* supports up to this many fingers at once */
|
||||
#define TOUCH_AXIS_MAX 0x7fff /* abstraction of pointer coords */
|
||||
#define SWITCH_NUM_SCANCODES 114 /* size of rarch_key_map_switch */
|
||||
#define SWITCH_MAX_SCANCODE 0xfb /* see https://switchbrew.github.io/libnx/hid_8h.html */
|
||||
/* Supports up to this many fingers at once */
|
||||
#define MULTITOUCH_LIMIT 4
|
||||
/* Abstraction of pointer coords */
|
||||
#define TOUCH_AXIS_MAX 0x7fff
|
||||
/* Size of rarch_key_map_switch */
|
||||
#define SWITCH_NUM_SCANCODES 114
|
||||
/* See https://switchbrew.github.io/libnx/hid_8h.html */
|
||||
#define SWITCH_MAX_SCANCODE 0xfb
|
||||
#define MOUSE_MAX_X 1920
|
||||
#define MOUSE_MAX_Y 1080
|
||||
|
||||
/* beginning of touch mouse defines and types */
|
||||
/* Beginning of touch mouse defines and types */
|
||||
#define TOUCH_MAX_X 1280
|
||||
#define TOUCH_MAX_Y 720
|
||||
#define TOUCH_MOUSE_BUTTON_LEFT 0
|
||||
#define TOUCH_MOUSE_BUTTON_RIGHT 1
|
||||
#define NO_TOUCH -1 /* finger id setting if finger is not touching the screen */
|
||||
/* Finger ID setting if finger is not touching the screen */
|
||||
#define NO_TOUCH -1
|
||||
|
||||
enum
|
||||
{
|
||||
@ -144,16 +149,16 @@ static void finish_simulated_mouse_clicks(switch_input_t *sw, uint64_t currentTi
|
||||
|
||||
static void switch_input_poll(void *data)
|
||||
{
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
#ifdef HAVE_LIBNX
|
||||
uint32_t touch_count;
|
||||
unsigned int i = 0;
|
||||
int keySym = 0;
|
||||
unsigned keyCode = 0;
|
||||
uint16_t mod = 0;
|
||||
MousePosition mouse_pos;
|
||||
uint32_t touch_count;
|
||||
unsigned int i = 0;
|
||||
int keySym = 0;
|
||||
unsigned keyCode = 0;
|
||||
uint16_t mod = 0;
|
||||
uint64_t mouse_current_report = 0;
|
||||
#endif
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
|
||||
if (sw->joypad)
|
||||
sw->joypad->poll();
|
||||
@ -163,7 +168,7 @@ static void switch_input_poll(void *data)
|
||||
for (i = 0; i < MULTITOUCH_LIMIT; i++)
|
||||
{
|
||||
sw->previous_touch_state[i] = sw->touch_state[i];
|
||||
sw->touch_state[i] = touch_count > i;
|
||||
sw->touch_state[i] = touch_count > i;
|
||||
|
||||
if (sw->touch_state[i])
|
||||
{
|
||||
@ -171,10 +176,10 @@ static void switch_input_poll(void *data)
|
||||
touchPosition touch_position;
|
||||
hidTouchRead(&touch_position, i);
|
||||
|
||||
sw->touch_previous_x[i] = sw->touch_x[i];
|
||||
sw->touch_previous_y[i] = sw->touch_y[i];
|
||||
sw->touch_x[i] = touch_position.px;
|
||||
sw->touch_y[i] = touch_position.py;
|
||||
sw->touch_previous_x[i] = sw->touch_x[i];
|
||||
sw->touch_previous_y[i] = sw->touch_y[i];
|
||||
sw->touch_x[i] = touch_position.px;
|
||||
sw->touch_y[i] = touch_position.py;
|
||||
|
||||
/* convert from event coordinates to core and screen coordinates */
|
||||
vp.x = 0;
|
||||
@ -223,7 +228,8 @@ static void switch_input_poll(void *data)
|
||||
/* update physical mouse buttons only when they change
|
||||
* this allows the physical mouse and touch mouse to coexist */
|
||||
mouse_current_report = hidMouseButtonsHeld();
|
||||
if ((mouse_current_report & MOUSE_LEFT) != (sw->mouse_previous_report & MOUSE_LEFT))
|
||||
if ((mouse_current_report & MOUSE_LEFT)
|
||||
!= (sw->mouse_previous_report & MOUSE_LEFT))
|
||||
{
|
||||
if (mouse_current_report & MOUSE_LEFT)
|
||||
sw->mouse_button_left = true;
|
||||
@ -231,7 +237,8 @@ static void switch_input_poll(void *data)
|
||||
sw->mouse_button_left = false;
|
||||
}
|
||||
|
||||
if ((mouse_current_report & MOUSE_RIGHT) != (sw->mouse_previous_report & MOUSE_RIGHT))
|
||||
if ((mouse_current_report & MOUSE_RIGHT)
|
||||
!= (sw->mouse_previous_report & MOUSE_RIGHT))
|
||||
{
|
||||
if (mouse_current_report & MOUSE_RIGHT)
|
||||
sw->mouse_button_right = true;
|
||||
@ -239,7 +246,8 @@ static void switch_input_poll(void *data)
|
||||
sw->mouse_button_right = false;
|
||||
}
|
||||
|
||||
if ((mouse_current_report & MOUSE_MIDDLE) != (sw->mouse_previous_report & MOUSE_MIDDLE))
|
||||
if ((mouse_current_report & MOUSE_MIDDLE)
|
||||
!= (sw->mouse_previous_report & MOUSE_MIDDLE))
|
||||
{
|
||||
if (mouse_current_report & MOUSE_MIDDLE)
|
||||
sw->mouse_button_middle = true;
|
||||
@ -298,7 +306,8 @@ static int16_t switch_pointer_screen_device_state(switch_input_t *sw,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t switch_pointer_device_state(switch_input_t *sw,
|
||||
static int16_t switch_pointer_device_state(
|
||||
switch_input_t *sw,
|
||||
unsigned id, unsigned idx)
|
||||
{
|
||||
if (idx >= MULTITOUCH_LIMIT)
|
||||
@ -317,7 +326,8 @@ static int16_t switch_pointer_device_state(switch_input_t *sw,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t switch_input_mouse_state(switch_input_t *sw, unsigned id, bool screen)
|
||||
static int16_t switch_input_mouse_state(
|
||||
switch_input_t *sw, unsigned id, bool screen)
|
||||
{
|
||||
int val = 0;
|
||||
switch (id)
|
||||
@ -417,9 +427,9 @@ static int16_t switch_input_state(void *data,
|
||||
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
if ((uint16_t)joykey != NO_BTN && sw->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(sw->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
@ -430,19 +440,14 @@ static int16_t switch_input_state(void *data,
|
||||
#ifdef HAVE_LIBNX
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return ((id < RETROK_LAST) && sw->keyboard_state[rarch_keysym_lut[(enum retro_key)id]]);
|
||||
break;
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
return switch_input_mouse_state(sw, id, false);
|
||||
break;
|
||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||
return switch_input_mouse_state(sw, id, true);
|
||||
break;
|
||||
case RETRO_DEVICE_POINTER:
|
||||
return switch_pointer_device_state(sw, id, idx);
|
||||
break;
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
return switch_pointer_screen_device_state(sw, id, idx);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -452,17 +457,17 @@ static int16_t switch_input_state(void *data,
|
||||
#ifdef HAVE_LIBNX
|
||||
void handle_touch_mouse(switch_input_t *sw)
|
||||
{
|
||||
int finger_id = 0;
|
||||
uint64_t current_time = svcGetSystemTick() * 1000 / 19200000;
|
||||
unsigned int i;
|
||||
int finger_id = 0;
|
||||
uint64_t current_time = svcGetSystemTick() * 1000 / 19200000;
|
||||
finish_simulated_mouse_clicks(sw, current_time);
|
||||
|
||||
for (i = 0; i < MULTITOUCH_LIMIT; i++)
|
||||
{
|
||||
if (sw->touch_state[i])
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
normalize_touch_mouse_xy(&x, &y, sw->touch_x[i], sw->touch_y[i]);
|
||||
finger_id = i;
|
||||
|
||||
@ -470,11 +475,11 @@ void handle_touch_mouse(switch_input_t *sw)
|
||||
if (!sw->previous_touch_state[i])
|
||||
{
|
||||
TouchEvent ev;
|
||||
ev.type = FINGERDOWN;
|
||||
ev.type = FINGERDOWN;
|
||||
ev.tfinger.timestamp = current_time;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
process_touch_mouse_event(sw, &ev);
|
||||
}
|
||||
else
|
||||
@ -483,47 +488,47 @@ void handle_touch_mouse(switch_input_t *sw)
|
||||
if (sw->touch_x[i] != sw->touch_previous_x[i] ||
|
||||
sw->touch_y[i] != sw->touch_previous_y[i])
|
||||
{
|
||||
TouchEvent ev;
|
||||
float oldx = 0;
|
||||
float oldy = 0;
|
||||
TouchEvent ev;
|
||||
normalize_touch_mouse_xy(&oldx, &oldy, sw->touch_previous_x[i], sw->touch_previous_y[i]);
|
||||
ev.type = FINGERMOTION;
|
||||
ev.type = FINGERMOTION;
|
||||
ev.tfinger.timestamp = current_time;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
ev.tfinger.dx = x - oldx;
|
||||
ev.tfinger.dy = y - oldy;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
ev.tfinger.dx = x - oldx;
|
||||
ev.tfinger.dy = y - oldy;
|
||||
process_touch_mouse_event(sw, &ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* some fingers might have been let go */
|
||||
if (sw->previous_touch_state[i] == true && sw->touch_state[i] == false)
|
||||
if (sw->previous_touch_state[i] && sw->touch_state[i] == false)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
TouchEvent ev;
|
||||
normalize_touch_mouse_xy(&x, &y, sw->touch_previous_x[i], sw->touch_previous_y[i]);
|
||||
finger_id = i;
|
||||
normalize_touch_mouse_xy(&x, &y,
|
||||
sw->touch_previous_x[i], sw->touch_previous_y[i]);
|
||||
finger_id = i;
|
||||
/* finger released from screen */
|
||||
ev.type = FINGERUP;
|
||||
ev.type = FINGERUP;
|
||||
ev.tfinger.timestamp = current_time;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
ev.tfinger.fingerId = finger_id;
|
||||
ev.tfinger.x = x;
|
||||
ev.tfinger.y = y;
|
||||
process_touch_mouse_event(sw, &ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void normalize_touch_mouse_xy(float *normalized_x, float *normalized_y, int reported_x, int reported_y)
|
||||
void normalize_touch_mouse_xy(float *normalized_x,
|
||||
float *normalized_y, int reported_x, int reported_y)
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
x = (float) reported_x / TOUCH_MAX_X;
|
||||
y = (float) reported_y / TOUCH_MAX_Y;
|
||||
float x = (float) reported_x / TOUCH_MAX_X;
|
||||
float y = (float) reported_y / TOUCH_MAX_Y;
|
||||
|
||||
if (x < 0.0)
|
||||
x = 0.0;
|
||||
@ -543,10 +548,13 @@ void process_touch_mouse_event(switch_input_t *sw, TouchEvent *event)
|
||||
/* supported touch gestures:
|
||||
* pointer motion = single finger drag
|
||||
* left mouse click = single finger short tap
|
||||
* right mouse click = second finger short tap while first finger is still down
|
||||
* right mouse click = second finger short tap
|
||||
* while first finger is still down
|
||||
* left click drag and drop = dual finger drag
|
||||
* right click drag and drop = triple finger drag */
|
||||
if (event->type == FINGERDOWN || event->type == FINGERUP || event->type == FINGERMOTION)
|
||||
if ( event->type == FINGERDOWN
|
||||
|| event->type == FINGERUP
|
||||
|| event->type == FINGERMOTION)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
@ -566,8 +574,8 @@ void process_touch_mouse_event(switch_input_t *sw, TouchEvent *event)
|
||||
void process_touch_mouse_finger_down(switch_input_t *sw, TouchEvent *event)
|
||||
{
|
||||
/* id (for multitouch) */
|
||||
int id = event->tfinger.fingerId;
|
||||
unsigned int i;
|
||||
int id = event->tfinger.fingerId;
|
||||
|
||||
/* make sure each finger is not reported down multiple times */
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
@ -576,17 +584,19 @@ void process_touch_mouse_finger_down(switch_input_t *sw, TouchEvent *event)
|
||||
sw->finger[i].id = NO_TOUCH;
|
||||
}
|
||||
|
||||
/* we need the timestamps to decide later if the user performed a short tap (click)
|
||||
/* we need the timestamps to decide later if the
|
||||
* user performed a short tap (click)
|
||||
* or a long tap (drag)
|
||||
* we also need the last coordinates for each finger to keep track of dragging */
|
||||
* we also need the last coordinates for each finger
|
||||
* to keep track of dragging */
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
{
|
||||
if (sw->finger[i].id == NO_TOUCH)
|
||||
{
|
||||
sw->finger[i].id = id;
|
||||
sw->finger[i].id = id;
|
||||
sw->finger[i].time_last_down = event->tfinger.timestamp;
|
||||
sw->finger[i].last_down_x = event->tfinger.x;
|
||||
sw->finger[i].last_down_y = event->tfinger.y;
|
||||
sw->finger[i].last_down_x = event->tfinger.x;
|
||||
sw->finger[i].last_down_y = event->tfinger.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -594,13 +604,12 @@ void process_touch_mouse_finger_down(switch_input_t *sw, TouchEvent *event)
|
||||
|
||||
void process_touch_mouse_finger_up(switch_input_t *sw, TouchEvent *event)
|
||||
{
|
||||
unsigned int i;
|
||||
/* id (for multitouch) */
|
||||
int id = event->tfinger.fingerId;
|
||||
int num_fingers_down;
|
||||
unsigned int i;
|
||||
|
||||
/* find out how many fingers were down before this event */
|
||||
num_fingers_down = 0;
|
||||
int num_fingers_down = 0;
|
||||
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
{
|
||||
if (sw->finger[i].id >= 0)
|
||||
@ -620,11 +629,14 @@ void process_touch_mouse_finger_up(switch_input_t *sw, TouchEvent *event)
|
||||
float max_r_squared;
|
||||
int simulated_button;
|
||||
|
||||
if ((event->tfinger.timestamp - sw->finger[i].time_last_down) > MAX_TAP_TIME)
|
||||
if ((event->tfinger.timestamp - sw->finger[i].time_last_down)
|
||||
> MAX_TAP_TIME)
|
||||
continue;
|
||||
|
||||
/* short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
|
||||
* but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels */
|
||||
/* short (<MAX_TAP_TIME ms) tap is interpreted as
|
||||
* right/left mouse click depending on # fingers already down
|
||||
* but only if the finger hasn't moved since it was
|
||||
* pressed down by more than MAX_TAP_MOTION_DISTANCE pixels */
|
||||
xrel = ((event->tfinger.x * TOUCH_MAX_X) - (sw->finger[i].last_down_x * TOUCH_MAX_X));
|
||||
yrel = ((event->tfinger.y * TOUCH_MAX_Y) - (sw->finger[i].last_down_y * TOUCH_MAX_Y));
|
||||
max_r_squared = (float) (MAX_TAP_MOTION_DISTANCE * MAX_TAP_MOTION_DISTANCE);
|
||||
@ -676,15 +688,14 @@ void process_touch_mouse_finger_up(switch_input_t *sw, TouchEvent *event)
|
||||
|
||||
void process_touch_mouse_finger_motion(switch_input_t *sw, TouchEvent *event)
|
||||
{
|
||||
/* id (for multitouch) */
|
||||
int id = event->tfinger.fingerId;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
int num_fingers_down;
|
||||
bool update_pointer;
|
||||
|
||||
/* id (for multitouch) */
|
||||
int id = event->tfinger.fingerId;
|
||||
/* find out how many fingers were down before this event */
|
||||
num_fingers_down = 0;
|
||||
int num_fingers_down = 0;
|
||||
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
{
|
||||
if (sw->finger[i].id >= 0)
|
||||
@ -694,16 +705,19 @@ void process_touch_mouse_finger_motion(switch_input_t *sw, TouchEvent *event)
|
||||
if (num_fingers_down == 0)
|
||||
return;
|
||||
|
||||
/* If we are starting a multi-finger drag, start holding down the mouse button */
|
||||
/* If we are starting a multi-finger drag,
|
||||
* start holding down the mouse button */
|
||||
if (num_fingers_down >= 2 && !sw->multi_finger_dragging)
|
||||
{
|
||||
/* only start a multi-finger drag if at least two fingers have been down long enough */
|
||||
/* only start a multi-finger drag if at least
|
||||
* two fingers have been down long enough */
|
||||
int num_fingers_down_long = 0;
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
{
|
||||
if (sw->finger[i].id == NO_TOUCH)
|
||||
continue;
|
||||
if (event->tfinger.timestamp - sw->finger[i].time_last_down > MAX_TAP_TIME)
|
||||
if (event->tfinger.timestamp - sw->finger[i].time_last_down
|
||||
> MAX_TAP_TIME)
|
||||
num_fingers_down_long++;
|
||||
}
|
||||
if (num_fingers_down_long >= 2)
|
||||
@ -711,19 +725,19 @@ void process_touch_mouse_finger_motion(switch_input_t *sw, TouchEvent *event)
|
||||
int simulated_button = 0;
|
||||
if (num_fingers_down_long == 2)
|
||||
{
|
||||
simulated_button = TOUCH_MOUSE_BUTTON_LEFT;
|
||||
simulated_button = TOUCH_MOUSE_BUTTON_LEFT;
|
||||
sw->multi_finger_dragging = DRAG_TWO_FINGER;
|
||||
}
|
||||
else
|
||||
{
|
||||
simulated_button = TOUCH_MOUSE_BUTTON_RIGHT;
|
||||
simulated_button = TOUCH_MOUSE_BUTTON_RIGHT;
|
||||
sw->multi_finger_dragging = DRAG_THREE_FINGER;
|
||||
}
|
||||
|
||||
if (simulated_button == TOUCH_MOUSE_BUTTON_LEFT)
|
||||
sw->mouse_button_left = true;
|
||||
sw->mouse_button_left = true;
|
||||
else if (simulated_button == TOUCH_MOUSE_BUTTON_RIGHT)
|
||||
sw->mouse_button_right = true;
|
||||
sw->mouse_button_right = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -755,38 +769,42 @@ void process_touch_mouse_finger_motion(switch_input_t *sw, TouchEvent *event)
|
||||
normalized_to_screen_xy(&x, &y, event->tfinger.x, event->tfinger.y);
|
||||
sw->mouse_x_delta = x - sw->mouse_x;
|
||||
sw->mouse_y_delta = y - sw->mouse_y;
|
||||
sw->mouse_x = x;
|
||||
sw->mouse_y = y;
|
||||
sw->mouse_x = x;
|
||||
sw->mouse_y = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* for relative mode, use the pointer speed setting */
|
||||
int dx = event->tfinger.dx * TOUCH_MAX_X * 256 * sw->touch_mouse_speed_factor;
|
||||
int dy = event->tfinger.dy * TOUCH_MAX_Y * 256 * sw->touch_mouse_speed_factor;
|
||||
int dx = event->tfinger.dx * TOUCH_MAX_X * 256 *
|
||||
sw->touch_mouse_speed_factor;
|
||||
int dy = event->tfinger.dy * TOUCH_MAX_Y * 256 *
|
||||
sw->touch_mouse_speed_factor;
|
||||
sw->hires_dx += dx;
|
||||
sw->hires_dy += dy;
|
||||
int x_rel = sw->hires_dx / 256;
|
||||
int y_rel = sw->hires_dy / 256;
|
||||
int x_rel = sw->hires_dx / 256;
|
||||
int y_rel = sw->hires_dy / 256;
|
||||
if (x_rel || y_rel)
|
||||
{
|
||||
sw->mouse_x_delta = x_rel;
|
||||
sw->mouse_y_delta = y_rel;
|
||||
sw->mouse_x += x_rel;
|
||||
sw->mouse_y += y_rel;
|
||||
sw->mouse_x_delta = x_rel;
|
||||
sw->mouse_y_delta = y_rel;
|
||||
sw->mouse_x += x_rel;
|
||||
sw->mouse_y += y_rel;
|
||||
}
|
||||
sw->hires_dx %= 256;
|
||||
sw->hires_dy %= 256;
|
||||
sw->hires_dx %= 256;
|
||||
sw->hires_dy %= 256;
|
||||
}
|
||||
}
|
||||
|
||||
void normalized_to_screen_xy(int *screenX, int *screenY, float x, float y)
|
||||
static void normalized_to_screen_xy(
|
||||
int *screenX, int *screenY, float x, float y)
|
||||
{
|
||||
/* map to display */
|
||||
*screenX = x * TOUCH_MAX_X;
|
||||
*screenY = y * TOUCH_MAX_Y;
|
||||
}
|
||||
|
||||
void finish_simulated_mouse_clicks(switch_input_t *sw, uint64_t currentTime)
|
||||
static void finish_simulated_mouse_clicks(
|
||||
switch_input_t *sw, uint64_t currentTime)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < 2; i++)
|
||||
@ -794,7 +812,8 @@ void finish_simulated_mouse_clicks(switch_input_t *sw, uint64_t currentTime)
|
||||
if (sw->simulated_click_start_time[i] == 0)
|
||||
continue;
|
||||
|
||||
if (currentTime - sw->simulated_click_start_time[i] < SIMULATED_CLICK_DURATION)
|
||||
if (currentTime - sw->simulated_click_start_time[i]
|
||||
< SIMULATED_CLICK_DURATION)
|
||||
continue;
|
||||
|
||||
if (i == 0)
|
||||
@ -851,14 +870,15 @@ static void* switch_input_init(const char *joypad_driver)
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_switch);
|
||||
unsigned int i;
|
||||
for (i = 0; i <= SWITCH_MAX_SCANCODE; i++)
|
||||
sw->keyboard_state[i] = false;
|
||||
sw->keyboard_state[i] = false;
|
||||
|
||||
sw->mouse_x = 0;
|
||||
sw->mouse_y = 0;
|
||||
sw->mouse_previous_report = 0;
|
||||
sw->mouse_x = 0;
|
||||
sw->mouse_y = 0;
|
||||
sw->mouse_previous_report = 0;
|
||||
|
||||
/* touch mouse init */
|
||||
sw->touch_mouse_indirect = true; /* direct mode is not calibrated it seems */
|
||||
sw->touch_mouse_indirect = true;
|
||||
/* direct mode is not calibrated it seems */
|
||||
sw->touch_mouse_speed_factor = 1.0;
|
||||
for (i = 0; i < MAX_NUM_FINGERS; i++)
|
||||
sw->finger[i].id = NO_TOUCH;
|
||||
@ -869,7 +889,7 @@ static void* switch_input_init(const char *joypad_driver)
|
||||
sw->simulated_click_start_time[i] = 0;
|
||||
|
||||
for(i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
sw->sixaxis_handles_count[i] = 0;
|
||||
sw->sixaxis_handles_count[i] = 0;
|
||||
#endif
|
||||
|
||||
return sw;
|
||||
|
@ -806,17 +806,18 @@ static bool udev_pointer_is_off_window(const udev_input_t *udev)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int16_t udev_lightgun_aiming_state(udev_input_t *udev, unsigned port, unsigned id )
|
||||
static int16_t udev_lightgun_aiming_state(
|
||||
udev_input_t *udev, unsigned port, unsigned id )
|
||||
{
|
||||
const int edge_detect = 32700;
|
||||
struct video_viewport vp;
|
||||
const int edge_detect = 32700;
|
||||
bool inside = false;
|
||||
int16_t res_x = 0;
|
||||
int16_t res_y = 0;
|
||||
int16_t res_screen_x = 0;
|
||||
int16_t res_screen_y = 0;
|
||||
|
||||
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
||||
udev_input_mouse_t *mouse = udev_get_mouse(udev, port);
|
||||
|
||||
vp.x = 0;
|
||||
vp.y = 0;
|
||||
@ -828,22 +829,30 @@ static int16_t udev_lightgun_aiming_state(udev_input_t *udev, unsigned port, uns
|
||||
if (!mouse)
|
||||
return 0;
|
||||
|
||||
if (!(video_driver_translate_coord_viewport_wrap(&vp, udev->pointer_x, udev->pointer_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
if (!(video_driver_translate_coord_viewport_wrap(
|
||||
&vp, udev->pointer_x, udev->pointer_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
return 0;
|
||||
|
||||
inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect);
|
||||
inside = (res_x >= -edge_detect)
|
||||
&& (res_y >= -edge_detect)
|
||||
&& (res_x <= edge_detect)
|
||||
&& (res_y <= edge_detect);
|
||||
|
||||
switch ( id )
|
||||
{
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||
return inside ? res_x : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||
return inside ? res_y : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||
return !inside;
|
||||
default:
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||
if (inside)
|
||||
return res_x;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||
if (inside)
|
||||
return res_y;
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||
return !inside;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -953,7 +962,8 @@ static bool udev_is_pressed(udev_input_t *udev,
|
||||
if ((uint16_t)joykey != NO_BTN && udev->joypad->button(
|
||||
joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
if (((float)abs(udev->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
if (((float)abs(udev->joypad->axis(joypad_info->joy_idx, joyaxis))
|
||||
/ 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1033,7 +1043,7 @@ static int16_t udev_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (udev_is_pressed(udev, joypad_info, binds[port], port, id))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
@ -1072,27 +1082,38 @@ static int16_t udev_input_state(void *data,
|
||||
|
||||
/*buttons*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_TRIGGER);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_RELOAD);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_AUX_A);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_AUX_B);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_AUX_C);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_START);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_SELECT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_DPAD_UP);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||
|
||||
/*deprecated*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
@ -1106,8 +1127,8 @@ static int16_t udev_input_state(void *data,
|
||||
return (mouse) ? udev_mouse_get_y(mouse) : 0;
|
||||
}
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||
return udev_is_pressed(udev, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
||||
|
||||
return udev_is_pressed(udev, joypad_info,
|
||||
binds[port], port, RARCH_LIGHTGUN_START);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -157,9 +157,11 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
if (!bind_minus->valid || !bind_plus->valid)
|
||||
return 0;
|
||||
|
||||
if ((bind_minus->key < RETROK_LAST) && uwp_keyboard_pressed(bind_minus->key))
|
||||
if ((bind_minus->key < RETROK_LAST)
|
||||
&& uwp_keyboard_pressed(bind_minus->key))
|
||||
pressed_minus = -0x7fff;
|
||||
if ((bind_plus->key < RETROK_LAST) && uwp_keyboard_pressed(bind_plus->key))
|
||||
if ((bind_plus->key < RETROK_LAST)
|
||||
&& uwp_keyboard_pressed(bind_plus->key))
|
||||
pressed_plus = 0x7fff;
|
||||
|
||||
pressed_keyboard = pressed_plus + pressed_minus;
|
||||
@ -167,7 +169,8 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
return pressed_keyboard;
|
||||
|
||||
/* Then, process the joypad bindings */
|
||||
return input_joypad_analog(uwp->joypad, joypad_info, port, idx, id, binds);
|
||||
return input_joypad_analog(uwp->joypad,
|
||||
joypad_info, port, idx, id, binds);
|
||||
}
|
||||
|
||||
static int16_t uwp_input_state(void *data,
|
||||
@ -201,7 +204,7 @@ static int16_t uwp_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (uwp_pressed_joypad(uwp, joypad_info, binds[port], port, id))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -53,7 +53,8 @@
|
||||
|
||||
void flush_wayland_fd(void *data);
|
||||
|
||||
static int16_t input_wl_mouse_state(input_ctx_wayland_data_t *wl, unsigned id, bool screen)
|
||||
static int16_t input_wl_mouse_state(
|
||||
input_ctx_wayland_data_t *wl, unsigned id, bool screen)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@ -74,7 +75,8 @@ static int16_t input_wl_mouse_state(input_ctx_wayland_data_t *wl, unsigned id, b
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t input_wl_lightgun_state(input_ctx_wayland_data_t *wl, unsigned id)
|
||||
static int16_t input_wl_lightgun_state(
|
||||
input_ctx_wayland_data_t *wl, unsigned id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@ -333,15 +335,16 @@ static int16_t input_wl_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][id].key]))
|
||||
return true;
|
||||
if (BIT_GET(wl->key_state,
|
||||
rarch_keysym_lut[binds[port][id].key]))
|
||||
return 1;
|
||||
|
||||
if (binds[port])
|
||||
{
|
||||
if ((uint16_t)joykey != NO_BTN && wl->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(wl->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -358,7 +361,6 @@ static int16_t input_wl_state(void *data,
|
||||
return input_wl_mouse_state(wl, id, false);
|
||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||
return input_wl_mouse_state(wl, id, true);
|
||||
|
||||
case RETRO_DEVICE_POINTER:
|
||||
if (idx == 0)
|
||||
return input_wl_pointer_state(wl, idx, id,
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
static uint8_t keyboardChannel = 0x00;
|
||||
static uint8_t keyboardChannel = 0x00;
|
||||
static bool keyboardState[RETROK_LAST] = { 0 };
|
||||
|
||||
typedef struct wiiu_input
|
||||
@ -43,26 +43,26 @@ typedef struct wiiu_input
|
||||
const input_device_driver_t *joypad;
|
||||
} wiiu_input_t;
|
||||
|
||||
void kb_connection_callback(KBDKeyEvent *key)
|
||||
static void kb_connection_callback(KBDKeyEvent *key)
|
||||
{
|
||||
keyboardChannel = keyboardChannel + (key->channel + 0x01);
|
||||
}
|
||||
|
||||
void kb_disconnection_callback(KBDKeyEvent *key)
|
||||
static void kb_disconnection_callback(KBDKeyEvent *key)
|
||||
{
|
||||
keyboardChannel = keyboardChannel - (key->channel + 0x01);
|
||||
}
|
||||
|
||||
void kb_key_callback(KBDKeyEvent *key)
|
||||
static void kb_key_callback(KBDKeyEvent *key)
|
||||
{
|
||||
uint16_t mod = 0;
|
||||
unsigned code = 0;
|
||||
bool pressed = false;
|
||||
uint16_t mod = 0;
|
||||
unsigned code = 0;
|
||||
bool pressed = false;
|
||||
|
||||
if (key->state > 0)
|
||||
pressed = true;
|
||||
|
||||
code = input_keymaps_translate_keysym_to_rk(key->scancode);
|
||||
code = input_keymaps_translate_keysym_to_rk(key->scancode);
|
||||
if (code < RETROK_LAST)
|
||||
keyboardState[code] = pressed;
|
||||
|
||||
@ -115,11 +115,9 @@ static void wiiu_input_poll(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (!wiiu)
|
||||
return;
|
||||
|
||||
if (wiiu->joypad)
|
||||
wiiu->joypad->poll();
|
||||
if (wiiu)
|
||||
if (wiiu->joypad)
|
||||
wiiu->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t wiiu_input_state(void *data,
|
||||
@ -172,15 +170,15 @@ static int16_t wiiu_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && wiiu->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(wiiu->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
if (id < RETROK_LAST && keyboardState[id] && (keyboardChannel > 0))
|
||||
return true;
|
||||
return false;
|
||||
return 1;
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(wiiu->joypad,
|
||||
|
@ -143,7 +143,6 @@ static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt)
|
||||
name, &name_size);
|
||||
if (r == (UINT)-1 || r == 0)
|
||||
name[0] = '\0';
|
||||
RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,15 +679,15 @@ static void winraw_poll(void *d)
|
||||
|
||||
for (i = 0; i < g_mouse_cnt; ++i)
|
||||
{
|
||||
wr->mice[i].x = g_mice[i].x;
|
||||
wr->mice[i].y = g_mice[i].y;
|
||||
wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0);
|
||||
wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0);
|
||||
wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0);
|
||||
wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0);
|
||||
wr->mice[i].btn_l = g_mice[i].btn_l;
|
||||
wr->mice[i].btn_m = g_mice[i].btn_m;
|
||||
wr->mice[i].btn_r = g_mice[i].btn_r;
|
||||
wr->mice[i].x = g_mice[i].x;
|
||||
wr->mice[i].y = g_mice[i].y;
|
||||
wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0);
|
||||
wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0);
|
||||
wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0);
|
||||
wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0);
|
||||
wr->mice[i].btn_l = g_mice[i].btn_l;
|
||||
wr->mice[i].btn_m = g_mice[i].btn_m;
|
||||
wr->mice[i].btn_r = g_mice[i].btn_r;
|
||||
wr->mice[i].btn_b4 = g_mice[i].btn_b4;
|
||||
wr->mice[i].btn_b5 = g_mice[i].btn_b5;
|
||||
}
|
||||
|
@ -92,23 +92,23 @@ static bool x_mouse_button_pressed(
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
return x11->mouse_l;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
return x11->mouse_r;
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
return x11->mouse_m;
|
||||
/* case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||
return x11->mouse_b4;*/
|
||||
/* case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||
return x11->mouse_b5;*/
|
||||
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||
return x_mouse_state_wheel( key );
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
return x11->mouse_l;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
return x11->mouse_r;
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
return x11->mouse_m;
|
||||
#if 0
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||
return x11->mouse_b4;
|
||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||
return x11->mouse_b5;
|
||||
#endif
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
|
||||
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
|
||||
return x_mouse_state_wheel(key);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -176,10 +176,11 @@ static int16_t x_pressed_analog(x11_input_t *x11,
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t x_lightgun_aiming_state( x11_input_t *x11, unsigned idx, unsigned id )
|
||||
static int16_t x_lightgun_aiming_state(
|
||||
x11_input_t *x11, unsigned idx, unsigned id )
|
||||
{
|
||||
const int edge_detect = 32700;
|
||||
struct video_viewport vp;
|
||||
const int edge_detect = 32700;
|
||||
bool inside = false;
|
||||
int16_t res_x = 0;
|
||||
int16_t res_y = 0;
|
||||
@ -194,21 +195,21 @@ static int16_t x_lightgun_aiming_state( x11_input_t *x11, unsigned idx, unsigned
|
||||
vp.full_height = 0;
|
||||
|
||||
if (!(video_driver_translate_coord_viewport_wrap(&vp, x11->mouse_x, x11->mouse_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
return 0;
|
||||
|
||||
inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect);
|
||||
|
||||
switch ( id )
|
||||
{
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||
return inside ? res_x : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||
return inside ? res_y : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||
return !inside;
|
||||
default:
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||
return inside ? res_x : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||
return inside ? res_y : 0;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||
return !inside;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -270,8 +271,9 @@ static int16_t x_pointer_state(x11_input_t *x11,
|
||||
vp.full_width = 0;
|
||||
vp.full_height = 0;
|
||||
|
||||
if (!(video_driver_translate_coord_viewport_wrap(&vp, x11->mouse_x, x11->mouse_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
if (!(video_driver_translate_coord_viewport_wrap(
|
||||
&vp, x11->mouse_x, x11->mouse_y,
|
||||
&res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||
return 0;
|
||||
|
||||
if (screen)
|
||||
@ -328,7 +330,7 @@ static int16_t x_input_state(void *data,
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (x_is_pressed(x11, joypad_info, binds[port], port, id))
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
@ -456,7 +458,7 @@ static void x_input_poll_mouse(x11_input_t *x11,
|
||||
|
||||
video_driver_get_viewport_info(&vp);
|
||||
|
||||
mid_w = vp.full_width >> 1;
|
||||
mid_w = vp.full_width >> 1;
|
||||
mid_h = vp.full_height >> 1;
|
||||
|
||||
if (x11->mouse_x != mid_w || x11->mouse_y != mid_h)
|
||||
|
@ -98,9 +98,9 @@ static int16_t xdk_input_state(void *data,
|
||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||
|
||||
if ((uint16_t)joykey != NO_BTN && xdk->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||
return true;
|
||||
return 1;
|
||||
if (((float)abs(xdk->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
|
@ -38,23 +38,25 @@ static void xenon360_input_poll(void *data)
|
||||
for (unsigned i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
{
|
||||
struct controller_data_s pad;
|
||||
uint64_t *cur_state;
|
||||
|
||||
usb_do_poll();
|
||||
get_controller_data(&pad, i);
|
||||
|
||||
uint64_t *cur_state = &state[i];
|
||||
cur_state = &state[i];
|
||||
|
||||
*cur_state |= pad.b ? RETRO_DEVICE_ID_JOYPAD_A : 0;
|
||||
*cur_state |= pad.a ? RETRO_DEVICE_ID_JOYPAD_B : 0;
|
||||
*cur_state |= pad.y ? RETRO_DEVICE_ID_JOYPAD_X : 0;
|
||||
*cur_state |= pad.x ? RETRO_DEVICE_ID_JOYPAD_Y : 0;
|
||||
*cur_state |= pad.left ? RETRO_DEVICE_ID_JOYPAD_LEFT : 0;
|
||||
*cur_state |= pad.right ? RETRO_DEVICE_ID_JOYPAD_RIGHT : 0;
|
||||
*cur_state |= pad.up ? RETRO_DEVICE_ID_JOYPAD_UP : 0;
|
||||
*cur_state |= pad.down ? RETRO_DEVICE_ID_JOYPAD_DOWN : 0;
|
||||
*cur_state |= pad.start ? RETRO_DEVICE_ID_JOYPAD_START : 0;
|
||||
*cur_state |= pad.back ? RETRO_DEVICE_ID_JOYPAD_SELECT : 0;
|
||||
*cur_state |= pad.lt ? RETRO_DEVICE_ID_JOYPAD_L : 0;
|
||||
*cur_state |= pad.rt ? RETRO_DEVICE_ID_JOYPAD_R : 0;
|
||||
*cur_state |= pad.b ? RETRO_DEVICE_ID_JOYPAD_A : 0;
|
||||
*cur_state |= pad.a ? RETRO_DEVICE_ID_JOYPAD_B : 0;
|
||||
*cur_state |= pad.y ? RETRO_DEVICE_ID_JOYPAD_X : 0;
|
||||
*cur_state |= pad.x ? RETRO_DEVICE_ID_JOYPAD_Y : 0;
|
||||
*cur_state |= pad.left ? RETRO_DEVICE_ID_JOYPAD_LEFT : 0;
|
||||
*cur_state |= pad.right ? RETRO_DEVICE_ID_JOYPAD_RIGHT : 0;
|
||||
*cur_state |= pad.up ? RETRO_DEVICE_ID_JOYPAD_UP : 0;
|
||||
*cur_state |= pad.down ? RETRO_DEVICE_ID_JOYPAD_DOWN : 0;
|
||||
*cur_state |= pad.start ? RETRO_DEVICE_ID_JOYPAD_START : 0;
|
||||
*cur_state |= pad.back ? RETRO_DEVICE_ID_JOYPAD_SELECT : 0;
|
||||
*cur_state |= pad.lt ? RETRO_DEVICE_ID_JOYPAD_L : 0;
|
||||
*cur_state |= pad.rt ? RETRO_DEVICE_ID_JOYPAD_R : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +89,7 @@ static int16_t xenon360_input_state(void *data,
|
||||
}
|
||||
else
|
||||
if (state[port] & binds[port][id].joykey)
|
||||
return true;
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user