(Input) Settings cleanups

This commit is contained in:
twinaphex 2020-02-23 06:05:23 +01:00
parent 8b11d9f039
commit 0ec3a8a449
5 changed files with 55 additions and 39 deletions

View File

@ -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(
AMotionEvent_getPointerCount(event), MAX_TOUCH);
settings_t *settings = config_get_ptr(); 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
@ -1743,11 +1745,12 @@ 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;

View File

@ -402,10 +402,10 @@ 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)
@ -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();

View File

@ -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;
int y = 0;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
int x_scale = settings->uints.input_mouse_scale; unsigned input_mouse_scale = settings->uints.input_mouse_scale;
int y_scale = settings->uints.input_mouse_scale; int x_scale = input_mouse_scale;
int y_scale = input_mouse_scale;
x = (gx->mouse[joy_idx].x_abs - gx->mouse[joy_idx].x_last) * x_scale; int x = (gx->mouse[joy_idx].x_abs
y = (gx->mouse[joy_idx].y_abs - gx->mouse[joy_idx].y_last) * y_scale; - gx->mouse[joy_idx].x_last) * x_scale;
int y = (gx->mouse[joy_idx].y_abs
- gx->mouse[joy_idx].y_last) * y_scale;
switch (id) switch (id)
{ {

View File

@ -188,6 +188,7 @@ static void psp_joypad_poll(void)
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

View File

@ -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);