mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 19:25:35 +08:00
Fixed issue where GetAnalogActionData magnitude of joystick was always maximum.
This commit is contained in:
parent
663728edca
commit
09704ae243
@ -554,6 +554,10 @@ static void GamepadUpdateStick(GAMEPAD_AXIS* axis, float deadzone) {
|
|||||||
axis->nx = axis->x / axis->length;
|
axis->nx = axis->x / axis->length;
|
||||||
axis->ny = axis->y / axis->length;
|
axis->ny = axis->y / axis->length;
|
||||||
|
|
||||||
|
//fix special case
|
||||||
|
if (axis->nx < -1.0) axis->nx = -1.0;
|
||||||
|
if (axis->ny < -1.0) axis->ny = -1.0;
|
||||||
|
|
||||||
// adjust length for deadzone and find normalized length
|
// adjust length for deadzone and find normalized length
|
||||||
axis->length -= deadzone;
|
axis->length -= deadzone;
|
||||||
axis->length /= (32767.0f - deadzone);
|
axis->length /= (32767.0f - deadzone);
|
||||||
|
@ -495,9 +495,16 @@ ControllerAnalogActionData_t GetAnalogActionData( ControllerHandle_t controllerH
|
|||||||
if (a >= 10) {
|
if (a >= 10) {
|
||||||
int joystick_id = a - 10;
|
int joystick_id = a - 10;
|
||||||
GamepadStickNormXY((GAMEPAD_DEVICE)(controllerHandle - 1), (GAMEPAD_STICK) joystick_id, &data.x, &data.y);
|
GamepadStickNormXY((GAMEPAD_DEVICE)(controllerHandle - 1), (GAMEPAD_STICK) joystick_id, &data.x, &data.y);
|
||||||
|
float length = GamepadStickLength((GAMEPAD_DEVICE)(controllerHandle - 1), (GAMEPAD_STICK) joystick_id);
|
||||||
|
data.x = data.x * length;
|
||||||
|
data.y = data.y * length;
|
||||||
} else {
|
} else {
|
||||||
data.x = GamepadTriggerLength((GAMEPAD_DEVICE)(controllerHandle - 1), (GAMEPAD_TRIGGER) a);
|
data.x = GamepadTriggerLength((GAMEPAD_DEVICE)(controllerHandle - 1), (GAMEPAD_TRIGGER) a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.x || data.y) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
Reference in New Issue
Block a user