Compare commits

...

29 commits

Author SHA1 Message Date
oshaboy 7288afb4d0
Merge a0887a1769 into 3092740312 2024-05-05 14:14:58 +00:00
oshaboy a0887a1769 Merge branch 'linux_sensor' of https://github.com/oshaboy/RetroArch into linux_sensor 2024-04-23 01:08:48 +03:00
oshaboy a4c6880334 I commented out the wrong thing 2024-04-23 01:08:37 +03:00
oshaboy 19f47d28c2
Merge branch 'master' into linux_sensor 2024-04-23 00:42:18 +03:00
oshaboy aef300916d Gave up on menu settings 2024-04-23 00:38:45 +03:00
oshaboy 6a91a2c24f Update configuration.c 2024-04-15 17:09:16 +03:00
oshaboy cbb2b6467b typo 2024-02-22 02:13:01 +02:00
oshaboy 9d9e388884 Messed up the merge 2024-02-22 02:11:43 +02:00
oshaboy c218c60531
Merge branch 'master' into linux_sensor 2024-02-22 02:05:25 +02:00
oshaboy 2ab1ef5b28 Mostly menu stuff for sensors 2024-02-22 01:58:08 +02:00
oshaboy cafaeff71d Update sdl_input.c 2024-02-05 05:16:10 +02:00
oshaboy adcb02d6a0 Update sdl_input.c 2024-02-05 05:02:04 +02:00
oshaboy 6c7f783f98 Update sdl_input.c 2024-02-05 05:01:05 +02:00
oshaboy 1a30370efe Now SDL Sensor gives names. 2024-02-05 04:35:22 +02:00
oshaboy 809d53f92f Segfault fix and macro renaming 2024-02-04 00:43:53 +02:00
oshaboy 17a87f15c4 Various
Cleanup
Sensitivity settings and Sensor Retropad selection implemented including menu options
2024-02-04 00:05:02 +02:00
oshaboy ac21e7d2fc Moved sensitivity adjustment to some other function 2024-02-03 19:01:01 +02:00
oshaboy 91613a47b3 I forgot a few files. 2024-02-03 17:36:44 +02:00
oshaboy 6fdfa1cb70 Merge branch 'linux_sensor' of https://github.com/oshaboy/RetroArch into linux_sensor 2024-02-03 17:11:44 +02:00
oshaboy 7d3fcc12a0
Merge branch 'libretro:master' into linux_sensor 2024-02-03 17:11:19 +02:00
oshaboy 7dc3bdbb1a Menu Stuff 2024-02-03 17:09:00 +02:00
oshaboy 5113a521d2 Removed silly printf hack and used proper facilities. 2024-02-02 20:29:23 +02:00
oshaboy 0277283144 Update sdl_input.c 2024-02-02 20:10:30 +02:00
oshaboy 5fcea9b7a9 Remove C++ style comments 2024-02-02 19:35:41 +02:00
oshaboy 75b9de3c98 Comments and UDEV_TOUCH_SUPPORT flag. 2024-02-02 19:30:19 +02:00
oshaboy ebe99abf8d buncha stuff
optimizations
SDL touchpad support
bugfixes
2024-02-02 02:27:55 +02:00
oshaboy 7775239c41 Preliminary SDL Gyro Support 2024-02-01 18:24:43 +02:00
oshaboy 606742b485 Fixed segfault and added hotplug support. 2024-01-31 05:12:36 +02:00
oshaboy 5428652ef8 Added udev sensor support 2024-01-31 04:16:09 +02:00
15 changed files with 1125 additions and 330 deletions

View file

@ -1555,6 +1555,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

View file

@ -2246,6 +2246,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);
@ -2911,6 +2913,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;
@ -3710,6 +3713,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);
@ -5262,6 +5268,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]);
@ -5581,6 +5590,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])
{
@ -5775,7 +5792,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",
@ -5880,7 +5897,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();
@ -5906,7 +5956,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",
@ -5915,6 +5965,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;
@ -6056,6 +6118,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);

View file

@ -148,6 +148,7 @@ 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];
@ -155,6 +156,7 @@ typedef struct settings
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];
@ -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
@ -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;

View file

@ -28,10 +28,16 @@
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
#ifdef HAVE_SDL2
#define SDL_SUPPORT_SENSORS SDL_VERSION_ATLEAST(2,0,9)
#define SDL_SUPPORT_FANCY_GAMEPAD SDL_VERSION_ATLEAST(2,0,14)
#include "../../gfx/common/sdl2_common.h"
#else
#define SDL_SUPPORT_SENSORS 0
#define SDL_SUPPORT_FANCY_GAMEPAD 0
#endif
#ifdef WEBOS
@ -39,6 +45,39 @@
#include <dlfcn.h>
#endif
/* TODO/FIXME -
* fix game focus toggle */
enum SDL_AUXILIARY_DEVICE_TYPE{
SDL_AUXILIARY_DEVICE_TYPE_NONE,
SDL_AUXILIARY_DEVICE_TYPE_SENSOR,
SDL_AUXILIARY_DEVICE_TYPE_TOUCHID,
SDL_AUXILIARY_DEVICE_TYPE_GAMECONTROLLER
};
#ifdef HAVE_SDL2
#if SDL_SUPPORT_FANCY_GAMEPAD
struct game_controller_data{
SDL_GameController * ptr;
bool has_accelerometer : 1;
bool has_gyro : 1;
unsigned num_touchpads:14;
};
#endif
typedef struct {
union {
#if SDL_SUPPORT_SENSORS
SDL_Sensor * sensor;
#endif
SDL_TouchID touch_id;
#if SDL_SUPPORT_FANCY_GAMEPAD
struct game_controller_data game_controller;
#endif
} dev;
enum SDL_AUXILIARY_DEVICE_TYPE type;
} sdl_auxiliary_device;
#endif
typedef struct sdl_input
{
int mouse_x;
@ -54,6 +93,10 @@ typedef struct sdl_input
int mouse_wd;
int mouse_wl;
int mouse_wr;
#ifdef HAVE_SDL2
unsigned auxiliary_device_number;
sdl_auxiliary_device * auxiliary_devices;
#endif
} sdl_input_t;
#ifdef WEBOS
@ -74,6 +117,97 @@ static void *sdl_input_init(const char *joypad_driver)
input_keymaps_init_keyboard_lut(rarch_key_map_sdl);
#ifdef HAVE_SDL2
{
int numJoysticks=0,numTouchDevices=0,numSensors=0;
int i; int sensor_count=0;
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
RARCH_DBG(
"[sdl]: SDL_GetNumTouchDevices: %d\n",
numTouchDevices=SDL_GetNumTouchDevices()
);
#if SDL_SUPPORT_SENSORS
RARCH_DBG(
"[sdl]: SDL_NumSensors: %d\n",
numSensors=SDL_NumSensors()
);
#endif
#if SDL_SUPPORT_FANCY_GAMEPAD
RARCH_DBG(
"[sdl]: SDL_NumJoysticks: %d\n",
numJoysticks=SDL_NumJoysticks()
);
#endif
sdl->auxiliary_device_number=0;
sdl->auxiliary_devices=malloc(sizeof(sdl_auxiliary_device)*(numJoysticks+numTouchDevices+numSensors));
for (i=0; i<numTouchDevices; i++){
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.touch_id=SDL_GetTouchDevice(i);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
type=SDL_AUXILIARY_DEVICE_TYPE_TOUCHID;
sdl->auxiliary_device_number++;
}
#if SDL_SUPPORT_SENSORS
for(i=0; i<numSensors; i++){
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.sensor=SDL_SensorOpen(i);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
type=SDL_AUXILIARY_DEVICE_TYPE_SENSOR;
input_config_set_sensor_display_name(
sensor_count++,
SDL_SensorGetName(sdl->auxiliary_devices[sdl->auxiliary_device_number].dev.sensor)
);
sdl->auxiliary_device_number++;
}
#endif
#if SDL_SUPPORT_FANCY_GAMEPAD
for (i=0; i<numJoysticks; i++){
SDL_GameController * gamepad=SDL_GameControllerOpen(i);
bool hassensor=false;
RARCH_DBG(
"[sdl]: Gamepad no %d (%s 0x%p)\n"
"\tHasSensor: %d\n"
"\tIsSensorEnabled: %d\n"
"\tGetNumTouchpads: %d\n"
,i,SDL_GameControllerName(gamepad),gamepad,
SDL_GameControllerHasSensor(gamepad,SDL_SENSOR_ACCEL),
SDL_GameControllerIsSensorEnabled(gamepad,SDL_SENSOR_ACCEL),
SDL_GameControllerGetNumTouchpads(gamepad)
);
if (SDL_GameControllerHasSensor(gamepad,SDL_SENSOR_ACCEL)){
RARCH_DBG("[sdl]: Initializing Accelerometer\n");
SDL_GameControllerSetSensorEnabled(gamepad,SDL_SENSOR_ACCEL,SDL_TRUE);
hassensor=true;
}
if (SDL_GameControllerHasSensor(gamepad,SDL_SENSOR_GYRO)){
RARCH_DBG("[sdl]: Initializing Gyroscope\n");
SDL_GameControllerSetSensorEnabled(gamepad,SDL_SENSOR_GYRO,SDL_TRUE);
hassensor=true;
}
if (hassensor){
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.game_controller.ptr=SDL_GameControllerOpen(i);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.game_controller.has_accelerometer=SDL_GameControllerIsSensorEnabled(gamepad,SDL_SENSOR_ACCEL);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.game_controller.has_gyro=SDL_GameControllerIsSensorEnabled(gamepad,SDL_SENSOR_GYRO);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.game_controller.num_touchpads=SDL_GameControllerGetNumTouchpads(gamepad);
sdl->auxiliary_devices[sdl->auxiliary_device_number].
type=SDL_AUXILIARY_DEVICE_TYPE_GAMECONTROLLER;
sdl->auxiliary_device_number++;
input_config_set_sensor_display_name(sensor_count++,SDL_GameControllerName(gamepad));
}
}
#endif
}
#endif
return sdl;
}
@ -131,7 +265,6 @@ static int16_t sdl_input_state(
{
int16_t ret = 0;
sdl_input_t *sdl = (sdl_input_t*)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
@ -246,6 +379,54 @@ static int16_t sdl_input_state(
break;
case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN:
#ifdef HAVE_SDL2
if (sdl->auxiliary_devices[port].type == SDL_AUXILIARY_DEVICE_TYPE_TOUCHID ){
SDL_Finger * finger=SDL_GetTouchFinger(
sdl->auxiliary_devices[port].dev.touch_id,
idx
);
switch (id)
{
case RETRO_DEVICE_ID_POINTER_X:
return (int16_t)((finger->x-0.5f)*65535);
case RETRO_DEVICE_ID_POINTER_Y:
return (int16_t)((finger->y-0.5f)*65535);
case RETRO_DEVICE_ID_POINTER_PRESSED:
return finger->pressure>0.f;
}
}
#if SDL_SUPPORT_FANCY_GAMEPAD
else if (
sdl->auxiliary_devices[port].type == SDL_AUXILIARY_DEVICE_TYPE_GAMECONTROLLER &&
sdl->auxiliary_devices[port].dev.game_controller.num_touchpads
){
float x,y,pressure;
SDL_GameControllerGetTouchpadFinger(
sdl->auxiliary_devices[port].dev.game_controller.ptr,
0,/*Todo don't hard code*/
idx,
NULL,
&x,&y,
&pressure
);
RARCH_DBG("[sdl] finger dump:\n\t%f\n\t%f\n\t%f\n\t%d\n", x,y,pressure,id);
switch (id)
{
case RETRO_DEVICE_ID_POINTER_X:
return (int16_t)((x-0.5f)*65535);
case RETRO_DEVICE_ID_POINTER_Y:
return (int16_t)((y-0.5f)*65535);
case RETRO_DEVICE_ID_POINTER_PRESSED:
return pressure>0.f;
}
}
#endif
else
#endif
if (idx == 0)
{
struct video_viewport vp;
@ -333,10 +514,10 @@ static void sdl_input_free(void *data)
/* Flush out all pending events. */
#ifdef HAVE_SDL2
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
free(sdl->auxiliary_devices);
#else
while (SDL_PollEvent(&event));
#endif
free(data);
}
@ -358,7 +539,6 @@ static void sdl2_grab_mouse(void *data, bool state)
static void sdl_poll_mouse(sdl_input_t *sdl)
{
Uint8 btn = SDL_GetRelativeMouseState(&sdl->mouse_x, &sdl->mouse_y);
SDL_GetMouseState(&sdl->mouse_abs_x, &sdl->mouse_abs_y);
sdl->mouse_l = (SDL_BUTTON(SDL_BUTTON_LEFT) & btn) ? 1 : 0;
@ -378,7 +558,6 @@ static void sdl_input_poll(void *data)
sdl_input_t *sdl = (sdl_input_t*)data;
SDL_PumpEvents();
sdl_poll_mouse(sdl);
#ifdef HAVE_SDL2
@ -468,14 +647,102 @@ static uint64_t sdl_get_capabilities(void *data)
| (1 << RETRO_DEVICE_POINTER)
| (1 << RETRO_DEVICE_ANALOG);
}
#if SDL_SUPPORT_SENSORS
static bool sdl_input_set_sensor_state (void *data, unsigned port, enum retro_sensor_action action, unsigned rate) {
return true;
}
static float sdl_input_get_sensor_input (void *data, unsigned port, unsigned id) {
sdl_input_t * sdl = (sdl_input_t *)data;
SDL_GameController * gamepad=NULL;
SDL_Sensor * sensor=NULL;
SDL_SensorType sensor_type;
int i;
float sensor_data[3],sensor_value;
if ((id == RETRO_SENSOR_ACCELEROMETER_X) |
(id == RETRO_SENSOR_ACCELEROMETER_Y) |
(id == RETRO_SENSOR_ACCELEROMETER_Z)
) sensor_type=SDL_SENSOR_ACCEL;
else if ((id == RETRO_SENSOR_GYROSCOPE_X) |
(id == RETRO_SENSOR_GYROSCOPE_Y) |
(id == RETRO_SENSOR_GYROSCOPE_Z)
) sensor_type=SDL_SENSOR_GYRO;
else return 0.f; /*Unimplemented*/
for (i=0; i<(int)sdl->auxiliary_device_number;i++){
#if SDL_SUPPORT_FANCY_GAMEPAD
if (
sdl->auxiliary_devices[i].type == SDL_AUXILIARY_DEVICE_TYPE_GAMECONTROLLER &&
(sdl->auxiliary_devices[i].dev.game_controller.has_accelerometer ||
sdl->auxiliary_devices[i].dev.game_controller.has_gyro)
){
if (port==0){
gamepad=sdl->auxiliary_devices[i].dev.game_controller.ptr;
break;
} else port--;
} else
#endif
if(
sdl->auxiliary_devices[i].type == SDL_AUXILIARY_DEVICE_TYPE_SENSOR &&
SDL_SensorGetType(sdl->auxiliary_devices[i].dev.sensor) == sensor_type
){
if (port==0){
sensor=sdl->auxiliary_devices[i].dev.sensor;
break;
} else port--;
}
}
if (!gamepad && !sensor){
RARCH_ERR("[sdl]: sdl_input_get_sensor_input recieved a "
"device where none of it's children are sensors\n");
return 0.f;
}
#if SDL_SUPPORT_FANCY_GAMEPAD
if (gamepad)
SDL_GameControllerGetSensorData(gamepad, sensor_type, sensor_data,3);
else /*if (sensor)*/
#endif
SDL_SensorGetData(sensor,sensor_data, 3);
if (id>=RETRO_SENSOR_ACCELEROMETER_X && id <= RETRO_SENSOR_ACCELEROMETER_Z){
sensor_value=sensor_data[id-RETRO_SENSOR_ACCELEROMETER_X];
} else if (id>=RETRO_SENSOR_GYROSCOPE_X && id <= RETRO_SENSOR_GYROSCOPE_Z){
sensor_value=sensor_data[id-RETRO_SENSOR_GYROSCOPE_X];
} else {
return 0.f; /*UNIMPLEMENTED*/
}
RARCH_DBG(
"[udev] sensor:\n"
"\t%f\n"
/*
"\t%d\n"
"\t%d\n"
*/
"\t%f\n",
sensor_value,
/*limits.min,
limits.max,*/
sensor_value
);
return sensor_value;
}
#endif
input_driver_t input_sdl = {
sdl_input_init,
sdl_input_poll,
sdl_input_state,
sdl_input_free,
#if SDL_SUPPORT_SENSORS
sdl_input_set_sensor_state,
sdl_input_get_sensor_input,
#else
NULL,
NULL,
#endif
sdl_get_capabilities,
#ifdef HAVE_SDL2
"sdl2",

File diff suppressed because it is too large Load diff

View file

@ -244,7 +244,17 @@ enum input_turbo_default_button
INPUT_TURBO_DEFAULT_BUTTON_R3,
INPUT_TURBO_DEFAULT_BUTTON_LAST
};
enum RETRO_SENSOR
{
RETRO_SENSOR_ACCELEROMETER_X,
RETRO_SENSOR_ACCELEROMETER_Y,
RETRO_SENSOR_ACCELEROMETER_Z,
RETRO_SENSOR_GYROSCOPE_X,
RETRO_SENSOR_GYROSCOPE_Y,
RETRO_SENSOR_GYROSCOPE_Z,
RETRO_SENSOR_ILLUMINANCE,
RETRO_SENSOR_MAX
};
RETRO_END_DECLS
#endif

View file

@ -4305,8 +4305,15 @@ float input_get_sensor_state(unsigned port, unsigned id)
{
settings_t *settings = config_get_ptr();
bool input_sensors_enable = settings->bools.input_sensors_enable;
return input_driver_get_sensor(port, input_sensors_enable, id);
float sensitivity;
if (id >= RETRO_SENSOR_ACCELEROMETER_X && id <= RETRO_SENSOR_ACCELEROMETER_Z)
sensitivity=settings->floats.input_sensor_accelerometer_sensitivity;
else if (id >= RETRO_SENSOR_GYROSCOPE_X && id <= RETRO_SENSOR_GYROSCOPE_Z)
sensitivity=settings->floats.input_sensor_gyroscope_sensitivity;
else
sensitivity=1.f;
return input_driver_get_sensor(port, input_sensors_enable, id)*((float)pow(2,sensitivity));
}
/**
@ -4772,23 +4779,44 @@ const char *input_config_get_mouse_display_name(unsigned port)
return NULL;
return input_st->input_mouse_info[port].display_name;
}
void input_config_set_mouse_display_name(unsigned port, const char *name)
const char *input_config_get_sensor_display_name(unsigned port)
{
input_driver_state_t *input_st = &input_driver_st;
if (string_is_empty(input_st->input_sensor_info[port].display_name))
return NULL;
return input_st->input_sensor_info[port].display_name;
}
enum aux_device_type{
MOUSE_AUX_DEVICE,
SENSOR_AUX_DEVICE
};
static void input_config_set_auxiliary_device_display_name(unsigned port, const char *name, enum aux_device_type aux_device_type)
{
char name_ascii[NAME_MAX_LENGTH];
input_driver_state_t *input_st = &input_driver_st;
input_mouse_info_t * aux_device_info;
name_ascii[0] = '\0';
/* Strip non-ASCII characters */
if (!string_is_empty(name))
string_copy_only_ascii(name_ascii, name);
if (aux_device_type == SENSOR_AUX_DEVICE)
aux_device_info=&input_st->input_sensor_info[port];
else /*(aux_device_type == MOUSE_AUX_DEVICE)*/
aux_device_info=&input_st->input_mouse_info[port];
if (!string_is_empty(name_ascii))
strlcpy(input_st->input_mouse_info[port].display_name, name_ascii,
sizeof(input_st->input_mouse_info[port].display_name));
strlcpy(aux_device_info->display_name, name_ascii,
sizeof(aux_device_info->display_name));
}
void input_config_set_sensor_display_name(unsigned port, const char *name)
{
input_config_set_auxiliary_device_display_name(port, name, SENSOR_AUX_DEVICE);
}
void input_config_set_mouse_display_name(unsigned port, const char *name)
{
input_config_set_auxiliary_device_display_name(port, name, MOUSE_AUX_DEVICE);
}
void input_keyboard_mapping_bits(unsigned mode, unsigned key)
{
input_driver_state_t *input_st = &input_driver_st;

View file

@ -282,7 +282,7 @@ typedef struct
{
char display_name[256];
} input_mouse_info_t;
typedef input_mouse_info_t input_sensor_info_t;
typedef struct input_remote input_remote_t;
typedef struct input_remote_state
@ -540,6 +540,7 @@ typedef struct
input_mapper_t mapper; /* uint32_t alignment */
input_device_info_t input_device_info[MAX_INPUT_DEVICES]; /* unsigned alignment */
input_mouse_info_t input_mouse_info[MAX_INPUT_DEVICES];
input_sensor_info_t input_sensor_info[MAX_INPUT_DEVICES];
unsigned old_analog_dpad_mode[MAX_USERS];
unsigned old_libretro_device[MAX_USERS];
unsigned osk_last_codepoint;
@ -743,6 +744,7 @@ void input_config_set_device_name(unsigned port, const char *name);
*/
void input_config_set_device_display_name(unsigned port, const char *name);
void input_config_set_mouse_display_name(unsigned port, const char *name);
void input_config_set_sensor_display_name(unsigned port, const char *name);
/**
* Set the configuration name for the device in the specified port
@ -830,6 +832,7 @@ unsigned input_config_get_device(unsigned port);
const char *input_config_get_device_name(unsigned port);
const char *input_config_get_device_display_name(unsigned port);
const char *input_config_get_mouse_display_name(unsigned port);
const char *input_config_get_sensor_display_name(unsigned port);
const char *input_config_get_device_config_name(unsigned port);
const char *input_config_get_device_joypad_driver(unsigned port);

View file

@ -1876,6 +1876,14 @@ MSG_HASH(
MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY,
"input_analog_sensitivity"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
"input_sensor_accelerometer_sensitivity"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
"input_sensor_gyroscope_sensitivity"
)
#ifdef GEKKO
MSG_HASH(
MENU_ENUM_LABEL_INPUT_MOUSE_SCALE,
@ -1980,6 +1988,70 @@ MSG_HASH(
MENU_ENUM_LABEL_INPUT_MOUSE_INDEX,
"input_player%u_mouse_index"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_SENSOR_INDEX,
"input_player%u_sensor_index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_MAPPINGS,
"input_player%u_sensor_mappings"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X,
"input_player%u_accelerometer_x_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X_FLIP,
"input_player%u_accelerometer_x_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y,
"input_player%u_accelerometer_y_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y_FLIP,
"input_player%u_accelerometer_y_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z,
"input_player%u_accelerometer_z_binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z_FLIP,
"input_player%u_accelerometer_z_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X,
"input_player%u_gyroscope_x"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X_FLIP,
"input_player%u_gyroscope_x_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y,
"input_player%u_gyroscope_y"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y_FLIP,
"input_player%u_gyroscope_y_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z,
"input_player%u_gyroscope_z"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z_FLIP,
"input_player%u_gyroscope_z_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT,
"input_player%u_light"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT_FLIP,
"input_player%u_light_flip"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
"input_player%u_joypad_index"

View file

@ -3363,10 +3363,26 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_SENSITIVITY,
"Analog Sensitivity"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
"Accelerometer Sensitivity"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
"Gyroscope Sensitivity"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_ANALOG_SENSITIVITY,
"Adjust the sensitivity of analog sticks."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
"Adjust the sensitivity of the Accelerometer."
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
"Adjust the sensitivity of the Gyroscope."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_BIND_TIMEOUT,
"Bind Timeout"
@ -4161,9 +4177,74 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX,
"Mouse Index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_INDEX,
"Sensor Index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_MAPPINGS,
"Sensor Mappings"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X,
"Accelerometer X Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X_FLIP,
"Accelerometer X Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y,
"Accelerometer Y Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y_FLIP,
"Accelerometer Y Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z,
"Accelerometer Z Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z_FLIP,
"Accelerometer Z Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X,
"Gyroscope X Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X_FLIP,
"Gyroscope X Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y,
"Gyroscope Y Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y_FLIP,
"Gyroscope Y Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z,
"Gyroscope Z Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z_FLIP,
"Gyroscope Z Flip"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT,
"Light Binding"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT_FLIP,
"Light Flip"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_MOUSE_INDEX,
"The physical mouse as recognized by RetroArch."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B,

View file

@ -4418,75 +4418,7 @@ enum retro_sensor_action
RETRO_SENSOR_DUMMY = INT_MAX
};
/** @defgroup RETRO_SENSOR_ID Sensor Value IDs
* @{
*/
/* Id values for SENSOR types. */
/**
* Returns the device's acceleration along its local X axis minus the effect of gravity, in m/s^2.
*
* Positive values mean that the device is accelerating to the right.
* assuming the user is looking at it head-on.
*/
#define RETRO_SENSOR_ACCELEROMETER_X 0
/**
* Returns the device's acceleration along its local Y axis minus the effect of gravity, in m/s^2.
*
* Positive values mean that the device is accelerating upwards,
* assuming the user is looking at it head-on.
*/
#define RETRO_SENSOR_ACCELEROMETER_Y 1
/**
* Returns the the device's acceleration along its local Z axis minus the effect of gravity, in m/s^2.
*
* Positive values indicate forward acceleration towards the user,
* assuming the user is looking at the device head-on.
*/
#define RETRO_SENSOR_ACCELEROMETER_Z 2
/**
* Returns the angular velocity of the device around its local X axis, in radians per second.
*
* Positive values indicate counter-clockwise rotation.
*
* @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians.
* @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope
* for guidance on using this value to derive a device's orientation.
*/
#define RETRO_SENSOR_GYROSCOPE_X 3
/**
* Returns the angular velocity of the device around its local Z axis, in radians per second.
*
* Positive values indicate counter-clockwise rotation.
*
* @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians.
* @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope
* for guidance on using this value to derive a device's orientation.
*/
#define RETRO_SENSOR_GYROSCOPE_Y 4
/**
* Returns the angular velocity of the device around its local Z axis, in radians per second.
*
* Positive values indicate counter-clockwise rotation.
*
* @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians.
* @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope
* for guidance on using this value to derive a device's orientation.
*/
#define RETRO_SENSOR_GYROSCOPE_Z 5
/**
* Returns the ambient illuminance (light intensity) of the device's environment, in lux.
*
* @see https://en.wikipedia.org/wiki/Lux for a table of common lux values.
*/
#define RETRO_SENSOR_ILLUMINANCE 6
/** @} */
/**
* Adjusts the state of a sensor.

View file

@ -555,6 +555,8 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_touch_vmouse_gesture, MENU_
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_button_axis_threshold, MENU_ENUM_SUBLABEL_INPUT_BUTTON_AXIS_THRESHOLD)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_analog_deadzone, MENU_ENUM_SUBLABEL_INPUT_ANALOG_DEADZONE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_analog_sensitivity, MENU_ENUM_SUBLABEL_INPUT_ANALOG_SENSITIVITY)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sensor_accelerometer_sensitivity, MENU_ENUM_SUBLABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sensor_gyroscope_sensitivity, MENU_ENUM_SUBLABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_period, MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_duty_cycle, MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_mode, MENU_ENUM_SUBLABEL_INPUT_TURBO_MODE)
@ -4558,6 +4560,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_analog_sensitivity);
break;
case MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sensor_accelerometer_sensitivity);
break;
case MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sensor_gyroscope_sensitivity);
break;
#if defined(GEKKO)
case MENU_ENUM_LABEL_INPUT_MOUSE_SCALE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_mouse_scale);

View file

@ -7877,6 +7877,8 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_INPUT_BUTTON_AXIS_THRESHOLD, PARSE_ONLY_FLOAT, true },
{MENU_ENUM_LABEL_INPUT_ANALOG_DEADZONE, PARSE_ONLY_FLOAT, true },
{MENU_ENUM_LABEL_INPUT_ANALOG_SENSITIVITY, PARSE_ONLY_FLOAT, true },
{MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY, PARSE_ONLY_FLOAT, true },
{MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY, PARSE_ONLY_FLOAT, true },
#if defined(GEKKO)
{MENU_ENUM_LABEL_INPUT_MOUSE_SCALE, PARSE_ONLY_UINT, true },
#endif

View file

@ -7798,6 +7798,7 @@ static int setting_action_start_input_mouse_index(rarch_setting_t *setting)
return 0;
}
/**
******* ACTION TOGGLE CALLBACK FUNCTIONS *******
**/
@ -8047,7 +8048,37 @@ static void get_string_representation_input_mouse_index(
if (string_is_empty(s))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), len);
}
static void get_string_representation_input_sensor_index(
rarch_setting_t *setting, char *s, size_t len)
{
settings_t *settings = config_get_ptr();
unsigned map = 0;
if (!setting || !settings)
return;
map = settings->uints.input_sensor_index[setting->index_offset];
if (map < MAX_INPUT_DEVICES)
{
const char *device_name = input_config_get_sensor_display_name(map);
if (!string_is_empty(device_name))
strlcpy(s, device_name, len);
else if (map > 0)
{
size_t _len = strlcpy(s,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
len);
snprintf(s + _len, len - _len, " (#%u)", map + 1);
}
else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE), len);
}
if (string_is_empty(s))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), len);
}
static void read_handler_audio_rate_control_delta(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
@ -9298,7 +9329,6 @@ static bool setting_append_list_input_player_options(
*/
static char buffer[MAX_USERS][13+2+1];
static char group_label[MAX_USERS][255];
unsigned i, j;
rarch_setting_group_info_t group_info;
rarch_setting_group_info_t subgroup_info;
settings_t *settings = config_get_ptr();
@ -9330,6 +9360,7 @@ static bool setting_append_list_input_player_options(
{
static char device_index[MAX_USERS][64];
static char mouse_index[MAX_USERS][64];
static char sensor_index[MAX_USERS][64];
static char analog_to_digital[MAX_USERS][64];
static char bind_all[MAX_USERS][64];
static char bind_all_save_autoconfig[MAX_USERS][64];
@ -9337,6 +9368,7 @@ static bool setting_append_list_input_player_options(
static char label_device_index[MAX_USERS][64];
static char label_mouse_index[MAX_USERS][64];
static char label_sensor_index[MAX_USERS][64];
static char label_analog_to_digital[MAX_USERS][64];
static char label_bind_all[MAX_USERS][64];
static char label_bind_all_save_autoconfig[MAX_USERS][64];
@ -9349,10 +9381,13 @@ static bool setting_append_list_input_player_options(
snprintf(analog_to_digital[user], sizeof(analog_to_digital[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE), user + 1);
snprintf(device_index[user], sizeof(device_index[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX), user + 1);
snprintf(mouse_index[user], sizeof(mouse_index[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_MOUSE_INDEX), user + 1);
snprintf(sensor_index[user], sizeof(sensor_index[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_SENSOR_INDEX), user + 1);
snprintf(bind_all[user], sizeof(bind_all[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_BIND_ALL_INDEX), user + 1);
snprintf(bind_all_save_autoconfig[user], sizeof(bind_all_save_autoconfig[user]),
@ -9360,6 +9395,7 @@ static bool setting_append_list_input_player_options(
snprintf(bind_defaults[user], sizeof(bind_defaults[user]),
msg_hash_to_str(MENU_ENUM_LABEL_INPUT_BIND_DEFAULTS_INDEX), user + 1);
strlcpy(label_analog_to_digital[user],
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_ADC_TYPE),
sizeof(label_analog_to_digital[user]));
@ -9369,6 +9405,9 @@ static bool setting_append_list_input_player_options(
strlcpy(label_mouse_index[user],
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX),
sizeof(label_mouse_index[user]));
strlcpy(label_sensor_index[user],
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_INDEX),
sizeof(label_sensor_index[user]));
strlcpy(label_bind_all[user],
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_BIND_ALL),
sizeof(label_bind_all[user]));
@ -9480,9 +9519,30 @@ static bool setting_append_list_input_player_options(
(*list)[list_info->index - 1].get_string_representation =
&get_string_representation_input_mouse_index;
menu_settings_list_current_add_range(list, list_info, 0, MAX_INPUT_DEVICES - 1, 1.0, true, true);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_MOUSE_INDEX + user));
CONFIG_UINT_ALT(
list, list_info,
&settings->uints.input_sensor_index[user],
sensor_index[user],
label_sensor_index[user],
user,
&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;
(*list)[list_info->index - 1].get_string_representation =
&get_string_representation_input_sensor_index;
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
menu_settings_list_current_add_range(list, list_info, 0, MAX_INPUT_DEVICES - 1, 1.0, true, true);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info,
(enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_SENSOR_INDEX + user));
CONFIG_ACTION_ALT(
list, list_info,
bind_all[user],
@ -9523,71 +9583,56 @@ static bool setting_append_list_input_player_options(
}
{
const char *value_na =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
for (j = 0; j < RARCH_BIND_LIST_END; j++)
unsigned i;
for (i = 0; i < RARCH_BIND_LIST_END; i++)
{
char label[NAME_MAX_LENGTH];
char name[NAME_MAX_LENGTH];
size_t _len = 0;
i = (j < RARCH_ANALOG_BIND_LIST_END)
? input_config_bind_order[j]
: j;
if (input_config_bind_map_get_meta(i))
const char *input_desc_btn;
bool value_available=true;
unsigned cur_binding = (i < RARCH_ANALOG_BIND_LIST_END)
? input_config_bind_order[i]
: i;
if (input_config_bind_map_get_meta(cur_binding))
continue;
name[0] = '\0';
if (!string_is_empty(buffer[user]))
{
_len = strlcpy(label, buffer[user], sizeof(label));
label[ _len] = ' ';
label[++_len] = '\0';
}
else
label[0] = '\0';
if (
settings->bools.input_descriptor_label_show
&& (i < RARCH_FIRST_META_KEY)
/*default value*/
input_desc_btn=input_config_bind_map_get_desc(cur_binding);
if (settings->bools.input_descriptor_label_show
&& (cur_binding < RARCH_FIRST_META_KEY)
&& core_has_set_input_descriptor()
&& (i != RARCH_TURBO_ENABLE)
)
&& (cur_binding != RARCH_TURBO_ENABLE))
{
if (sys_info->input_desc_btn[user][i])
strlcpy(label + _len,
sys_info->input_desc_btn[user][i],
sizeof(label) - _len);
else
{
snprintf(label, sizeof(label), "%s (%s)",
input_config_bind_map_get_desc(i),
value_na);
if (settings->bools.input_descriptor_hide_unbound)
continue;
}
if (sys_info->input_desc_btn[user][cur_binding])
input_desc_btn=sys_info->input_desc_btn[user][cur_binding];
else value_available=false;
}
else
strlcpy(label + _len,
input_config_bind_map_get_desc(i),
sizeof(label) - _len);
if (value_available || !settings->bools.input_descriptor_hide_unbound){
char label[NAME_MAX_LENGTH];
char name[NAME_MAX_LENGTH];
int len;
snprintf(name, sizeof(name), "p%u_%s", user + 1, input_config_bind_map_get_base(i));
snprintf(name, sizeof(name), "p%u_%s", user + 1,
input_config_bind_map_get_base(cur_binding));
len=snprintf(label, sizeof(label), "%s%s%s",
buffer[user],
string_is_empty(buffer[user])?"":" ",
input_desc_btn);
if (!value_available)
snprintf(label+len,sizeof(label)-len, " (%s)",
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
CONFIG_BIND_ALT(
list, list_info,
&input_config_binds[user][i],
user + 1,
user,
strdup(name),
strdup(label),
&defaults[i],
&group_info,
&subgroup_info,
parent_group);
(*list)[list_info->index - 1].bind_type = i + MENU_SETTINGS_BIND_BEGIN;
CONFIG_BIND_ALT(
list, list_info,
&input_config_binds[user][cur_binding],
user + 1,
user,
strdup(name),
strdup(label),
&defaults[cur_binding],
&group_info,
&subgroup_info,
parent_group);
(*list)[list_info->index - 1].bind_type = cur_binding + MENU_SETTINGS_BIND_BEGIN;
}
}
}
@ -15442,6 +15487,36 @@ static bool setting_append_list(
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
CONFIG_FLOAT(
list, list_info,
&settings->floats.input_sensor_accelerometer_sensitivity,
MENU_ENUM_LABEL_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_SENSITIVITY,
DEFAULT_SENSOR_ACCELEROMETER_SENSITIVITY,
"%.1f",
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
CONFIG_FLOAT(
list, list_info,
&settings->floats.input_sensor_gyroscope_sensitivity,
MENU_ENUM_LABEL_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_SENSITIVITY,
DEFAULT_SENSOR_GYROSCOPE_SENSITIVITY,
"%.1f",
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
menu_settings_list_current_add_range(list, list_info, -5.0, 5.0, 0.1, true, true);
CONFIG_UINT(
list, list_info,
&settings->uints.input_bind_timeout,

View file

@ -873,6 +873,8 @@ enum msg_hash_enums
MENU_ENUM_LABEL_INPUT_DEVICE_INDEX_LAST = MENU_ENUM_LABEL_INPUT_DEVICE_INDEX + MAX_USERS,
MENU_ENUM_LABEL_INPUT_MOUSE_INDEX,
MENU_ENUM_LABEL_INPUT_MOUSE_INDEX_LAST = MENU_ENUM_LABEL_INPUT_MOUSE_INDEX + MAX_USERS,
MENU_ENUM_LABEL_INPUT_SENSOR_INDEX,
MENU_ENUM_LABEL_INPUT_SENSOR_INDEX_LAST = MENU_ENUM_LABEL_INPUT_SENSOR_INDEX + MAX_USERS,
MENU_ENUM_LABEL_INPUT_REMAP_PORT,
MENU_ENUM_LABEL_INPUT_REMAP_PORT_LAST = MENU_ENUM_LABEL_INPUT_REMAP_PORT + MAX_USERS,
@ -1155,10 +1157,29 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL,
MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG,
MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_INDEX,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_MAPPINGS,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_X_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Y_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_ACCELEROMETER_Z_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_X_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Y_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_GYROSCOPE_Z_FLIP,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT,
MENU_ENUM_LABEL_VALUE_INPUT_SENSOR_LIGHT_FLIP,
MENU_ENUM_LABEL_INPUT_JOYPAD_INDEX,
MENU_ENUM_LABEL_INPUT_BIND_ALL_INDEX,
MENU_ENUM_LABEL_INPUT_SAVE_AUTOCONFIG_INDEX,
MENU_ENUM_LABEL_INPUT_BIND_DEFAULTS_INDEX,
MENU_ENUM_LABEL_VALUE_INPUT_REMAP_PORT,
MENU_ENUM_SUBLABEL_INPUT_DEVICE_TYPE,
@ -1273,6 +1294,8 @@ enum msg_hash_enums
MENU_LABEL(INPUT_TOUCH_SCALE),
MENU_LABEL(INPUT_ANALOG_DEADZONE),
MENU_LABEL(INPUT_ANALOG_SENSITIVITY),
MENU_LABEL(INPUT_SENSOR_ACCELEROMETER_SENSITIVITY),
MENU_LABEL(INPUT_SENSOR_GYROSCOPE_SENSITIVITY),
MENU_LABEL(INPUT_BIND_TIMEOUT),
MENU_LABEL(INPUT_BIND_HOLD),
MENU_LABEL(INPUT_REMAP_BINDS_ENABLE),