Path: blob/master/thirdparty/sdl/joystick/linux/SDL_sysjoystick_c.h
9906 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021#ifndef SDL_sysjoystick_c_h_22#define SDL_sysjoystick_c_h_2324#include <linux/input.h>2526struct SDL_joylist_item;27struct SDL_sensorlist_item;2829// The private structure used to keep track of a joystick30struct joystick_hwdata31{32int fd;33// linux driver creates a separate device for gyro/accelerometer34int fd_sensor;35struct SDL_joylist_item *item;36struct SDL_sensorlist_item *item_sensor;37SDL_GUID guid;38char *fname; // Used in haptic subsystem3940bool ff_rumble;41bool ff_sine;42struct ff_effect effect;43Uint32 effect_expiration;4445// The current Linux joystick driver maps balls to two axes46struct hwdata_ball47{48int axis[2];49} *balls;5051// The current Linux joystick driver maps hats to two axes52struct hwdata_hat53{54int axis[2];55} *hats;5657// Support for the Linux 2.4 unified input interface58Uint8 key_map[KEY_MAX];59Uint8 abs_map[ABS_MAX];60bool has_key[KEY_MAX];61bool has_abs[ABS_MAX];62bool has_accelerometer;63bool has_gyro;6465// Support for the classic joystick interface66bool classic;67Uint16 *key_pam;68Uint8 *abs_pam;6970struct axis_correct71{72bool use_deadzones;7374// Deadzone coefficients75int coef[3];7677// Raw coordinate scale78int minimum;79int maximum;80float scale;81} abs_correct[ABS_MAX];8283float accelerometer_scale[3];84float gyro_scale[3];8586/* Each axis is read independently, if we don't get all axis this call to87* LINUX_JoystickUpdateupdate(), store them for the next one */88float gyro_data[3];89float accel_data[3];90Uint64 sensor_tick;91Sint32 last_tick;9293bool report_sensor;94bool fresh;95bool recovering_from_dropped;96bool recovering_from_dropped_sensor;9798// Steam Controller support99bool m_bSteamController;100101// 4 = (ABS_HAT3X-ABS_HAT0X)/2 (see input-event-codes.h in kernel)102int hats_indices[4];103bool has_hat[4];104struct hat_axis_correct105{106bool use_deadzones;107int minimum[2];108int maximum[2];109} hat_correct[4];110111// Set when gamepad is pending removal due to ENODEV read error112bool gone;113bool sensor_gone;114};115116#endif // SDL_sysjoystick_c_h_117118119