mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-27 21:48:29 +00:00
Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK
Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days. Closes https://github.com/libsdl-org/SDL/pull/7879
This commit is contained in:
@@ -52,8 +52,6 @@
|
||||
#define AKEYCODE_BUTTON_16 203
|
||||
#endif
|
||||
|
||||
#define ANDROID_ACCELEROMETER_NAME "Android Accelerometer"
|
||||
#define ANDROID_ACCELEROMETER_DEVICE_ID INT_MIN
|
||||
#define ANDROID_MAX_NBUTTONS 36
|
||||
|
||||
static SDL_joylist_item *JoystickByDeviceId(int device_id);
|
||||
@@ -303,7 +301,7 @@ int Android_OnHat(int device_id, int hat_id, int x, int y)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int axis_mask, int nhats)
|
||||
int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats)
|
||||
{
|
||||
SDL_joylist_item *item;
|
||||
SDL_JoystickGUID guid;
|
||||
@@ -366,7 +364,6 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
|
||||
goto done;
|
||||
}
|
||||
|
||||
item->is_accelerometer = is_accelerometer;
|
||||
if (button_mask == 0xFFFFFFFF) {
|
||||
item->nbuttons = ANDROID_MAX_NBUTTONS;
|
||||
} else {
|
||||
@@ -463,11 +460,6 @@ static void ANDROID_JoystickDetect(void);
|
||||
static int ANDROID_JoystickInit(void)
|
||||
{
|
||||
ANDROID_JoystickDetect();
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
|
||||
/* Default behavior, accelerometer as joystick */
|
||||
Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0x0003, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -614,31 +606,6 @@ static int ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool en
|
||||
|
||||
static void ANDROID_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item->is_accelerometer) {
|
||||
int i;
|
||||
Sint16 value;
|
||||
float values[3];
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (Android_JNI_GetAccelerometerValues(values)) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (values[i] > 1.0f) {
|
||||
values[i] = 1.0f;
|
||||
} else if (values[i] < -1.0f) {
|
||||
values[i] = -1.0f;
|
||||
}
|
||||
|
||||
value = (Sint16)(values[i] * 32767.0f);
|
||||
SDL_SendJoystickAxis(timestamp, item->joystick, i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ANDROID_JoystickClose(SDL_Joystick *joystick)
|
||||
|
Reference in New Issue
Block a user