mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
(winraw) Cleanups - get rid of setting pointer grabbing everywhere -
clean up mouse state grabbing everywhere - would be costly in loops
This commit is contained in:
parent
7ee5ffcd1c
commit
9aafd3c723
@ -260,14 +260,6 @@ static bool dinput_mouse_button_pressed(
|
|||||||
struct dinput_input *di, unsigned port, unsigned key)
|
struct dinput_input *di, unsigned port, unsigned key)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* the driver only supports one mouse */
|
|
||||||
if (settings->uints.input_mouse_index[port] != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
@ -301,7 +293,6 @@ static bool dinput_mouse_button_pressed(
|
|||||||
result = di->mouse_hwd;
|
result = di->mouse_hwd;
|
||||||
di->mouse_hwd = false;
|
di->mouse_hwd = false;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -404,14 +395,6 @@ static int16_t dinput_mouse_state(struct dinput_input *di,
|
|||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
int16_t state = 0;
|
int16_t state = 0;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* the driver only supports one mouse */
|
|
||||||
if (settings->uints.input_mouse_index[port] != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
@ -457,15 +440,6 @@ static int16_t dinput_mouse_state(struct dinput_input *di,
|
|||||||
static int16_t dinput_mouse_state_screen(struct dinput_input *di,
|
static int16_t dinput_mouse_state_screen(struct dinput_input *di,
|
||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* the driver only supports one mouse */
|
|
||||||
if (settings->uints.input_mouse_index[ port ] != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_MOUSE_X:
|
case RETRO_DEVICE_ID_MOUSE_X:
|
||||||
@ -556,90 +530,101 @@ static int16_t dinput_input_state(void *data,
|
|||||||
const struct retro_keybind **binds, unsigned port,
|
const struct retro_keybind **binds, unsigned port,
|
||||||
unsigned device, unsigned idx, unsigned id)
|
unsigned device, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
|
settings_t *settings;
|
||||||
struct dinput_input *di = (struct dinput_input*)data;
|
struct dinput_input *di = (struct dinput_input*)data;
|
||||||
|
|
||||||
|
if (port >= MAX_USERS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
|
||||||
{
|
{
|
||||||
unsigned i;
|
settings = config_get_ptr();
|
||||||
int16_t ret = 0;
|
|
||||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||||
{
|
{
|
||||||
if (binds[port][i].key < RETROK_LAST)
|
unsigned i;
|
||||||
|
int16_t ret = 0;
|
||||||
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
{
|
{
|
||||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][i].key]] & 0x80)
|
if (binds[port][i].key < RETROK_LAST)
|
||||||
if ((i == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
{
|
||||||
|
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][i].key]] & 0x80)
|
||||||
|
if ((i == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
||||||
|
{
|
||||||
|
ret |= (1 << i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binds[port][i].valid)
|
||||||
|
{
|
||||||
|
/* Auto-binds are per joypad, not per user. */
|
||||||
|
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
|
||||||
|
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
|
||||||
|
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
|
||||||
|
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
||||||
|
|
||||||
|
if (settings->uints.input_mouse_index[port] == 0)
|
||||||
|
if (dinput_mouse_button_pressed(
|
||||||
|
di, port, binds[port][i].mbutton))
|
||||||
|
{
|
||||||
|
ret |= (1 << i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uint16_t)joykey != NO_BTN
|
||||||
|
&& di->joypad->button(
|
||||||
|
joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
{
|
{
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (binds[port][i].valid)
|
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||||
{
|
{
|
||||||
/* Auto-binds are per joypad, not per user. */
|
ret |= (1 << i);
|
||||||
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
|
continue;
|
||||||
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
|
}
|
||||||
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
|
|
||||||
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
|
|
||||||
|
|
||||||
if (dinput_mouse_button_pressed(
|
|
||||||
di, port, binds[port][i].mbutton))
|
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((uint16_t)joykey != NO_BTN
|
|
||||||
&& di->joypad->button(
|
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
|
||||||
{
|
|
||||||
ret |= (1 << i);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
return ret;
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (id < RARCH_BIND_LIST_END)
|
|
||||||
{
|
{
|
||||||
if (binds[port][id].key < RETROK_LAST)
|
if (id < RARCH_BIND_LIST_END)
|
||||||
{
|
{
|
||||||
if (di->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] & 0x80)
|
if (binds[port][id].key < RETROK_LAST)
|
||||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_dinput.keyboard_mapping_blocked)
|
{
|
||||||
return 1;
|
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)
|
||||||
if (binds[port][id].valid)
|
return 1;
|
||||||
{
|
}
|
||||||
/* Auto-binds are per joypad, not per user. */
|
if (binds[port][id].valid)
|
||||||
|
{
|
||||||
|
/* Auto-binds are per joypad, not per user. */
|
||||||
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
|
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
|
||||||
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
|
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
|
||||||
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
|
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
|
||||||
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
|
||||||
|
|
||||||
if (dinput_mouse_button_pressed(di, port, binds[port][id].mbutton))
|
if (settings->uints.input_mouse_index[port] == 0)
|
||||||
return 1;
|
if (dinput_mouse_button_pressed(di, port, binds[port][id].mbutton))
|
||||||
if ((uint16_t)joykey != NO_BTN
|
return 1;
|
||||||
&& di->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
if ((uint16_t)joykey != NO_BTN
|
||||||
return 1;
|
&& di->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
return 1;
|
||||||
return 1;
|
if (((float)abs(di->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
return (id < RETROK_LAST) && di->state[rarch_keysym_lut[(enum retro_key)id]] & 0x80;
|
return (id < RETROK_LAST) &&
|
||||||
|
di->state[rarch_keysym_lut[(enum retro_key)id]] & 0x80;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
if (binds[port])
|
if (binds[port])
|
||||||
{
|
{
|
||||||
@ -652,11 +637,19 @@ static int16_t dinput_input_state(void *data,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RETRO_DEVICE_MOUSE:
|
case RETRO_DEVICE_MOUSE:
|
||||||
return dinput_mouse_state(di, port, id);
|
{
|
||||||
|
settings = config_get_ptr();
|
||||||
|
if (settings->uints.input_mouse_index[port] == 0)
|
||||||
|
return dinput_mouse_state(di, port, id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||||
return dinput_mouse_state_screen(di, port, id);
|
{
|
||||||
|
settings = config_get_ptr();
|
||||||
|
if (settings->uints.input_mouse_index[ port ] != 0)
|
||||||
|
return dinput_mouse_state_screen(di, port, id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_POINTER:
|
case RETRO_DEVICE_POINTER:
|
||||||
case RARCH_DEVICE_POINTER_SCREEN:
|
case RARCH_DEVICE_POINTER_SCREEN:
|
||||||
return dinput_pointer_state(di, idx, id,
|
return dinput_pointer_state(di, idx, id,
|
||||||
@ -686,6 +679,7 @@ static int16_t dinput_input_state(void *data,
|
|||||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||||
{
|
{
|
||||||
unsigned new_id = 0;
|
unsigned new_id = 0;
|
||||||
|
settings = config_get_ptr();
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
@ -739,8 +733,9 @@ static int16_t dinput_input_state(void *data,
|
|||||||
const uint32_t joyaxis = (binds[port][new_id].joyaxis != AXIS_NONE)
|
const uint32_t joyaxis = (binds[port][new_id].joyaxis != AXIS_NONE)
|
||||||
? binds[port][new_id].joyaxis : joypad_info->auto_binds[new_id].joyaxis;
|
? binds[port][new_id].joyaxis : joypad_info->auto_binds[new_id].joyaxis;
|
||||||
|
|
||||||
if (dinput_mouse_button_pressed(di, port, binds[port][new_id].mbutton))
|
if (settings->uints.input_mouse_index[port] == 0)
|
||||||
return 1;
|
if (dinput_mouse_button_pressed(di, port, binds[port][new_id].mbutton))
|
||||||
|
return 1;
|
||||||
if ((uint16_t)joykey != NO_BTN
|
if ((uint16_t)joykey != NO_BTN
|
||||||
&& di->joypad->button(
|
&& di->joypad->button(
|
||||||
joypad_info->joy_idx, (uint16_t)joykey))
|
joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
|
@ -209,37 +209,24 @@ static BOOL winraw_set_mouse_input(HWND window, bool grab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr,
|
static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr,
|
||||||
|
winraw_mouse_t *mouse,
|
||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
const int edge_detect = 32700;
|
const int edge_detect = 32700;
|
||||||
bool inside = false;
|
bool inside = false;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
winraw_mouse_t *mouse = NULL;
|
|
||||||
int16_t res_x = 0;
|
int16_t res_x = 0;
|
||||||
int16_t res_y = 0;
|
int16_t res_y = 0;
|
||||||
int16_t res_screen_x = 0;
|
int16_t res_screen_x = 0;
|
||||||
int16_t res_screen_y = 0;
|
int16_t res_screen_y = 0;
|
||||||
|
|
||||||
for (i = 0; i < g_mouse_cnt; ++i)
|
vp.x = 0;
|
||||||
{
|
vp.y = 0;
|
||||||
if (i == settings->uints.input_mouse_index[port])
|
vp.width = 0;
|
||||||
{
|
vp.height = 0;
|
||||||
mouse = &wr->mice[i];
|
vp.full_width = 0;
|
||||||
break;
|
vp.full_height = 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mouse)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
vp.x = 0;
|
|
||||||
vp.y = 0;
|
|
||||||
vp.width = 0;
|
|
||||||
vp.height = 0;
|
|
||||||
vp.full_width = 0;
|
|
||||||
vp.full_height = 0;
|
|
||||||
|
|
||||||
if ( !( video_driver_translate_coord_viewport_wrap(
|
if ( !( video_driver_translate_coord_viewport_wrap(
|
||||||
&vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) )
|
&vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) )
|
||||||
@ -263,27 +250,9 @@ static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int16_t winraw_mouse_state(winraw_input_t *wr,
|
static int16_t winraw_mouse_state(winraw_input_t *wr,
|
||||||
|
winraw_mouse_t *mouse,
|
||||||
unsigned port, bool abs, unsigned id)
|
unsigned port, bool abs, unsigned id)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
winraw_mouse_t *mouse = NULL;
|
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < g_mouse_cnt; ++i)
|
|
||||||
{
|
|
||||||
if (i == settings->uints.input_mouse_index[port])
|
|
||||||
{
|
|
||||||
mouse = &wr->mice[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mouse)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_MOUSE_X:
|
case RETRO_DEVICE_ID_MOUSE_X:
|
||||||
@ -312,50 +281,33 @@ static int16_t winraw_mouse_state(winraw_input_t *wr,
|
|||||||
#define winraw_keyboard_pressed(wr, key) (wr->keyboard.keys[rarch_keysym_lut[(enum retro_key)(key)]])
|
#define winraw_keyboard_pressed(wr, key) (wr->keyboard.keys[rarch_keysym_lut[(enum retro_key)(key)]])
|
||||||
|
|
||||||
static bool winraw_mouse_button_pressed(
|
static bool winraw_mouse_button_pressed(
|
||||||
winraw_input_t *wr, unsigned port, unsigned key)
|
winraw_input_t *wr,
|
||||||
|
winraw_mouse_t *mouse,
|
||||||
|
unsigned port, unsigned key)
|
||||||
{
|
{
|
||||||
unsigned i;
|
switch (key)
|
||||||
winraw_mouse_t *mouse = NULL;
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||||
|
return mouse->btn_l;
|
||||||
if (port >= MAX_USERS)
|
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||||
return false;
|
return mouse->btn_r;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||||
for (i = 0; i < g_mouse_cnt; ++i)
|
return mouse->btn_m;
|
||||||
{
|
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
||||||
if (i == settings->uints.input_mouse_index[port])
|
return mouse->btn_b4;
|
||||||
{
|
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
||||||
mouse = &wr->mice[i];
|
return mouse->btn_b5;
|
||||||
break;
|
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||||
}
|
return mouse->whl_u;
|
||||||
}
|
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||||
|
return mouse->whl_d;
|
||||||
if (!mouse)
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
switch ( key )
|
|
||||||
{
|
|
||||||
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
|
||||||
return mouse->btn_l;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
|
||||||
return mouse->btn_r;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
|
||||||
return mouse->btn_m;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
|
|
||||||
return mouse->btn_b4;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
|
|
||||||
return mouse->btn_b5;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
|
||||||
return mouse->whl_u;
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
|
||||||
return mouse->whl_d;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool winraw_is_pressed(winraw_input_t *wr,
|
static bool winraw_is_pressed(winraw_input_t *wr,
|
||||||
|
winraw_mouse_t *mouse,
|
||||||
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)
|
unsigned port, unsigned id)
|
||||||
@ -365,6 +317,8 @@ static bool winraw_is_pressed(winraw_input_t *wr,
|
|||||||
if ((bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key))
|
if ((bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key))
|
||||||
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_winraw.keyboard_mapping_blocked)
|
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_winraw.keyboard_mapping_blocked)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
if (binds && binds[id].valid)
|
if (binds && binds[id].valid)
|
||||||
{
|
{
|
||||||
/* Auto-binds are per joypad, not per user. */
|
/* Auto-binds are per joypad, not per user. */
|
||||||
@ -372,7 +326,8 @@ static bool winraw_is_pressed(winraw_input_t *wr,
|
|||||||
? 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;
|
||||||
if (winraw_mouse_button_pressed(wr, port, bind->mbutton))
|
if (mouse && winraw_mouse_button_pressed(wr,
|
||||||
|
mouse, port, bind->mbutton))
|
||||||
return true;
|
return true;
|
||||||
if ((uint16_t)joykey != NO_BTN &&
|
if ((uint16_t)joykey != NO_BTN &&
|
||||||
wr->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
wr->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
|
||||||
@ -410,27 +365,9 @@ static void winraw_init_mouse_xy_mapping(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr,
|
static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr,
|
||||||
|
winraw_mouse_t *mouse,
|
||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
winraw_mouse_t *mouse = NULL;
|
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < g_mouse_cnt; ++i)
|
|
||||||
{
|
|
||||||
if (i == settings->uints.input_mouse_index[port])
|
|
||||||
{
|
|
||||||
mouse = &wr->mice[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mouse)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||||
@ -656,7 +593,58 @@ static int16_t winraw_input_state(void *d,
|
|||||||
const struct retro_keybind **binds,
|
const struct retro_keybind **binds,
|
||||||
unsigned port, unsigned device, unsigned index, unsigned id)
|
unsigned port, unsigned device, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
winraw_input_t *wr = (winraw_input_t*)d;
|
unsigned i;
|
||||||
|
settings_t *settings = NULL;
|
||||||
|
winraw_mouse_t *mouse = NULL;
|
||||||
|
winraw_input_t *wr = (winraw_input_t*)d;
|
||||||
|
bool process_mouse = (device == RETRO_DEVICE_JOYPAD);
|
||||||
|
|
||||||
|
if (port >= MAX_USERS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!process_mouse && device == RETRO_DEVICE_LIGHTGUN)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||||
|
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||||
|
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
||||||
|
|
||||||
|
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||||
|
process_mouse = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process_mouse)
|
||||||
|
{
|
||||||
|
settings = config_get_ptr();
|
||||||
|
for (i = 0; i < g_mouse_cnt; ++i)
|
||||||
|
{
|
||||||
|
if (i == settings->uints.input_mouse_index[port])
|
||||||
|
{
|
||||||
|
mouse = &wr->mice[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
@ -668,7 +656,7 @@ static int16_t winraw_input_state(void *d,
|
|||||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
{
|
{
|
||||||
if (winraw_is_pressed(
|
if (winraw_is_pressed(
|
||||||
wr, joypad_info, binds[port], port, i))
|
wr, mouse, joypad_info, binds[port], port, i))
|
||||||
{
|
{
|
||||||
ret |= (1 << i);
|
ret |= (1 << i);
|
||||||
continue;
|
continue;
|
||||||
@ -680,7 +668,8 @@ static int16_t winraw_input_state(void *d,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (id < RARCH_BIND_LIST_END)
|
if (id < RARCH_BIND_LIST_END)
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, id);
|
return winraw_is_pressed(
|
||||||
|
wr, mouse ,joypad_info, binds[port], port, id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
@ -691,9 +680,12 @@ static int16_t winraw_input_state(void *d,
|
|||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id);
|
return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id);
|
||||||
case RETRO_DEVICE_MOUSE:
|
case RETRO_DEVICE_MOUSE:
|
||||||
return winraw_mouse_state(wr, port, false, id);
|
|
||||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||||
return winraw_mouse_state(wr, port, true, id);
|
if (mouse)
|
||||||
|
return winraw_mouse_state(wr, mouse, port,
|
||||||
|
(device == RARCH_DEVICE_MOUSE_SCREEN) ? true : false,
|
||||||
|
id);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_LIGHTGUN:
|
case RETRO_DEVICE_LIGHTGUN:
|
||||||
switch ( id )
|
switch ( id )
|
||||||
{
|
{
|
||||||
@ -701,40 +693,45 @@ static int16_t winraw_input_state(void *d,
|
|||||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||||
if (port >= MAX_USERS)
|
if (mouse)
|
||||||
break;
|
return winraw_lightgun_aiming_state(wr, mouse, port, id);
|
||||||
return winraw_lightgun_aiming_state(wr, port, id);
|
break;
|
||||||
|
|
||||||
/*buttons*/
|
/*buttons*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER);
|
return winraw_is_pressed(
|
||||||
|
wr, mouse, joypad_info, binds[port],
|
||||||
|
port, RARCH_LIGHTGUN_TRIGGER);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD);
|
return winraw_is_pressed(
|
||||||
|
wr, mouse, joypad_info, binds[port],
|
||||||
|
port, RARCH_LIGHTGUN_RELOAD);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||||
|
|
||||||
/*deprecated*/
|
/*deprecated*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
case RETRO_DEVICE_ID_LIGHTGUN_Y:
|
||||||
return winraw_deprecated_lightgun_state(wr, port, id);
|
if (mouse)
|
||||||
|
return winraw_deprecated_lightgun_state(wr, mouse, port, id);
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||||
return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
return winraw_is_pressed(wr, mouse, joypad_info, binds[port], port, RARCH_LIGHTGUN_START);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user