update SDL3 from 3.2.20 to 3.4.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
/* Gamepad image */
|
||||
|
||||
#ifndef gamepadutils_h_
|
||||
#define gamepadutils_h_
|
||||
|
||||
typedef struct GamepadImage GamepadImage;
|
||||
|
||||
typedef enum
|
||||
@@ -48,7 +51,19 @@ enum
|
||||
#define PRESSED_COLOR 175, 238, 238, SDL_ALPHA_OPAQUE
|
||||
#define PRESSED_TEXTURE_MOD 175, 238, 238
|
||||
#define SELECTED_COLOR 224, 255, 224, SDL_ALPHA_OPAQUE
|
||||
#define GYRO_COLOR_RED 255, 0, 0, SDL_ALPHA_OPAQUE
|
||||
#define GYRO_COLOR_GREEN 0, 255, 0, SDL_ALPHA_OPAQUE
|
||||
#define GYRO_COLOR_BLUE 0, 0, 255, SDL_ALPHA_OPAQUE
|
||||
#define GYRO_COLOR_ORANGE 255, 128, 0, SDL_ALPHA_OPAQUE
|
||||
|
||||
/* Shared layout constants */
|
||||
#define BUTTON_PADDING 12.0f
|
||||
#define MINIMUM_BUTTON_WIDTH 96.0f
|
||||
|
||||
/* Symbol */
|
||||
#define DEGREE_UTF8 "\xC2\xB0"
|
||||
#define SQUARED_UTF8 "\xC2\xB2"
|
||||
#define MICRO_UTF8 "\xC2\xB5"
|
||||
/* Gamepad image display */
|
||||
|
||||
extern GamepadImage *CreateGamepadImage(SDL_Renderer *renderer);
|
||||
@@ -78,6 +93,7 @@ typedef struct GamepadDisplay GamepadDisplay;
|
||||
extern GamepadDisplay *CreateGamepadDisplay(SDL_Renderer *renderer);
|
||||
extern void SetGamepadDisplayDisplayMode(GamepadDisplay *ctx, ControllerDisplayMode display_mode);
|
||||
extern void SetGamepadDisplayArea(GamepadDisplay *ctx, const SDL_FRect *area);
|
||||
extern void SetGamepadDisplayGyroDriftCorrection(GamepadDisplay *ctx, float *gyro_drift_correction);
|
||||
extern int GetGamepadDisplayElementAt(GamepadDisplay *ctx, SDL_Gamepad *gamepad, float x, float y);
|
||||
extern void SetGamepadDisplayHighlight(GamepadDisplay *ctx, int element, bool pressed);
|
||||
extern void SetGamepadDisplaySelected(GamepadDisplay *ctx, int element);
|
||||
@@ -118,6 +134,7 @@ extern void DestroyJoystickDisplay(JoystickDisplay *ctx);
|
||||
typedef struct GamepadButton GamepadButton;
|
||||
|
||||
extern GamepadButton *CreateGamepadButton(SDL_Renderer *renderer, const char *label);
|
||||
extern void SetGamepadButtonLabel(GamepadButton *ctx, const char *label);
|
||||
extern void SetGamepadButtonArea(GamepadButton *ctx, const SDL_FRect *area);
|
||||
extern void GetGamepadButtonArea(GamepadButton *ctx, SDL_FRect *area);
|
||||
extern void SetGamepadButtonHighlight(GamepadButton *ctx, bool highlight, bool pressed);
|
||||
@@ -127,6 +144,35 @@ extern bool GamepadButtonContains(GamepadButton *ctx, float x, float y);
|
||||
extern void RenderGamepadButton(GamepadButton *ctx);
|
||||
extern void DestroyGamepadButton(GamepadButton *ctx);
|
||||
|
||||
/* Gyro element Display */
|
||||
|
||||
/* This is used as the initial noise tolerance threshold. It's set very close to zero to avoid divide by zero while we're evaluating the noise profile. Each controller may have a very different noise profile.*/
|
||||
#define ACCELEROMETER_NOISE_THRESHOLD 1e-6f
|
||||
/* The value below is based on observation of a Dualshock controller. Of all gamepads observed, the Dualshock (PS4) tends to have one of the noisiest accelerometers. Increase this threshold if a controller is failing to pass the noise profiling stage while stationary on a table. */
|
||||
#define ACCELEROMETER_MAX_NOISE_G 0.075f
|
||||
#define ACCELEROMETER_MAX_NOISE_G_SQ (ACCELEROMETER_MAX_NOISE_G * ACCELEROMETER_MAX_NOISE_G)
|
||||
|
||||
/* Gyro Calibration Phases */
|
||||
typedef enum
|
||||
{
|
||||
GYRO_CALIBRATION_PHASE_OFF, /* Calibration has not yet been evaluated - signal to the user to put the controller on a flat surface before beginning the calibration process */
|
||||
GYRO_CALIBRATION_PHASE_NOISE_PROFILING, /* Find the max accelerometer noise for a fixed period */
|
||||
GYRO_CALIBRATION_PHASE_DRIFT_PROFILING, /* Find the drift while the accelerometer is below the accelerometer noise tolerance */
|
||||
GYRO_CALIBRATION_PHASE_COMPLETE, /* Calibration has finished */
|
||||
} EGyroCalibrationPhase;
|
||||
|
||||
typedef struct Quaternion Quaternion;
|
||||
typedef struct GyroDisplay GyroDisplay;
|
||||
|
||||
extern void InitCirclePoints3D(void);
|
||||
extern GyroDisplay *CreateGyroDisplay(SDL_Renderer *renderer);
|
||||
extern void SetGyroDisplayArea(GyroDisplay *ctx, const SDL_FRect *area);
|
||||
extern void SetGamepadDisplayIMUValues(GyroDisplay *ctx, float *gyro_drift_solution, float *euler_displacement_angles, Quaternion *gyro_quaternion, int reported_senor_rate_hz, int estimated_sensor_rate_hz, EGyroCalibrationPhase calibration_phase, float drift_calibration_progress_frac, float accelerometer_noise_sq, float accelerometer_noise_tolerance_sq);
|
||||
extern GamepadButton *GetGyroResetButton(GyroDisplay *ctx);
|
||||
extern GamepadButton *GetGyroCalibrateButton(GyroDisplay *ctx);
|
||||
extern void RenderGyroDisplay(GyroDisplay *ctx, GamepadDisplay *gamepadElements, SDL_Gamepad *gamepad);
|
||||
extern void DestroyGyroDisplay(GyroDisplay *ctx);
|
||||
|
||||
/* Working with mappings and bindings */
|
||||
|
||||
/* Return whether a mapping has any bindings */
|
||||
@@ -167,3 +213,5 @@ extern bool MappingHasBinding(const char *mapping, const char *binding);
|
||||
|
||||
/* Clear any previous binding */
|
||||
extern char *ClearMappingBinding(char *mapping, const char *binding);
|
||||
|
||||
#endif /* gamepadutils_h_ */
|
||||
|
||||
Reference in New Issue
Block a user