Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udev and SDL Sensor and Touchpad #16188

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5428652
Added udev sensor support
oshaboy Jan 31, 2024
606742b
Fixed segfault and added hotplug support.
oshaboy Jan 31, 2024
7775239
Preliminary SDL Gyro Support
oshaboy Feb 1, 2024
ebe99ab
buncha stuff
oshaboy Feb 2, 2024
75b9de3
Comments and UDEV_TOUCH_SUPPORT flag.
oshaboy Feb 2, 2024
5fcea9b
Remove C++ style comments
oshaboy Feb 2, 2024
0277283
Update sdl_input.c
oshaboy Feb 2, 2024
5113a52
Removed silly printf hack and used proper facilities.
oshaboy Feb 2, 2024
7dc3bdb
Menu Stuff
oshaboy Feb 3, 2024
7d3fcc1
Merge branch 'libretro:master' into linux_sensor
oshaboy Feb 3, 2024
6fdfa1c
Merge branch 'linux_sensor' of https://github.com/oshaboy/RetroArch i…
oshaboy Feb 3, 2024
91613a4
I forgot a few files.
oshaboy Feb 3, 2024
ac21e7d
Moved sensitivity adjustment to some other function
oshaboy Feb 3, 2024
17a87f1
Various
oshaboy Feb 3, 2024
809d53f
Segfault fix and macro renaming
oshaboy Feb 3, 2024
1a30370
Now SDL Sensor gives names.
oshaboy Feb 5, 2024
6c7f783
Update sdl_input.c
oshaboy Feb 5, 2024
adcb02d
Update sdl_input.c
oshaboy Feb 5, 2024
cafaeff
Update sdl_input.c
oshaboy Feb 5, 2024
2ab1ef5
Mostly menu stuff for sensors
oshaboy Feb 21, 2024
c218c60
Merge branch 'master' into linux_sensor
oshaboy Feb 22, 2024
9d9e388
Messed up the merge
oshaboy Feb 22, 2024
cbb2b64
typo
oshaboy Feb 22, 2024
6a91a2c
Update configuration.c
oshaboy Apr 15, 2024
aef3009
Gave up on menu settings
oshaboy Apr 22, 2024
19f47d2
Merge branch 'master' into linux_sensor
oshaboy Apr 22, 2024
a4c6880
I commented out the wrong thing
oshaboy Apr 22, 2024
a0887a1
Merge branch 'linux_sensor' of https://github.com/oshaboy/RetroArch i…
oshaboy Apr 22, 2024
db24c1e
Made sensor remapping work for all drivers.
oshaboy May 30, 2024
0da83e8
C89 is bleh.
oshaboy May 30, 2024
9e959cb
Typo
oshaboy Aug 25, 2024
a1ebece
Merge branch 'master' into linux_sensor
oshaboy Aug 26, 2024
0a926bf
Messed Up the merge conflict
oshaboy Aug 26, 2024
034a8aa
Update net_retropad_core.c
oshaboy Aug 26, 2024
31bf40d
Merge branch 'master' into linux_sensor
oshaboy Sep 11, 2024
a34c408
I accidentally the semicolon
oshaboy Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,9 @@
#define DEFAULT_AXIS_THRESHOLD 0.5f
#define DEFAULT_ANALOG_DEADZONE 0.0f
#define DEFAULT_ANALOG_SENSITIVITY 1.0f
#define DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY 1.0f
#define DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY 1.0f


/* Describes speed of which turbo-enabled buttons toggle. */
#define DEFAULT_TURBO_PERIOD 6
Expand Down
95 changes: 92 additions & 3 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,8 @@ static struct config_float_setting *populate_settings_float(
SETTING_FLOAT("input_axis_threshold", &settings->floats.input_axis_threshold, true, DEFAULT_AXIS_THRESHOLD, false);
SETTING_FLOAT("input_analog_deadzone", &settings->floats.input_analog_deadzone, true, DEFAULT_ANALOG_DEADZONE, false);
SETTING_FLOAT("input_analog_sensitivity", &settings->floats.input_analog_sensitivity, true, DEFAULT_ANALOG_SENSITIVITY, false);
SETTING_FLOAT("input_sensor_accelerometer_sensitivity", &settings->floats.input_sensor_accelerometer_sensitivity, true, DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY, false);
SETTING_FLOAT("input_sensor_gyroscope_sensitivity", &settings->floats.input_sensor_gyroscope_sensitivity, true, DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY, false);
#ifdef HAVE_OVERLAY
SETTING_FLOAT("input_overlay_opacity", &settings->floats.input_overlay_opacity, true, DEFAULT_INPUT_OVERLAY_OPACITY, false);
SETTING_FLOAT("input_osk_overlay_opacity", &settings->floats.input_osk_overlay_opacity, true, DEFAULT_INPUT_OVERLAY_OPACITY, false);
Expand Down Expand Up @@ -2910,6 +2912,7 @@ void config_set_defaults(void *data)
#endif
input_config_set_device((unsigned)i, RETRO_DEVICE_JOYPAD);
settings->uints.input_mouse_index[i] = (unsigned)i;
settings->uints.input_sensor_index[i] = (unsigned)i;
}

custom_vp->width = 0;
Expand Down Expand Up @@ -3709,6 +3712,9 @@ static bool config_load_file(global_t *global,

_len2 = strlcpy(buf, prefix, sizeof(buf));

strlcpy(buf + _len2, "_sensor_index", sizeof(buf) - _len2);
CONFIG_GET_INT_BASE(conf, settings, uints.input_sensor_index[i], buf);

strlcpy(buf + _len2, "_mouse_index", sizeof(buf) - _len2);
CONFIG_GET_INT_BASE(conf, settings, uints.input_mouse_index[i], buf);

Expand Down Expand Up @@ -5261,6 +5267,9 @@ bool config_save_file(const char *path)

_len = strlcpy(cfg, "input_player", sizeof(cfg));
_len += strlcpy(cfg + _len, formatted_number, sizeof(cfg) - _len);

strlcpy(cfg + _len, "_sensor_index", sizeof(cfg) - _len);
config_set_int(conf, cfg, settings->uints.input_sensor_index[i]);

strlcpy(cfg + _len, "_mouse_index", sizeof(cfg) - _len);
config_set_int(conf, cfg, settings->uints.input_mouse_index[i]);
Expand Down Expand Up @@ -5580,6 +5589,14 @@ int8_t config_save_overrides(enum override_type type,
_len = strlcpy(cfg, "input_player", sizeof(cfg));
_len += strlcpy(cfg + _len, formatted_number, sizeof(cfg) - _len);

if (settings->uints.input_sensor_index[i]
!= overrides->uints.input_sensor_index[i])
{
strlcpy(cfg + _len, "_sensor_index", sizeof(cfg) - _len);
config_set_int(conf, cfg, overrides->uints.input_sensor_index[i]);
RARCH_DBG("[Overrides]: %s = \"%u\"\n", cfg, overrides->uints.input_sensor_index[i]);
}

if (settings->uints.input_mouse_index[i]
!= overrides->uints.input_mouse_index[i])
{
Expand Down Expand Up @@ -5774,7 +5791,7 @@ bool input_remapping_load_file(void *data, const char *path)
config_file_t *conf = (config_file_t*)data;
settings_t *settings = config_st;
runloop_state_t *runloop_st = runloop_state_get_ptr();
char key_strings[RARCH_FIRST_CUSTOM_BIND + 8][8] = {
static const char * key_strings[RARCH_FIRST_CUSTOM_BIND + 8] = {
"b", "y", "select", "start",
"up", "down", "left", "right",
"a", "x", "l", "r", "l2", "r2",
Expand Down Expand Up @@ -5879,7 +5896,40 @@ bool input_remapping_load_file(void *data, const char *path)
_len = strlcpy(s1, "input_remap_port_p", sizeof(s1));
strlcpy(s1 + _len, formatted_number, sizeof(s1) - _len);
CONFIG_GET_INT_BASE(conf, settings, uints.input_remap_ports[i], s1);
}
{
static const char * sensor_strings[RETRO_SENSOR_MAX] =
{
"accel_x","accel_y", "accel_z",
"gyro_x","gyro_y","gyro_z",
"light"
};
static const char * sensor_strings_flip[RETRO_SENSOR_MAX] =
{
"accel_x_flip","accel_y_flip", "accel_z_flip",
"gyro_x_flip","gyro_y_flip","gyro_z_flip",
"light_flip"
};
for (j = 0; j < RETRO_SENSOR_MAX; j++){

int sensor_remap = -1;
bool sensor_flip_remap = false;
char sensor_ident[128];
char sensor_flip_ident[128];
fill_pathname_join_delim(sensor_ident, s1,
sensor_strings[j], '_', sizeof(sensor_ident));
fill_pathname_join_delim(sensor_flip_ident, s1,
sensor_strings_flip[j], '_', sizeof(sensor_flip_ident));
if(!config_get_int(conf, sensor_ident, &sensor_remap))
sensor_remap=RETROK_UNKNOWN;
configuration_set_uint(settings,
settings->uints.input_sensor_ids[i][j], sensor_remap);
config_get_bool(conf, sensor_flip_ident, &sensor_flip_remap);
configuration_set_bool(settings,
settings->bools.input_sensor_flip_axis[i][j], sensor_flip_remap);

}
}
}

input_remapping_update_port_map();

Expand All @@ -5905,7 +5955,7 @@ bool input_remapping_save_file(const char *path)
bool ret;
unsigned i, j;
char remap_file_dir[PATH_MAX_LENGTH];
char key_strings[RARCH_FIRST_CUSTOM_BIND + 8][8] =
static const char * key_strings[RARCH_FIRST_CUSTOM_BIND + 8] =
{
"b", "y", "select", "start",
"up", "down", "left", "right",
Expand All @@ -5914,6 +5964,18 @@ bool input_remapping_save_file(const char *path)
"l_x+", "l_x-", "l_y+", "l_y-",
"r_x+", "r_x-", "r_y+", "r_y-"
};
static const char * sensor_strings[RETRO_SENSOR_MAX] =
{
"accel_x","accel_y", "accel_z",
"gyro_x","gyro_y","gyro_z",
"light"
};
static const char * sensor_strings_flip[RETRO_SENSOR_MAX] =
{
"accel_x_flip","accel_y_flip", "accel_z_flip",
"gyro_x_flip","gyro_y_flip","gyro_z_flip",
"light_flip"
};
config_file_t *conf = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
settings_t *settings = config_st;
Expand Down Expand Up @@ -6055,6 +6117,33 @@ bool input_remapping_save_file(const char *path)
_len = strlcpy(s1, "input_remap_port_p", sizeof(s1));
strlcpy(s1 + _len, formatted_number, sizeof(s1) - _len);
config_set_int(conf, s1, settings->uints.input_remap_ports[i]);
for (j = 0; j < RETRO_SENSOR_MAX; j++){
char sensor_ident[128];
char sensor_ident_flip[128];
unsigned sensor_remap = settings->uints.input_sensor_ids[i][j];

fill_pathname_join_delim(sensor_ident, s1,
sensor_strings[j], '_', sizeof(sensor_ident));
fill_pathname_join_delim(sensor_ident_flip, s1,
sensor_strings_flip[j], '_', sizeof(sensor_ident_flip));

if (sensor_remap == j)
config_unset(conf, sensor_ident);
else
{
if (sensor_remap == RARCH_UNMAPPED)
config_set_int(conf, sensor_ident, -1);
else
config_set_int(conf, sensor_ident,
settings->uints.input_sensor_ids[i][j]);
}
/*
configuration_set_bool(conf,
settings->bools.input_sensor_flip_axis[i][j],
settings->bools.input_sensor_flip_axis[i][j]
);
*/
}
}

ret = config_file_write(conf, path, true);
Expand Down
5 changes: 5 additions & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ typedef struct settings
unsigned input_joypad_index[MAX_USERS];
unsigned input_device[MAX_USERS];
unsigned input_mouse_index[MAX_USERS];
unsigned input_sensor_index[MAX_USERS];

unsigned input_libretro_device[MAX_USERS];
unsigned input_analog_dpad_mode[MAX_USERS];

unsigned input_remap_ports[MAX_USERS];
unsigned input_remap_ids[MAX_USERS][RARCH_CUSTOM_BIND_LIST_END];
unsigned input_keymapper_ids[MAX_USERS][RARCH_CUSTOM_BIND_LIST_END];
unsigned input_sensor_ids[MAX_USERS][RETRO_SENSOR_MAX];
unsigned input_remap_port_map[MAX_USERS][MAX_USERS + 1];

unsigned led_map[MAX_LEDS];
Expand Down Expand Up @@ -432,6 +434,8 @@ typedef struct settings
float input_analog_deadzone;
float input_axis_threshold;
float input_analog_sensitivity;
float input_sensor_accelerometer_sensitivity;
float input_sensor_gyroscope_sensitivity;
#ifdef _3DS
float bottom_font_scale;
#endif
Expand Down Expand Up @@ -704,6 +708,7 @@ typedef struct settings
bool input_touch_vmouse_trackball;
bool input_touch_vmouse_gesture;
#endif
bool input_sensor_flip_axis[MAX_USERS][RETRO_SENSOR_MAX];

/* Frame time counter */
bool frame_time_counter_reset_after_fastforwarding;
Expand Down
Loading
Loading