mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 14:08:28 +00:00
Android: indicate gamepaddb entries where axis order changed.
Axis order was changed in 6f1f586086
to improve
default mappings.
This commit is contained in:

committed by
Sam Lantinga

parent
3e28588bb6
commit
de3909a190
@@ -299,12 +299,11 @@ 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 nhats)
|
||||
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)
|
||||
{
|
||||
SDL_joylist_item *item;
|
||||
SDL_JoystickGUID guid;
|
||||
int i;
|
||||
int axis_mask;
|
||||
int result = -1;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
@@ -331,22 +330,6 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v
|
||||
SDL_Log("Joystick: %s, descriptor %s, vendor = 0x%.4x, product = 0x%.4x, %d axes, %d hats\n", name, desc, vendor_id, product_id, naxes, nhats);
|
||||
#endif
|
||||
|
||||
/* Add the available buttons and axes
|
||||
The axis mask should probably come from Java where there is more information about the axes...
|
||||
*/
|
||||
axis_mask = 0;
|
||||
if (!is_accelerometer) {
|
||||
if (naxes >= 2) {
|
||||
axis_mask |= ((1 << SDL_GAMEPAD_AXIS_LEFTX) | (1 << SDL_GAMEPAD_AXIS_LEFTY));
|
||||
}
|
||||
if (naxes >= 4) {
|
||||
axis_mask |= ((1 << SDL_GAMEPAD_AXIS_RIGHTX) | (1 << SDL_GAMEPAD_AXIS_RIGHTY));
|
||||
}
|
||||
if (naxes >= 6) {
|
||||
axis_mask |= ((1 << SDL_GAMEPAD_AXIS_LEFT_TRIGGER) | (1 << SDL_GAMEPAD_AXIS_RIGHT_TRIGGER));
|
||||
}
|
||||
}
|
||||
|
||||
if (nhats > 0) {
|
||||
/* Hat is translated into DPAD buttons */
|
||||
button_mask |= ((1 << SDL_GAMEPAD_BUTTON_DPAD_UP) |
|
||||
@@ -479,7 +462,7 @@ static int ANDROID_JoystickInit(void)
|
||||
|
||||
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, 0);
|
||||
Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0x0003, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user