Merge pull request #6926 from fr500/staging

Android fixes
This commit is contained in:
Twinaphex 2018-06-30 14:31:06 +02:00 committed by GitHub
commit 5366fc1f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 397 additions and 78 deletions

View File

@ -14,9 +14,6 @@
"*.in": "c",
"*.rh": "c",
"array": "c",
"stdlib.h": "c",
"cmath": "c",
"cstdlib": "c"
},
"C_Cpp.dimInactiveRegions": false,
}

View File

@ -662,6 +662,8 @@ static const unsigned input_poll_type_behavior = 2;
static const unsigned input_bind_timeout = 5;
static const unsigned input_bind_hold = 2;
static const unsigned menu_thumbnails_default = 3;
static const unsigned menu_left_thumbnails_default = 0;

View File

@ -1494,6 +1494,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
struct config_uint_setting *tmp = (struct config_uint_setting*)malloc((*size + 1) * sizeof(struct config_uint_setting));
SETTING_UINT("input_bind_timeout", &settings->uints.input_bind_timeout, true, input_bind_timeout, false);
SETTING_UINT("input_bind_hold", &settings->uints.input_bind_hold, true, input_bind_hold, false);
SETTING_UINT("input_turbo_period", &settings->uints.input_turbo_period, true, turbo_period, false);
SETTING_UINT("input_duty_cycle", &settings->uints.input_turbo_duty_cycle, true, turbo_duty_cycle, false);
SETTING_UINT("input_max_users", input_driver_get_uint(INPUT_ACTION_MAX_USERS), true, input_max_users, false);

View File

@ -333,6 +333,7 @@ typedef struct settings
unsigned input_turbo_duty_cycle;
unsigned input_bind_timeout;
unsigned input_bind_hold;
unsigned input_menu_toggle_gamepad_combo;
unsigned input_keyboard_gamepad_mapping_type;

View File

@ -52,6 +52,7 @@ enum {
AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
AMOTION_EVENT_BUTTON_BACK = 1 << 3,
AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
AMOTION_EVENT_AXIS_VSCROLL = 9,
};
#endif
@ -65,7 +66,7 @@ enum {
#endif
/* Use this to enable/disable using the touch screen as mouse */
#define ENABLE_TOUCH_SCREEN_MOUSE 0
#define ENABLE_TOUCH_SCREEN_MOUSE 1
typedef struct
{
@ -121,7 +122,7 @@ typedef struct android_input
unsigned pointer_count;
int mouse_x_delta, mouse_y_delta;
float mouse_x_prev, mouse_y_prev;
int mouse_l, mouse_r, mouse_m;
int mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
int64_t quick_tap_time;
} android_input_t;
@ -557,7 +558,7 @@ static int16_t android_mouse_state(android_input_t *android, unsigned id)
break;
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
val = android->mouse_m;
break;
break;
case RETRO_DEVICE_ID_MOUSE_X:
val = android->mouse_x_delta;
android->mouse_x_delta = 0; /* flush delta after it has been read */
@ -566,6 +567,14 @@ static int16_t android_mouse_state(android_input_t *android, unsigned id)
val = android->mouse_y_delta; /* flush delta after it has been read */
android->mouse_y_delta = 0;
break;
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
val = android->mouse_wu;
android->mouse_wu = 0;
break;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
val = android->mouse_wd;
android->mouse_wd = 0;
break;
}
return val;
@ -674,9 +683,17 @@ static INLINE int android_input_poll_event_type_motion(
if (p_AMotionEvent_getButtonState)
{
btn = (int)AMotionEvent_getButtonState(event);
android->mouse_l = (btn & AMOTION_EVENT_BUTTON_PRIMARY);
android->mouse_r = (btn & AMOTION_EVENT_BUTTON_SECONDARY);
android->mouse_m = (btn & AMOTION_EVENT_BUTTON_TERTIARY);
btn = (int)AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, motion_ptr);
if (btn > 0)
android->mouse_wu = btn;
else if (btn < 0)
android->mouse_wd = btn;
}
else
{
@ -1386,7 +1403,8 @@ static int16_t android_input_state(void *data,
port, idx, id, binds[port]);
break;
case RETRO_DEVICE_MOUSE:
return android_mouse_state(android, id);
ret = android_mouse_state(android, id);
return ret;
case RETRO_DEVICE_LIGHTGUN:
return android_lightgun_device_state(android, id);
case RETRO_DEVICE_POINTER:

View File

@ -614,6 +614,11 @@ int menu_hash_get_help_ar_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");

View File

@ -765,6 +765,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Hide Unbound Core Input Descriptors")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,
@ -2459,6 +2461,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period when turbo-enabled buttons are toggled. Numbers are described in frames."

View File

@ -569,6 +569,11 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");

View File

@ -2299,6 +2299,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period of which turbo-enabled buttons toggle. Numbers are described in frames."

View File

@ -566,6 +566,11 @@ int menu_hash_get_help_cht_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay 比例.");

View File

@ -2291,6 +2291,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period of which turbo-enabled buttons toggle. Numbers are described in frames."

View File

@ -593,6 +593,11 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len)
"Anzahl der Sekunden, die gewartet werden soll, \n"
"bis zur nächsten Belegung gewechselt wird.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay-Skalierung.");
@ -864,7 +869,7 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len)
const char *lbl = settings ? settings->arrays.audio_resampler : NULL;
if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_SINC)))
strlcpy(s,
strlcpy(s,
"Windowed-SINC-Implementierung.", len);
else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC)))
strlcpy(s,

View File

@ -628,6 +628,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Hide Unbound Core Input Descriptors")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,
@ -2190,6 +2192,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period of which turbo-enabled buttons toggle. Numbers are described in frames."

View File

@ -713,6 +713,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Nascondi i descrittori di input di core non legati")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,

View File

@ -586,6 +586,11 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");

View File

@ -2443,6 +2443,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period of which turbo-enabled buttons toggle. Numbers are described in frames."

View File

@ -588,6 +588,11 @@ int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");
@ -858,7 +863,7 @@ int menu_hash_get_help_ko_enum(enum msg_hash_enums msg, char *s, size_t len)
strlcpy(s,
"Windowed SINC implementation.", len);
else if (string_is_equal(lbl, msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER_CC)))
strlcpy(s,
strlcpy(s,
"Convoluted Cosine implementation.", len);
else if (string_is_empty(s))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len);

View File

@ -493,6 +493,8 @@ MSG_HASH(MENU_ENUM_LABEL_INPUT_BIND_MODE,
"input_bind_mode")
MSG_HASH(MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT,
"input_bind_timeout")
MSG_HASH(MENU_ENUM_LABEL_INPUT_BIND_HOLD,
"input_bind_hold")
MSG_HASH(MENU_ENUM_LABEL_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"input_descriptor_hide_unbound")
MSG_HASH(MENU_ENUM_LABEL_INPUT_DESCRIPTOR_LABEL_SHOW,

View File

@ -628,6 +628,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Verbergen Niet-gemapte Core Input Descripties")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,
@ -2188,6 +2190,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period of which turbo-enabled buttons toggle. Numbers are described in frames."

View File

@ -618,6 +618,11 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len)
"Quantos segundos aguardar até prosseguir \n"
"para o próximo vínculo.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Escala da Transparência.");

View File

@ -610,6 +610,11 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");

View File

@ -777,6 +777,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Hide Unbound Core Input Descriptors")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,
@ -2515,6 +2517,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period when turbo-enabled buttons are toggled. Numbers are described in frames."

View File

@ -586,6 +586,11 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len)
"Amount of seconds to wait until proceeding \n"
"to the next bind.");
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
snprintf(s, len,
"Input bind hold time (in seconds). \n"
"Amount of seconds to hold an input to bind it.");
break;
case MENU_ENUM_LABEL_OVERLAY_SCALE:
snprintf(s, len,
"Overlay scale.");

View File

@ -707,6 +707,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
"Bind Default All")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
"Bind Hold")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND,
"Hide Unbound Core Input Descriptors")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_LABEL_SHOW,
@ -2327,6 +2329,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT,
"Amount of seconds to wait until proceeding to the next bind."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD,
"Amount of seconds to hold an input to bind it."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD,
"Describes the period when turbo-enabled buttons are toggled. Numbers are described in frames."

View File

@ -145,6 +145,7 @@ default_sublabel_macro(action_bind_sublabel_input_max_users, MENU_
default_sublabel_macro(action_bind_sublabel_input_poll_type_behavior, MENU_ENUM_SUBLABEL_INPUT_POLL_TYPE_BEHAVIOR)
default_sublabel_macro(action_bind_sublabel_input_all_users_control_menu, MENU_ENUM_SUBLABEL_INPUT_ALL_USERS_CONTROL_MENU)
default_sublabel_macro(action_bind_sublabel_input_bind_timeout, MENU_ENUM_SUBLABEL_INPUT_BIND_TIMEOUT)
default_sublabel_macro(action_bind_sublabel_input_bind_hold, MENU_ENUM_SUBLABEL_INPUT_BIND_HOLD)
default_sublabel_macro(action_bind_sublabel_audio_volume, MENU_ENUM_SUBLABEL_AUDIO_VOLUME)
default_sublabel_macro(action_bind_sublabel_audio_mixer_volume, MENU_ENUM_SUBLABEL_AUDIO_MIXER_VOLUME)
default_sublabel_macro(action_bind_sublabel_audio_sync, MENU_ENUM_SUBLABEL_AUDIO_SYNC)
@ -1485,6 +1486,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_bind_timeout);
break;
case MENU_ENUM_LABEL_INPUT_BIND_HOLD:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_bind_hold);
break;
case MENU_ENUM_LABEL_INPUT_AXIS_THRESHOLD:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_axis_threshold);
break;

View File

@ -6298,6 +6298,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
MENU_ENUM_LABEL_INPUT_AXIS_THRESHOLD, PARSE_ONLY_FLOAT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT, PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_BIND_HOLD, PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_TURBO_PERIOD, PARSE_ONLY_UINT, false);
ret = menu_displaylist_parse_settings_enum(menu, info,

View File

@ -4546,6 +4546,20 @@ static bool setting_append_list(
menu_settings_list_current_add_range(list, list_info, 1, 0, 1, true, false);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
CONFIG_UINT(
list, list_info,
&settings->uints.input_bind_hold,
MENU_ENUM_LABEL_INPUT_BIND_HOLD,
MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD,
input_bind_hold,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 1, 0, 1, true, false);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
CONFIG_UINT(
list, list_info,
&settings->uints.input_turbo_period,

View File

@ -51,10 +51,12 @@ struct menu_bind_axis_state
struct menu_bind_state
{
struct retro_keybind *target;
/* For keyboard binding. */
struct retro_keybind * output;
struct retro_keybind buffer;
rarch_timer_t timer_timeout;
rarch_timer_t timer_hold;
rarch_timer_t timer;
unsigned begin;
unsigned last;
unsigned user;
@ -71,11 +73,18 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb(
{
settings_t *settings = config_get_ptr();
menu_input_binds.target->key = (enum retro_key)code;
menu_input_binds.begin++;
menu_input_binds.target++;
/* store key in bind */
menu_input_binds.buffer.key = (enum retro_key)code;
rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout);
/* write out the bind */
*(menu_input_binds.output)=menu_input_binds.buffer;
/* next bind */
menu_input_binds.begin++;
menu_input_binds.output++;
menu_input_binds.buffer=*(menu_input_binds.output);
rarch_timer_begin_new_time(&menu_input_binds.timer_hold, settings->uints.input_bind_hold);
rarch_timer_begin_new_time(&menu_input_binds.timer_timeout, settings->uints.input_bind_timeout);
return (menu_input_binds.begin <= menu_input_binds.last);
}
@ -105,7 +114,8 @@ static int menu_input_key_bind_set_mode_common(
menu_input_binds.begin = bind_type;
menu_input_binds.last = bind_type;
menu_input_binds.target = keybind;
menu_input_binds.output = keybind;
menu_input_binds.buffer = *(menu_input_binds.output);
menu_input_binds.user = index_offset;
info.list = menu_stack;
@ -119,7 +129,8 @@ static int menu_input_key_bind_set_mode_common(
menu_displaylist_info_free(&info);
break;
case MENU_INPUT_BINDS_CTL_BIND_ALL:
menu_input_binds.target = &input_config_binds[index_offset][0];
menu_input_binds.output = &input_config_binds[index_offset][0];
menu_input_binds.buffer = *(menu_input_binds.output);
menu_input_binds.begin = MENU_SETTINGS_BIND_BEGIN;
menu_input_binds.last = MENU_SETTINGS_BIND_LAST;
@ -268,7 +279,8 @@ bool menu_input_key_bind_set_mode(
menu_input_key_bind_poll_bind_state(
&menu_input_binds, menu_bind_port, false);
rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout);
rarch_timer_begin_new_time(&menu_input_binds.timer_hold, settings->uints.input_bind_hold);
rarch_timer_begin_new_time(&menu_input_binds.timer_timeout, settings->uints.input_bind_timeout);
keys.userdata = menu;
keys.cb = menu_input_key_bind_custom_bind_keyboard_cb;
@ -280,6 +292,7 @@ bool menu_input_key_bind_set_mode(
static bool menu_input_key_bind_poll_find_trigger_pad(
struct menu_bind_state *state,
struct menu_bind_state *new_state,
struct retro_keybind * output,
unsigned p)
{
unsigned a, b, h;
@ -298,18 +311,18 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
switch ( b )
{
case RETRO_DEVICE_ID_MOUSE_LEFT:
case RETRO_DEVICE_ID_MOUSE_RIGHT:
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
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:
state->target->mbutton = b;
return true;
}
case RETRO_DEVICE_ID_MOUSE_LEFT:
case RETRO_DEVICE_ID_MOUSE_RIGHT:
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
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:
output->mbutton = b;
return true;
}
}
for (b = 0; b < MENU_MAX_BUTTONS; b++)
@ -319,8 +332,8 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
if (!iterate)
continue;
state->target->joykey = b;
state->target->joyaxis = AXIS_NONE;
output->joykey = b;
output->joyaxis = AXIS_NONE;
return true;
}
@ -338,9 +351,9 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
{
/* Take care of case where axis rests on +/- 0x7fff
* (e.g. 360 controller on Linux) */
state->target->joyaxis = n->axes[a] > 0
output->joyaxis = n->axes[a] > 0
? AXIS_POS(a) : AXIS_NEG(a);
state->target->joykey = NO_BTN;
output->joykey = NO_BTN;
/* Lock the current axis */
new_state->axis_state[p].locked_axes[a] =
@ -369,8 +382,8 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
if (sane_trigger)
{
state->target->joykey = HAT_MAP(h, sane_trigger);
state->target->joyaxis = AXIS_NONE;
output->joykey = HAT_MAP(h, sane_trigger);
output->joyaxis = AXIS_NONE;
return true;
}
}
@ -378,9 +391,119 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
return false;
}
static bool menu_input_key_bind_poll_find_hold_pad(
struct menu_bind_state *new_state,
struct retro_keybind * output,
unsigned p)
{
unsigned a, b, h;
const struct menu_bind_state_port *n = (const struct menu_bind_state_port*)
&new_state->state[p];
for (b = 0; b < MENU_MAX_MBUTTONS; b++)
{
bool iterate = n->mbuttons[b];
if (!iterate)
continue;
switch ( b )
{
case RETRO_DEVICE_ID_MOUSE_LEFT:
case RETRO_DEVICE_ID_MOUSE_RIGHT:
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
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:
output->mbutton = b;
return true;
}
}
for (b = 0; b < MENU_MAX_BUTTONS; b++)
{
bool iterate = n->buttons[b];
if (!iterate)
continue;
output->joykey = b;
output->joyaxis = AXIS_NONE;
return true;
}
/* Axes are a bit tricky ... */
for (a = 0; a < MENU_MAX_AXES; a++)
{
if (abs(n->axes[a]) >= 20000)
{
/* Take care of case where axis rests on +/- 0x7fff
* (e.g. 360 controller on Linux) */
output->joyaxis = n->axes[a] > 0
? AXIS_POS(a) : AXIS_NEG(a);
output->joykey = NO_BTN;
return true;
}
}
for (h = 0; h < MENU_MAX_HATS; h++)
{
uint16_t trigged = n->hats[h];
uint16_t sane_trigger = 0;
if (trigged & HAT_UP_MASK)
sane_trigger = HAT_UP_MASK;
else if (trigged & HAT_DOWN_MASK)
sane_trigger = HAT_DOWN_MASK;
else if (trigged & HAT_LEFT_MASK)
sane_trigger = HAT_LEFT_MASK;
else if (trigged & HAT_RIGHT_MASK)
sane_trigger = HAT_RIGHT_MASK;
if (sane_trigger)
{
output->joykey = HAT_MAP(h, sane_trigger);
output->joyaxis = AXIS_NONE;
return true;
}
}
return false;
}
static bool menu_input_key_bind_poll_find_hold(
struct menu_bind_state *new_state,
struct retro_keybind * output
)
{
unsigned i;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
if (!new_state)
return false;
for (i = 0; i < max_users; i++)
{
if (!menu_input_key_bind_poll_find_hold_pad( new_state, output, i))
continue;
return true;
}
return false;
}
static bool menu_input_key_bind_poll_find_trigger(
struct menu_bind_state *state,
struct menu_bind_state *new_state)
struct menu_bind_state *new_state,
struct retro_keybind * output
)
{
unsigned i;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
@ -390,9 +513,8 @@ static bool menu_input_key_bind_poll_find_trigger(
for (i = 0; i < max_users; i++)
{
if (!menu_input_key_bind_poll_find_trigger_pad(
state, new_state, i))
continue;
if (!menu_input_key_bind_poll_find_trigger_pad( state, new_state, output, i))
continue;
return true;
}
@ -413,32 +535,35 @@ bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim)
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind)
{
struct menu_bind_state binds;
bool timed_out = false;
settings_t *settings = config_get_ptr();
rarch_timer_tick(&menu_input_binds.timer);
settings_t * settings = config_get_ptr();
if (!bind)
return false;
if (rarch_timer_has_expired(&menu_input_binds.timer))
snprintf( bind->s, bind->len,
"[%s]\npress keyboard, mouse or joypad\n(timeout %d %s)",
input_config_bind_map_get_desc(
menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN ),
rarch_timer_get_timeout( &menu_input_binds.timer_timeout ),
msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SECONDS ) );
/*tick main timers*/
rarch_timer_tick( &menu_input_binds.timer_timeout );
rarch_timer_tick( &menu_input_binds.timer_hold );
if (rarch_timer_has_expired(&menu_input_binds.timer_timeout))
{
input_driver_keyboard_mapping_set_block(false);
/*skip to next bind*/
menu_input_binds.begin++;
menu_input_binds.target++;
rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout);
menu_input_binds.output++;
rarch_timer_begin_new_time(&menu_input_binds.timer_hold, settings->uints.input_bind_hold);
rarch_timer_begin_new_time(&menu_input_binds.timer_timeout, settings->uints.input_bind_timeout);
timed_out = true;
}
snprintf(bind->s, bind->len,
"[%s]\npress keyboard, mouse or joypad\n(timeout %d %s)",
input_config_bind_map_get_desc(
menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN),
rarch_timer_get_timeout(&menu_input_binds.timer),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS));
/* binds.begin is updated in keyboard_press callback. */
if (menu_input_binds.begin > menu_input_binds.last)
{
@ -452,31 +577,81 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind)
return true;
}
binds = menu_input_binds;
input_driver_keyboard_mapping_set_block(true);
menu_input_key_bind_poll_bind_state(&binds, menu_bind_port, timed_out);
if ((binds.skip && !menu_input_binds.skip) ||
menu_input_key_bind_poll_find_trigger(&menu_input_binds, &binds))
{
input_driver_keyboard_mapping_set_block(false);
bool complete = false;
struct menu_bind_state binds;
binds = menu_input_binds;
/* Avoid new binds triggering things right away. */
input_driver_set_flushing_input();
input_driver_keyboard_mapping_set_block( true );
menu_input_key_bind_poll_bind_state( &binds, menu_bind_port, timed_out );
binds.begin++;
#ifdef ANDROID
if (binds.begin > binds.last)
/*keep resetting bind during the hold period, or we'll potentially bind joystick and mouse, etc.*/
binds.buffer = *( binds.output );
if ( menu_input_key_bind_poll_find_hold( &binds, &binds.buffer ) )
{
input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL);
return true;
/*inhibit timeout*/
rarch_timer_begin_new_time( &binds.timer_timeout, settings->uints.input_bind_timeout );
/*run hold timer*/
rarch_timer_tick( &binds.timer_hold );
snprintf( bind->s, bind->len,
"[%s]\npress keyboard, mouse or joypad\nand hold ...",
input_config_bind_map_get_desc(
menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN ) );
/*hold complete?*/
if ( rarch_timer_has_expired( &binds.timer_hold ) )
{
complete = true;
}
}
else
{
/*reset hold countdown*/
rarch_timer_begin_new_time( &binds.timer_hold, settings->uints.input_bind_hold );
}
binds.target++;
rarch_timer_begin_new_time(&binds.timer, settings->uints.input_bind_timeout);
#else
if ( ( binds.skip && !menu_input_binds.skip ) ||
menu_input_key_bind_poll_find_trigger( &menu_input_binds, &binds, &( binds.buffer ) ) )
{
complete = true;
}
#endif
if ( complete )
{
/*update bind*/
*( binds.output ) = binds.buffer;
input_driver_keyboard_mapping_set_block( false );
/* Avoid new binds triggering things right away. */
input_driver_set_flushing_input();
binds.begin++;
if ( binds.begin > binds.last )
{
input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL );
return true;
}
/*next bind*/
binds.output++;
binds.buffer = *( binds.output );
rarch_timer_begin_new_time( &binds.timer_hold, settings->uints.input_bind_hold );
rarch_timer_begin_new_time( &binds.timer_timeout, settings->uints.input_bind_timeout );
}
menu_input_binds = binds;
}
menu_input_binds = binds;
return false;
}

View File

@ -664,6 +664,7 @@ enum msg_hash_enums
MENU_LABEL(INPUT_DESCRIPTOR_HIDE_UNBOUND),
MENU_LABEL(INPUT_AXIS_THRESHOLD),
MENU_LABEL(INPUT_BIND_TIMEOUT),
MENU_LABEL(INPUT_BIND_HOLD),
MENU_LABEL(INPUT_REMAP_BINDS_ENABLE),
MENU_LABEL(MENU_INPUT_SWAP_OK_CANCEL),
MENU_LABEL(INPUT_OVERLAY_ENABLE),

View File

@ -125,14 +125,14 @@ void rarch_timer_tick(rarch_timer_t *timer)
if (!timer)
return;
timer->current = cpu_features_get_time_usec();
timer->timeout = (timer->timeout_end - timer->current) / 1000000;
timer->timeout_us = (timer->timeout_end - timer->current);
}
int rarch_timer_get_timeout(rarch_timer_t *timer)
{
if (!timer)
return 0;
return (int)timer->timeout;
return (int)timer->timeout_us / 1000000;
}
bool rarch_timer_is_running(rarch_timer_t *timer)
@ -144,7 +144,7 @@ bool rarch_timer_is_running(rarch_timer_t *timer)
bool rarch_timer_has_expired(rarch_timer_t *timer)
{
if (!timer || timer->timeout <= 0)
if (!timer || timer->timeout_us <= 0)
return true;
return false;
}
@ -162,7 +162,18 @@ void rarch_timer_begin_new_time(rarch_timer_t *timer, uint64_t sec)
{
if (!timer)
return;
timer->timeout_end = cpu_features_get_time_usec() + sec * 1000000;
timer->timeout_us = sec * 1000000;
timer->current = cpu_features_get_time_usec();
timer->timeout_end = timer->current + timer->timeout_us;
}
void rarch_timer_begin_new_time_us(rarch_timer_t *timer, uint64_t usec)
{
if (!timer)
return;
timer->timeout_us = usec;
timer->current = cpu_features_get_time_usec();
timer->timeout_end = timer->current + timer->timeout_us;
}
void rarch_timer_begin(rarch_timer_t *timer, uint64_t sec)

View File

@ -33,7 +33,7 @@ RETRO_BEGIN_DECLS
typedef struct rarch_timer
{
int64_t current;
int64_t timeout;
int64_t timeout_us;
int64_t timeout_end;
bool timer_begin;
bool timer_end;
@ -99,6 +99,8 @@ void rarch_timer_begin(rarch_timer_t *timer, uint64_t ms);
void rarch_timer_begin_new_time(rarch_timer_t *timer, uint64_t sec);
void rarch_timer_begin_new_time_us(rarch_timer_t *timer, uint64_t usec);
void rarch_timer_end(rarch_timer_t *timer);
int rarch_timer_get_timeout(rarch_timer_t *timer);

View File

@ -3209,7 +3209,7 @@ static enum runloop_state runloop_check_state(
{
/* rarch_timer_tick */
timer.current = cpu_features_get_time_usec();
timer.timeout = (timer.timeout_end - timer.current) / 1000;
timer.timeout_us = (timer.timeout_end - timer.current);
if (!timer.timer_end && rarch_timer_has_expired(&timer))
{