Skip to content

Commit

Permalink
Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
oshaboy committed Jan 15, 2025
1 parent e1942e4 commit ed0e7f4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 55 deletions.
9 changes: 6 additions & 3 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -3789,7 +3789,6 @@ static bool config_load_file(global_t *global,
_len = old_len;
_len += snprintf(prefix + _len, sizeof(prefix) - _len, "%u", i + 1);


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

Expand Down Expand Up @@ -6030,11 +6029,13 @@ bool input_remapping_load_file(void *data, const char *path)
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);
// configuration_set_bool(settings,
// settings->bools.input_sensor_flip_axis[i][j], sensor_flip_remap);

}
}
Expand Down Expand Up @@ -6225,6 +6226,7 @@ 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]);
#if 0
for (j = 0; j < RETRO_SENSOR_MAX; j++){
char sensor_ident[128];
char sensor_ident_flip[128];
Expand Down Expand Up @@ -6252,6 +6254,7 @@ bool input_remapping_save_file(const char *path)
);
*/
}
#endif
}

ret = config_file_write(conf, path, true);
Expand Down
4 changes: 2 additions & 2 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,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_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 @@ -725,7 +725,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];
//bool input_sensor_flip_axis[MAX_USERS][RETRO_SENSOR_MAX];

/* Frame time counter */
bool frame_time_counter_reset_after_fastforwarding;
Expand Down
40 changes: 8 additions & 32 deletions input/drivers/sdl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@

/* TODO/FIXME -
* fix game focus toggle */
enum SDL_AUXILIARY_DEVICE_TYPE{
enum sdl_input_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{
struct sdl_input_game_controller_data{
SDL_GameController * ptr;
bool has_accelerometer : 1;
bool has_gyro : 1;
Expand All @@ -75,11 +75,11 @@ typedef struct {
#endif
SDL_TouchID touch_id;
#if SDL_SUPPORT_FANCY_GAMEPAD
struct game_controller_data game_controller;
struct sdl_input_game_controller_data game_controller;
#endif
} dev;
enum SDL_AUXILIARY_DEVICE_TYPE type;
} sdl_auxiliary_device;
enum sdl_input_auxiliary_device_type type;
} sdl_input_auxiliary_device;
#endif

typedef struct sdl_input
Expand All @@ -99,7 +99,7 @@ typedef struct sdl_input
int mouse_wr;
#ifdef HAVE_SDL2
unsigned auxiliary_device_number;
sdl_auxiliary_device * auxiliary_devices;
sdl_input_auxiliary_device * auxiliary_devices;
#endif
#ifdef __linux__
/* Light sensors aren't exposed through SDL, and they're not usually part of controllers */
Expand Down Expand Up @@ -148,7 +148,7 @@ static void *sdl_input_init(const char *joypad_driver)
);
#endif
sdl->auxiliary_device_number=0;
sdl->auxiliary_devices=malloc(sizeof(sdl_auxiliary_device)*(numJoysticks+numTouchDevices+numSensors));
sdl->auxiliary_devices=malloc(sizeof(sdl_input_auxiliary_device)*(numJoysticks+numTouchDevices+numSensors));
for (i=0; i<numTouchDevices; i++){
sdl->auxiliary_devices[sdl->auxiliary_device_number].
dev.touch_id=SDL_GetTouchDevice(i);
Expand Down Expand Up @@ -575,28 +575,6 @@ static bool sdl_set_sensor_state(void *data, unsigned port, enum retro_sensor_ac
return false;
}

static float sdl_get_sensor_input(void *data, unsigned port, unsigned id)
{
sdl_input_t *sdl = (sdl_input_t*)data;

if (!sdl)
return 0.0f;

switch (id)
{
case RETRO_SENSOR_ILLUMINANCE:
#ifdef __linux__
if (sdl->illuminance_sensor)
return linux_get_illuminance_reading(sdl->illuminance_sensor);
#endif
/* Unsupported on non-Linux platforms */
default:
break;
}

return 0.0f;
}

#ifdef HAVE_SDL2
static void sdl2_grab_mouse(void *data, bool state)
{
Expand Down Expand Up @@ -729,9 +707,7 @@ static uint64_t sdl_get_capabilities(void *data)
| (1 << RETRO_DEVICE_ANALOG);
}

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;
#if SDL_SUPPORT_SENSORS
Expand Down
7 changes: 1 addition & 6 deletions input/drivers/udev_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ static void udev_report_touch(udev_input_t *udev, udev_input_device_t *dev)

/**
* Function handling incoming udev events pertaining to a touch device.
udev_handle_touch *
*
* @param data Data passed by the callback -> udev_input_t*
* @param event Incoming event.
* @param dev The source device.
Expand Down Expand Up @@ -4361,11 +4361,6 @@ static void udev_input_grab_mouse(void *data, bool state)
}


static bool udev_input_set_sensor_state (void *data, unsigned port, enum retro_sensor_action action, unsigned rate) {
/*TODO*/
RARCH_DBG("udev_input_set_sensor_state: %d %d %d\n", port, action,rate);
return true;
}
static float udev_input_get_sensor_input(void *data, unsigned port, unsigned id) {
const udev_input_t *udev = (const udev_input_t *)data;
const udev_input_sensor_t * sensor;
Expand Down
12 changes: 1 addition & 11 deletions input/input_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,7 @@ 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
};


enum input_device_reservation_type
{
Expand Down
13 changes: 12 additions & 1 deletion libretro-common/include/libretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -7311,7 +7311,18 @@ struct retro_device_power
*/
int8_t percent;
};

enum retro_sensor_selector
{
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_SENSOR_SELECTOR_DUMMY=INT_MAX
};
/** @} */

/**
Expand Down

0 comments on commit ed0e7f4

Please sign in to comment.