mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
input: Aim From Analog Stick, for a port's lightgun or pointer
A lightgun or a pointer was aimed by a mouse or by touch, so there were as many of them as there were mice (issue #13425). New setting in a port's controls, "Aim From Analog Stick" (input_playerN_aim_stick: OFF by default, Left Analog, Right Analog). With it on, where the port's stick is held is where its lightgun and its pointer point, the stick's centre being the screen's; the gun is never off the screen, and its trigger is the pointer's press. The gun's buttons are bound as they always were. The stick is read as it comes, with no deadzone, and is still given to the core as a stick. Lightguns read as movements (the old X and Y) and the mouse are not covered. The frontend harness gains a lane for it.
This commit is contained in:
1 parent
adf3cc063d
commit
d307939703
12 files changed
+251
No files matched your search
@@ -6013,6 +6013,7 @@ void config_set_defaults(settings_t *target)
|
||||
input_config_set_device((unsigned)i, RETRO_DEVICE_JOYPAD);
|
||||
settings->uints.input_mouse_index[i] = (unsigned)i;
|
||||
settings->uints.input_keyboard_index[i] = 0;
|
||||
settings->uints.input_aim_stick[i] = INPUT_AIM_STICK_NONE;
|
||||
}
|
||||
|
||||
custom_vp->dims = 0;
|
||||
@@ -7018,6 +7019,11 @@ static bool config_load_file(const char *path, settings_t *settings)
|
||||
strlcpy_lit(prefix + _len, "_keyboard_index", sizeof(prefix) - _len);
|
||||
CONFIG_GET_INT_BASE(conf, settings, uints.input_keyboard_index[i], prefix);
|
||||
|
||||
strlcpy_lit(prefix + _len, "_aim_stick", sizeof(prefix) - _len);
|
||||
CONFIG_GET_INT_BASE(conf, settings, uints.input_aim_stick[i], prefix);
|
||||
if (settings->uints.input_aim_stick[i] >= INPUT_AIM_STICK_LAST)
|
||||
settings->uints.input_aim_stick[i] = INPUT_AIM_STICK_NONE;
|
||||
|
||||
strlcpy_lit(prefix + _len, "_joypad_index", sizeof(prefix) - _len);
|
||||
CONFIG_GET_INT_BASE(conf, settings, uints.input_joypad_index[i], prefix);
|
||||
|
||||
@@ -9522,6 +9528,13 @@ bool config_save_file(const char *path)
|
||||
else
|
||||
config_unset(conf, cfg);
|
||||
|
||||
strlcpy_lit(cfg + _len, "_aim_stick", sizeof(cfg) - _len);
|
||||
if ( !minimal
|
||||
|| settings->uints.input_aim_stick[i] != defaults->uints.input_aim_stick[i])
|
||||
config_set_int(conf, cfg, settings->uints.input_aim_stick[i]);
|
||||
else
|
||||
config_unset(conf, cfg);
|
||||
|
||||
/* What the user configured, which is not what the setting holds
|
||||
* while a driver restart has put controllers back on their
|
||||
* ports. */
|
||||
@@ -10126,6 +10139,14 @@ int8_t config_save_overrides(enum override_type type,
|
||||
RARCH_DBG("[Override] %s = \"%u\"\n", cfg, overrides->uints.input_keyboard_index[i]);
|
||||
}
|
||||
|
||||
if (settings->uints.input_aim_stick[i]
|
||||
!= overrides->uints.input_aim_stick[i])
|
||||
{
|
||||
strlcpy_lit(cfg + _len, "_aim_stick", sizeof(cfg) - _len);
|
||||
config_set_int(conf, cfg, overrides->uints.input_aim_stick[i]);
|
||||
RARCH_DBG("[Override] %s = \"%u\"\n", cfg, overrides->uints.input_aim_stick[i]);
|
||||
}
|
||||
|
||||
/* The live value is what the user configured, not a port a
|
||||
* driver restart handed back. */
|
||||
if (settings->uints.input_joypad_index[i]
|
||||
|
||||
@@ -161,6 +161,8 @@ typedef struct settings
|
||||
* keyboards apart: 0 for all of them as one (the default), N
|
||||
* for the Nth the driver lists. */
|
||||
unsigned input_keyboard_index[MAX_USERS];
|
||||
/* 0 off, 1 the left stick, 2 the right: enum input_aim_stick */
|
||||
unsigned input_aim_stick[MAX_USERS];
|
||||
|
||||
unsigned input_libretro_device[MAX_USERS];
|
||||
unsigned input_analog_dpad_mode[MAX_USERS];
|
||||
|
||||
@@ -231,6 +231,16 @@ enum input_combo_type
|
||||
INPUT_COMBO_LAST
|
||||
};
|
||||
|
||||
/* input_playerN_aim_stick: the stick that aims a port's lightgun or
|
||||
* pointer, if one does. */
|
||||
enum input_aim_stick
|
||||
{
|
||||
INPUT_AIM_STICK_NONE = 0,
|
||||
INPUT_AIM_STICK_LEFT,
|
||||
INPUT_AIM_STICK_RIGHT,
|
||||
INPUT_AIM_STICK_LAST
|
||||
};
|
||||
|
||||
/* input_rotation: 0 to 3 are quarter turns, as Video Rotation counts
|
||||
* them; this one follows that setting. */
|
||||
#define INPUT_ROTATION_AUTO 4
|
||||
|
||||
@@ -3130,6 +3130,59 @@ static int16_t input_state_internal(
|
||||
kb_mapping_blocked,
|
||||
mapped_port, device, idx, id);
|
||||
|
||||
/* "Aim From Analog Stick": where the port's stick is held is
|
||||
* where its lightgun or pointer points, the stick's centre
|
||||
* being the screen's. The stick is read as it comes: a deadzone
|
||||
* would make the centre of the screen a place it snaps to. */
|
||||
if ( settings->uints.input_aim_stick[mapped_port]
|
||||
&& ( device == RETRO_DEVICE_LIGHTGUN
|
||||
|| (device == RETRO_DEVICE_POINTER && idx == 0))
|
||||
&& input_st->libretro_input_binds[mapped_port])
|
||||
{
|
||||
int axis = -1;
|
||||
if (device == RETRO_DEVICE_LIGHTGUN)
|
||||
{
|
||||
if (id == RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X)
|
||||
axis = RETRO_DEVICE_ID_ANALOG_X;
|
||||
else if (id == RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y)
|
||||
axis = RETRO_DEVICE_ID_ANALOG_Y;
|
||||
else if (id == RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN)
|
||||
ret = 0; /* a stick is never off the screen */
|
||||
}
|
||||
else if (id == RETRO_DEVICE_ID_POINTER_X)
|
||||
axis = RETRO_DEVICE_ID_ANALOG_X;
|
||||
else if (id == RETRO_DEVICE_ID_POINTER_Y)
|
||||
axis = RETRO_DEVICE_ID_ANALOG_Y;
|
||||
else if (id == RETRO_DEVICE_ID_POINTER_PRESSED && !ret)
|
||||
/* the gun's trigger is the pointer's press */
|
||||
ret = input_state_wrap(
|
||||
input_st->current_driver,
|
||||
input_st->current_data,
|
||||
joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
(*input_st->libretro_input_binds),
|
||||
kb_mapping_blocked,
|
||||
mapped_port, RETRO_DEVICE_LIGHTGUN, 0,
|
||||
RETRO_DEVICE_ID_LIGHTGUN_TRIGGER);
|
||||
|
||||
if (axis >= 0)
|
||||
{
|
||||
unsigned stick =
|
||||
(settings->uints.input_aim_stick[mapped_port] == INPUT_AIM_STICK_RIGHT)
|
||||
? RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
|
||||
ret = 0;
|
||||
if (sec_joypad)
|
||||
ret = input_joypad_analog_axis(ANALOG_DPAD_NONE, 0.0f, 1.0f,
|
||||
sec_joypad, &joypad_info, stick, (unsigned)axis,
|
||||
(*input_st->libretro_input_binds[mapped_port]));
|
||||
if (joypad && !ret)
|
||||
ret = input_joypad_analog_axis(ANALOG_DPAD_NONE, 0.0f, 1.0f,
|
||||
joypad, &joypad_info, stick, (unsigned)axis,
|
||||
(*input_st->libretro_input_binds[mapped_port]));
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore analog sticks when using Analog to Digital */
|
||||
if ( (device == RETRO_DEVICE_ANALOG)
|
||||
&& (input_analog_dpad_mode != ANALOG_DPAD_NONE))
|
||||
|
||||
@@ -1464,6 +1464,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX,
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX_STR
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK,
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK_STR
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
|
||||
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX_STR
|
||||
|
||||
@@ -12439,6 +12439,14 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_MOUSE_INDEX,
|
||||
"The physical mouse as recognized by RetroArch. Where the input driver can tell mice apart, a mouse chosen here is remembered by what it is, and stays this port's when mice are plugged in or out."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_AIM_STICK,
|
||||
"Aim From Analog Stick"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_AIM_STICK,
|
||||
"Lets an analog stick aim this port's lightgun or pointer: where the stick is held is where it points on the screen, with the centre of the stick at the centre. Several players can then each aim without a mouse each. The gun's buttons are bound below as usual."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_INDEX,
|
||||
"Keyboard Index"
|
||||
|
||||
@@ -370,6 +370,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_device_type, ME
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_device_index, MENU_ENUM_SUBLABEL_INPUT_DEVICE_INDEX)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_mouse_index, MENU_ENUM_SUBLABEL_INPUT_MOUSE_INDEX)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_keyboard_index, MENU_ENUM_SUBLABEL_INPUT_KEYBOARD_INDEX)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_aim_stick, MENU_ENUM_SUBLABEL_INPUT_AIM_STICK)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_adc_type, MENU_ENUM_SUBLABEL_INPUT_ADC_TYPE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_device_reservation_type, MENU_ENUM_SUBLABEL_INPUT_DEVICE_RESERVATION_TYPE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_device_reserved_device_name, MENU_ENUM_SUBLABEL_INPUT_DEVICE_RESERVED_DEVICE_NAME)
|
||||
@@ -3906,6 +3907,10 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX,
|
||||
action_bind_sublabel_input_keyboard_index
|
||||
},
|
||||
{
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK,
|
||||
action_bind_sublabel_input_aim_stick
|
||||
},
|
||||
{
|
||||
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
|
||||
action_bind_sublabel_input_device_index
|
||||
|
||||
@@ -628,6 +628,9 @@ static int action_get_title_dropdown_item(
|
||||
else if ((enum_idx >= MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX) &&
|
||||
(enum_idx <= MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX_LAST))
|
||||
enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_INDEX;
|
||||
else if ((enum_idx >= MENU_ENUM_LABEL_INPUT_AIM_STICK) &&
|
||||
(enum_idx <= MENU_ENUM_LABEL_INPUT_AIM_STICK_LAST))
|
||||
enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_AIM_STICK;
|
||||
else if ((enum_idx >= MENU_ENUM_LABEL_INPUT_REMAP_PORT) &&
|
||||
(enum_idx <= MENU_ENUM_LABEL_INPUT_REMAP_PORT_LAST))
|
||||
enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_REMAP_PORT;
|
||||
|
||||
@@ -7793,6 +7793,24 @@ static size_t setting_get_string_representation_retropad_bind(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t setting_get_string_representation_input_aim_stick(
|
||||
rarch_setting_t *setting, char *s, size_t len)
|
||||
{
|
||||
enum msg_hash_enums e = MENU_ENUM_LABEL_VALUE_OFF;
|
||||
if (!setting)
|
||||
return 0;
|
||||
switch (*setting->value.target.unsigned_integer)
|
||||
{
|
||||
case INPUT_AIM_STICK_LEFT:
|
||||
e = MENU_ENUM_LABEL_VALUE_LEFT_ANALOG;
|
||||
break;
|
||||
case INPUT_AIM_STICK_RIGHT:
|
||||
e = MENU_ENUM_LABEL_VALUE_RIGHT_ANALOG;
|
||||
break;
|
||||
}
|
||||
return strlcpy(s, msg_hash_to_str(e), len);
|
||||
}
|
||||
|
||||
static size_t setting_get_string_representation_input_rotation(
|
||||
rarch_setting_t *setting, char *s, size_t len)
|
||||
{
|
||||
@@ -11495,6 +11513,7 @@ static bool setting_append_list_input_player_options(
|
||||
char device_reserved_device[64];
|
||||
char mouse_index[64];
|
||||
char keyboard_index[64];
|
||||
char aim_stick[64];
|
||||
char bind_all[64];
|
||||
char bind_all_save_autoconfig[64];
|
||||
char bind_defaults[64];
|
||||
@@ -11522,6 +11541,9 @@ static bool setting_append_list_input_player_options(
|
||||
snprintf(keyboard_index, sizeof(keyboard_index),
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX_STR,
|
||||
user + 1);
|
||||
snprintf(aim_stick, sizeof(aim_stick),
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK_STR,
|
||||
user + 1);
|
||||
snprintf(bind_all, sizeof(bind_all),
|
||||
MENU_ENUM_LABEL_INPUT_BIND_ALL_INDEX_STR,
|
||||
user + 1);
|
||||
@@ -11647,6 +11669,25 @@ static bool setting_append_list_input_player_options(
|
||||
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
|
||||
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE + user));
|
||||
|
||||
CONFIG_UINT_ALT(
|
||||
list, list_info,
|
||||
&settings->uints.input_aim_stick[user],
|
||||
aim_stick,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_AIM_STICK),
|
||||
INPUT_AIM_STICK_NONE,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].index = user + 1;
|
||||
(*list)[list_info->index - 1].index_offset = user;
|
||||
SETTINGS_ACTION_SET(ok, &(*list)[list_info->index - 1], &setting_action_ok_uint)
|
||||
SETTINGS_ACTION_SET(repr, &(*list)[list_info->index - 1], &setting_get_string_representation_input_aim_stick)
|
||||
menu_settings_list_current_add_range(list, list_info, 0, INPUT_AIM_STICK_LAST - 1, 1.0, true, true);
|
||||
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
|
||||
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_AIM_STICK + user));
|
||||
|
||||
CONFIG_UINT_ALT(
|
||||
list, list_info,
|
||||
&settings->uints.input_device_reservation_type[user],
|
||||
|
||||
@@ -2163,6 +2163,8 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_INPUT_MOUSE_INDEX_LAST = MENU_ENUM_LABEL_INPUT_MOUSE_INDEX + MAX_USERS,
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX,
|
||||
MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX_LAST = MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX + MAX_USERS,
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK,
|
||||
MENU_ENUM_LABEL_INPUT_AIM_STICK_LAST = MENU_ENUM_LABEL_INPUT_AIM_STICK + MAX_USERS,
|
||||
MENU_ENUM_LABEL_INPUT_STYLUS_ENABLE,
|
||||
MENU_ENUM_LABEL_INPUT_STYLUS_REQUIRE_CONTACT_FOR_CLICK,
|
||||
MENU_ENUM_LABEL_INPUT_STYLUS_HOVER_MOVES_POINTER,
|
||||
@@ -2696,6 +2698,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_INDEX,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_AIM_STICK,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_INDEX_ALL,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_INDEX_ABSENT,
|
||||
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
|
||||
@@ -2716,6 +2719,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_HELP_INPUT_DEVICE_RESERVATION_TYPE,
|
||||
MENU_ENUM_SUBLABEL_INPUT_MOUSE_INDEX,
|
||||
MENU_ENUM_SUBLABEL_INPUT_KEYBOARD_INDEX,
|
||||
MENU_ENUM_SUBLABEL_INPUT_AIM_STICK,
|
||||
MENU_ENUM_SUBLABEL_INPUT_STYLUS_ENABLE,
|
||||
MENU_ENUM_SUBLABEL_INPUT_STYLUS_REQUIRE_CONTACT_FOR_CLICK,
|
||||
MENU_ENUM_SUBLABEL_INPUT_STYLUS_HOVER_MOVES_POINTER,
|
||||
|
||||
@@ -366,6 +366,7 @@
|
||||
#define MENU_ENUM_LABEL_INPUT_DEVICE_RESERVATION_TYPE_STR "input_device_reservation_type_p%u"
|
||||
#define MENU_ENUM_LABEL_INPUT_MOUSE_INDEX_STR "input_player%u_mouse_index"
|
||||
#define MENU_ENUM_LABEL_INPUT_KEYBOARD_INDEX_STR "input_player%u_keyboard_index"
|
||||
#define MENU_ENUM_LABEL_INPUT_AIM_STICK_STR "input_player%u_aim_stick"
|
||||
#define MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX_STR "input_player%u_joypad_index"
|
||||
#define MENU_ENUM_LABEL_INPUT_BIND_ALL_INDEX_STR "input_player%u_bind_all"
|
||||
#define MENU_ENUM_LABEL_INPUT_SAVE_AUTOCONFIG_INDEX_STR "input_player%u_bind_all_save_autoconfig"
|
||||
|
||||
@@ -2415,6 +2415,104 @@ static void lane_menu_combo_gate(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Aim From Analog Stick: a port's stick is where its lightgun or
|
||||
* pointer points. */
|
||||
static void lane_aim_stick(void)
|
||||
{
|
||||
#if defined(HAVE_TEST_DRIVERS) && !defined(_WIN32)
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const input_device_driver_t *joypad_real = input_st->primary_joypad;
|
||||
struct retro_keybind saved_auto[8];
|
||||
unsigned had = failures;
|
||||
unsigned i;
|
||||
int gx, gy, off, px, py, lx;
|
||||
#define AIM_READ() do { \
|
||||
run_loop_frames(1); \
|
||||
gx = input_driver_state_wrapper(0, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X); \
|
||||
gy = input_driver_state_wrapper(0, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y); \
|
||||
off = input_driver_state_wrapper(0, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN); \
|
||||
px = input_driver_state_wrapper(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); \
|
||||
py = input_driver_state_wrapper(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); \
|
||||
lx = input_driver_state_wrapper(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X); \
|
||||
} while (0)
|
||||
|
||||
if (!joypad_real)
|
||||
{
|
||||
CHECK(false, "aim stick: no joypad driver");
|
||||
return;
|
||||
}
|
||||
syn_joypad = *joypad_real;
|
||||
syn_joypad.button = syn_button;
|
||||
syn_joypad.axis = syn_axis;
|
||||
syn_joypad.state = syn_state;
|
||||
syn_joypad.get_buttons = syn_get_buttons;
|
||||
input_st->primary_joypad = &syn_joypad;
|
||||
syn_hat = 0;
|
||||
syn_buttons = 0;
|
||||
memset(syn_axes, 0, sizeof(syn_axes));
|
||||
/* the sticks on axes 0-3 */
|
||||
memcpy(saved_auto, &input_autoconf_binds[0][RARCH_ANALOG_LEFT_X_PLUS],
|
||||
sizeof(saved_auto));
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
input_autoconf_binds[0][RARCH_ANALOG_LEFT_X_PLUS + 2 * i].joyaxis = AXIS_POS(i);
|
||||
input_autoconf_binds[0][RARCH_ANALOG_LEFT_X_PLUS + 2 * i + 1].joyaxis = AXIS_NEG(i);
|
||||
}
|
||||
fast_forward(true);
|
||||
/* the left stick up and left, the right stick right and down */
|
||||
syn_axes[0] = -30000;
|
||||
syn_axes[1] = -12000;
|
||||
syn_axes[2] = 10000;
|
||||
syn_axes[3] = 20000;
|
||||
|
||||
/* off, as before: the stick is not the gun */
|
||||
settings->uints.input_aim_stick[0] = INPUT_AIM_STICK_NONE;
|
||||
AIM_READ();
|
||||
CHECK(gx != 10000 && px != 10000 && lx == 10000,
|
||||
"aim stick: off, the stick shows up as the lightgun or the pointer");
|
||||
|
||||
/* the right stick aims */
|
||||
settings->uints.input_aim_stick[0] = INPUT_AIM_STICK_RIGHT;
|
||||
AIM_READ();
|
||||
if (gx != 10000 || gy != 20000 || off || px != 10000 || py != 20000)
|
||||
printf("[info] aim stick: gun %d %d offscreen %d, pointer %d %d\n",
|
||||
gx, gy, off, px, py);
|
||||
CHECK(gx == 10000 && gy == 20000 && !off,
|
||||
"aim stick: the lightgun is not where the right stick is held");
|
||||
CHECK(px == 10000 && py == 20000,
|
||||
"aim stick: the pointer is not where the right stick is held");
|
||||
CHECK(lx == 10000, "aim stick: the stick itself is no longer read as a stick");
|
||||
|
||||
/* the left stick aims */
|
||||
settings->uints.input_aim_stick[0] = INPUT_AIM_STICK_LEFT;
|
||||
AIM_READ();
|
||||
CHECK(gx == -30000 && gy == -12000 && px == -30000 && py == -12000,
|
||||
"aim stick: the lightgun or pointer is not where the left stick is held");
|
||||
|
||||
/* another port's setting is its own */
|
||||
settings->uints.input_aim_stick[0] = INPUT_AIM_STICK_NONE;
|
||||
settings->uints.input_aim_stick[1] = INPUT_AIM_STICK_RIGHT;
|
||||
AIM_READ();
|
||||
CHECK(gx != 10000, "aim stick: the second port's setting aimed the first port's gun");
|
||||
settings->uints.input_aim_stick[1] = INPUT_AIM_STICK_NONE;
|
||||
|
||||
memset(syn_axes, 0, sizeof(syn_axes));
|
||||
fast_forward(false);
|
||||
run_loop_frames(3);
|
||||
memcpy(&input_autoconf_binds[0][RARCH_ANALOG_LEFT_X_PLUS], saved_auto,
|
||||
sizeof(saved_auto));
|
||||
input_st->primary_joypad = joypad_real;
|
||||
#undef AIM_READ
|
||||
if (failures == had)
|
||||
printf("[pass] aim stick: off, the stick is only a stick; on, the"
|
||||
" chosen stick is where the port's lightgun and pointer"
|
||||
" point, and is still read as a stick\n");
|
||||
#else
|
||||
printf("[skip] aim stick: needs the test drivers\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* First-press port assignment: with the setting on no user has a core
|
||||
* port until a button is pressed on its controller. */
|
||||
static void lane_first_press(void)
|
||||
@@ -3333,6 +3431,7 @@ int main(int argc, char *argv[])
|
||||
lane_network_retropad();
|
||||
lane_pointer_capture();
|
||||
lane_menu_combo_gate();
|
||||
lane_aim_stick();
|
||||
lane_core_view();
|
||||
lane_key_events();
|
||||
/* last: these restart the drivers */
|
||||
|
||||
Reference in new issue
Block a user