Add support for sensor to joystick on Linux (evdev)

This commit is contained in:
meyraud705
2023-05-11 19:51:07 +02:00
committed by Sam Lantinga
parent 95727b5c7d
commit 000277060c
2 changed files with 437 additions and 44 deletions
File diff suppressed because it is too large Load Diff
+19
View File
@@ -25,12 +25,16 @@
#include <linux/input.h>
struct SDL_joylist_item;
struct SDL_sensorlist_item;
/* The private structure used to keep track of a joystick */
struct joystick_hwdata
{
int fd;
/* linux driver creates a separate device for gyro/accelerometer */
int fd_sensor;
struct SDL_joylist_item *item;
struct SDL_sensorlist_item *item_sensor;
SDL_JoystickGUID guid;
char *fname; /* Used in haptic subsystem */
@@ -50,6 +54,8 @@ struct joystick_hwdata
Uint8 abs_map[ABS_MAX];
SDL_bool has_key[KEY_MAX];
SDL_bool has_abs[ABS_MAX];
SDL_bool has_accelerometer;
SDL_bool has_gyro;
/* Support for the classic joystick interface */
SDL_bool classic;
@@ -69,8 +75,20 @@ struct joystick_hwdata
float scale;
} abs_correct[ABS_MAX];
float accelerometer_scale[3];
float gyro_scale[3];
/* Each axis is read independently, if we don't get all axis this call to
* LINUX_JoystickUpdateupdate(), store them for the next one */
float gyro_data[3];
float accel_data[3];
Uint64 sensor_tick;
Sint32 last_tick;
SDL_bool report_sensor;
SDL_bool fresh;
SDL_bool recovering_from_dropped;
SDL_bool recovering_from_dropped_sensor;
/* Steam Controller support */
SDL_bool m_bSteamController;
@@ -87,6 +105,7 @@ struct joystick_hwdata
/* Set when gamepad is pending removal due to ENODEV read error */
SDL_bool gone;
SDL_bool sensor_gone;
};
#endif /* SDL_sysjoystick_c_h_ */