(Input) Settings cleanups
This commit is contained in:
parent
8b11d9f039
commit
0ec3a8a449
|
@ -787,10 +787,12 @@ static INLINE int android_input_poll_event_type_motion(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pointer_max = MIN(AMotionEvent_getPointerCount(event), MAX_TOUCH);
|
int pointer_max = MIN(
|
||||||
settings_t *settings = config_get_ptr();
|
AMotionEvent_getPointerCount(event), MAX_TOUCH);
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool vibrate_on_keypress = settings ? settings->bools.vibrate_on_keypress : false;
|
||||||
|
|
||||||
if (settings && settings->bools.vibrate_on_keypress && action != AMOTION_EVENT_ACTION_MOVE)
|
if (vibrate_on_keypress && action != AMOTION_EVENT_ACTION_MOVE)
|
||||||
android_app_write_cmd(g_android, APP_CMD_VIBRATE_KEYPRESS);
|
android_app_write_cmd(g_android, APP_CMD_VIBRATE_KEYPRESS);
|
||||||
|
|
||||||
if (action == AMOTION_EVENT_ACTION_DOWN && ENABLE_TOUCH_SCREEN_MOUSE)
|
if (action == AMOTION_EVENT_ACTION_DOWN && ENABLE_TOUCH_SCREEN_MOUSE)
|
||||||
|
@ -1396,10 +1398,10 @@ static bool android_input_key_pressed(android_input_t *android, int key)
|
||||||
*/
|
*/
|
||||||
static void android_input_poll(void *data)
|
static void android_input_poll(void *data)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
int ident;
|
int ident;
|
||||||
struct android_app *android_app = (struct android_app*)g_android;
|
struct android_app *android_app = (struct android_app*)g_android;
|
||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
while ((ident =
|
while ((ident =
|
||||||
ALooper_pollAll((input_config_binds[0][RARCH_PAUSE_TOGGLE].valid
|
ALooper_pollAll((input_config_binds[0][RARCH_PAUSE_TOGGLE].valid
|
||||||
|
@ -1742,12 +1744,13 @@ static void android_input_set_rumble_internal(
|
||||||
static bool android_input_set_rumble(void *data, unsigned port,
|
static bool android_input_set_rumble(void *data, unsigned port,
|
||||||
enum retro_rumble_effect effect, uint16_t strength)
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool enable_device_vibration = settings->bools.enable_device_vibration;
|
||||||
|
|
||||||
if (!g_android || !g_android->doVibrate)
|
if (!g_android || !g_android->doVibrate)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (settings->bools.enable_device_vibration)
|
if (enable_device_vibration)
|
||||||
{
|
{
|
||||||
static uint16_t last_strength_strong = 0;
|
static uint16_t last_strength_strong = 0;
|
||||||
static uint16_t last_strength_weak = 0;
|
static uint16_t last_strength_weak = 0;
|
||||||
|
|
|
@ -268,7 +268,7 @@ static bool dinput_mouse_button_pressed(
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* the driver only supports one mouse */
|
/* the driver only supports one mouse */
|
||||||
if ( settings->uints.input_mouse_index[ port ] != 0)
|
if (settings->uints.input_mouse_index[port] != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
|
@ -341,7 +341,7 @@ static int16_t dinput_pressed_analog(struct dinput_input *di,
|
||||||
return pressed_plus + pressed_minus;
|
return pressed_plus + pressed_minus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned idx, unsigned id)
|
static int16_t dinput_lightgun_aiming_state(struct dinput_input *di, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
const int edge_detect = 32700;
|
const int edge_detect = 32700;
|
||||||
struct video_viewport vp;
|
struct video_viewport vp;
|
||||||
|
@ -363,7 +363,7 @@ static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned i
|
||||||
vp.full_width = 0;
|
vp.full_width = 0;
|
||||||
vp.full_height = 0;
|
vp.full_height = 0;
|
||||||
|
|
||||||
while ( check_pos && num < idx)
|
while (check_pos && num < idx)
|
||||||
{
|
{
|
||||||
num++;
|
num++;
|
||||||
check_pos = check_pos->next;
|
check_pos = check_pos->next;
|
||||||
|
@ -381,7 +381,7 @@ static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned i
|
||||||
y = check_pos->pointer_y;
|
y = check_pos->pointer_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !( video_driver_translate_coord_viewport_wrap(
|
if (!(video_driver_translate_coord_viewport_wrap(
|
||||||
&vp, x, y, &res_x, &res_y, &res_screen_x, &res_screen_y)))
|
&vp, x, y, &res_x, &res_y, &res_screen_x, &res_screen_y)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -402,17 +402,17 @@ static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned i
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_mouse_state(struct dinput_input *di, unsigned port, unsigned id)
|
static int16_t dinput_mouse_state(struct dinput_input *di,
|
||||||
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
int16_t state = 0;
|
int16_t state = 0;
|
||||||
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (port >= MAX_USERS)
|
if (port >= MAX_USERS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* the driver only supports one mouse */
|
/* the driver only supports one mouse */
|
||||||
if (settings->uints.input_mouse_index[ port ] != 0)
|
if (settings->uints.input_mouse_index[port] != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
|
@ -456,7 +456,8 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned port, unsign
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned port, unsigned id)
|
static int16_t dinput_mouse_state_screen(struct dinput_input *di,
|
||||||
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
@ -670,7 +671,7 @@ static int16_t dinput_input_state(void *data,
|
||||||
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:
|
||||||
return dinput_lightgun_aiming_state( di, idx, id);
|
return dinput_lightgun_aiming_state(di, idx, id);
|
||||||
|
|
||||||
/*buttons*/
|
/*buttons*/
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||||
|
|
|
@ -109,15 +109,14 @@ static int16_t gx_lightgun_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
||||||
|
|
||||||
static int16_t gx_mouse_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
static int16_t gx_mouse_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
||||||
{
|
{
|
||||||
int x = 0;
|
settings_t *settings = config_get_ptr();
|
||||||
int y = 0;
|
unsigned input_mouse_scale = settings->uints.input_mouse_scale;
|
||||||
|
int x_scale = input_mouse_scale;
|
||||||
settings_t *settings = config_get_ptr();
|
int y_scale = input_mouse_scale;
|
||||||
int x_scale = settings->uints.input_mouse_scale;
|
int x = (gx->mouse[joy_idx].x_abs
|
||||||
int y_scale = settings->uints.input_mouse_scale;
|
- gx->mouse[joy_idx].x_last) * x_scale;
|
||||||
|
int y = (gx->mouse[joy_idx].y_abs
|
||||||
x = (gx->mouse[joy_idx].x_abs - gx->mouse[joy_idx].x_last) * x_scale;
|
- gx->mouse[joy_idx].y_last) * y_scale;
|
||||||
y = (gx->mouse[joy_idx].y_abs - gx->mouse[joy_idx].y_last) * y_scale;
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,9 +185,10 @@ static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||||
static void psp_joypad_poll(void)
|
static void psp_joypad_poll(void)
|
||||||
{
|
{
|
||||||
unsigned player;
|
unsigned player;
|
||||||
unsigned players_count = DEFAULT_MAX_PADS;
|
unsigned players_count = DEFAULT_MAX_PADS;
|
||||||
#if defined(VITA)
|
#if defined(VITA)
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool input_backtouch_enable = settings->bools.input_backtouch_enable;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PSP
|
#ifdef PSP
|
||||||
|
@ -262,21 +263,27 @@ static void psp_joypad_poll(void)
|
||||||
#endif
|
#endif
|
||||||
#if defined(VITA)
|
#if defined(VITA)
|
||||||
if (sceKernelGetModelForCDialog() == SCE_KERNEL_MODEL_VITA
|
if (sceKernelGetModelForCDialog() == SCE_KERNEL_MODEL_VITA
|
||||||
&& settings->bools.input_backtouch_enable)
|
&& input_backtouch_enable)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
SceTouchData touch_surface = {0};
|
SceTouchData touch_surface = {0};
|
||||||
sceTouchPeek(settings->bools.input_backtouch_toggle
|
sceTouchPeek(input_backtouch_toggle
|
||||||
? SCE_TOUCH_PORT_FRONT : SCE_TOUCH_PORT_BACK, &touch_surface, 1);
|
? SCE_TOUCH_PORT_FRONT
|
||||||
|
: SCE_TOUCH_PORT_BACK,
|
||||||
|
&touch_surface, 1);
|
||||||
|
|
||||||
for (i = 0; i < touch_surface.reportNum; i++)
|
for (i = 0; i < touch_surface.reportNum; i++)
|
||||||
{
|
{
|
||||||
int x = LERP(touch_surface.report[i].x, TOUCH_MAX_WIDTH, SCREEN_WIDTH);
|
int x = LERP(touch_surface.report[i].x, TOUCH_MAX_WIDTH, SCREEN_WIDTH);
|
||||||
int y = LERP(touch_surface.report[i].y, TOUCH_MAX_HEIGHT, SCREEN_HEIGHT);
|
int y = LERP(touch_surface.report[i].y, TOUCH_MAX_HEIGHT, SCREEN_HEIGHT);
|
||||||
if (NW_AREA(x, y)) state_tmp.buttons |= PSP_CTRL_L2;
|
if (NW_AREA(x, y))
|
||||||
if (NE_AREA(x, y)) state_tmp.buttons |= PSP_CTRL_R2;
|
state_tmp.buttons |= PSP_CTRL_L2;
|
||||||
if (SW_AREA(x, y)) state_tmp.buttons |= PSP_CTRL_L3;
|
if (NE_AREA(x, y))
|
||||||
if (SE_AREA(x, y)) state_tmp.buttons |= PSP_CTRL_R3;
|
state_tmp.buttons |= PSP_CTRL_R2;
|
||||||
|
if (SW_AREA(x, y))
|
||||||
|
state_tmp.buttons |= PSP_CTRL_L3;
|
||||||
|
if (SE_AREA(x, y))
|
||||||
|
state_tmp.buttons |= PSP_CTRL_R3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -202,13 +202,16 @@ static void switch_joypad_poll(void)
|
||||||
{
|
{
|
||||||
for (i = 0; i < MAX_USERS; i += 2)
|
for (i = 0; i < MAX_USERS; i += 2)
|
||||||
{
|
{
|
||||||
if (settings->uints.input_split_joycon[i])
|
unsigned input_split_joycon =
|
||||||
|
settings->uints.input_split_joycon[i];
|
||||||
|
|
||||||
|
if (input_split_joycon)
|
||||||
{
|
{
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
||||||
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal);
|
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal);
|
||||||
}
|
}
|
||||||
else if (!settings->uints.input_split_joycon[i])
|
else if (!input_split_joycon)
|
||||||
{
|
{
|
||||||
hidSetNpadJoyAssignmentModeDual(i);
|
hidSetNpadJoyAssignmentModeDual(i);
|
||||||
hidSetNpadJoyAssignmentModeDual(i + 1);
|
hidSetNpadJoyAssignmentModeDual(i + 1);
|
||||||
|
@ -227,8 +230,10 @@ static void switch_joypad_poll(void)
|
||||||
* joycons are correctly split. */
|
* joycons are correctly split. */
|
||||||
for (i = 0; i < MAX_USERS; i += 2)
|
for (i = 0; i < MAX_USERS; i += 2)
|
||||||
{
|
{
|
||||||
|
unsigned input_split_joycon = settings->uints.input_split_joycon[i];
|
||||||
|
|
||||||
/* CONTROLLER_PLAYER_X, X == i++ */
|
/* CONTROLLER_PLAYER_X, X == i++ */
|
||||||
if (settings->uints.input_split_joycon[i])
|
if (input_split_joycon)
|
||||||
{
|
{
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
||||||
|
@ -273,14 +278,15 @@ static void switch_joypad_poll(void)
|
||||||
/* split or join joycons every time the user changes a setting */
|
/* split or join joycons every time the user changes a setting */
|
||||||
for (i = 0; i < MAX_USERS; i += 2)
|
for (i = 0; i < MAX_USERS; i += 2)
|
||||||
{
|
{
|
||||||
if ( settings->uints.input_split_joycon[i]
|
unsigned input_split_joycon = settings->uints.input_split_joycon[i];
|
||||||
|
if (input_split_joycon
|
||||||
&& !previous_split_joycon_setting[i])
|
&& !previous_split_joycon_setting[i])
|
||||||
{
|
{
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i);
|
||||||
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
hidSetNpadJoyAssignmentModeSingleByDefault(i + 1);
|
||||||
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal);
|
hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal);
|
||||||
}
|
}
|
||||||
else if (!settings->uints.input_split_joycon[i]
|
else if (!input_split_joycon
|
||||||
&& previous_split_joycon_setting[i])
|
&& previous_split_joycon_setting[i])
|
||||||
{
|
{
|
||||||
hidSetNpadJoyAssignmentModeDual(i);
|
hidSetNpadJoyAssignmentModeDual(i);
|
||||||
|
|
Loading…
Reference in New Issue