mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/gamepaddb: fix the assignment of axes for Android
Updates #2309
This commit is contained in:
parent
f414e25b9d
commit
4a851bcf27
@ -550,7 +550,7 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
|||||||
for (int i = 0; i < axes.length; i++) {
|
for (int i = 0; i < axes.length; i++) {
|
||||||
InputDevice.MotionRange range = inputDevice.getMotionRange(axes[i], InputDevice.SOURCE_JOYSTICK);
|
InputDevice.MotionRange range = inputDevice.getMotionRange(axes[i], InputDevice.SOURCE_JOYSTICK);
|
||||||
if (range == null) {
|
if (range == null) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (range.getAxis() == MotionEvent.AXIS_HAT_X || range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
if (range.getAxis() == MotionEvent.AXIS_HAT_X || range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
||||||
nhats2++;
|
nhats2++;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -741,7 +741,7 @@ func addAndroidDefaultMappings(id string) bool {
|
|||||||
if axisMask&(1<<SDLControllerAxisLeftX) != 0 {
|
if axisMask&(1<<SDLControllerAxisLeftX) != 0 {
|
||||||
gamepadAxisMappings[id][StandardAxisLeftStickHorizontal] = &mapping{
|
gamepadAxisMappings[id][StandardAxisLeftStickHorizontal] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisLeftX,
|
Index: 0,
|
||||||
AxisScale: 1,
|
AxisScale: 1,
|
||||||
AxisOffset: 0,
|
AxisOffset: 0,
|
||||||
}
|
}
|
||||||
@ -749,23 +749,27 @@ func addAndroidDefaultMappings(id string) bool {
|
|||||||
if axisMask&(1<<SDLControllerAxisLeftY) != 0 {
|
if axisMask&(1<<SDLControllerAxisLeftY) != 0 {
|
||||||
gamepadAxisMappings[id][StandardAxisLeftStickVertical] = &mapping{
|
gamepadAxisMappings[id][StandardAxisLeftStickVertical] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisLeftY,
|
Index: 1,
|
||||||
AxisScale: 1,
|
AxisScale: 1,
|
||||||
AxisOffset: 0,
|
AxisOffset: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if axisMask&(1<<SDLControllerAxisRightX) != 0 {
|
if axisMask&(1<<SDLControllerAxisRightX) != 0 {
|
||||||
|
// https://developer.android.com/reference/android/view/MotionEvent#AXIS_Z
|
||||||
|
// > On game pads with two analog joysticks, this axis is often reinterpreted to report the absolute X position of the second joystick instead.
|
||||||
gamepadAxisMappings[id][StandardAxisRightStickHorizontal] = &mapping{
|
gamepadAxisMappings[id][StandardAxisRightStickHorizontal] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisRightX,
|
Index: 2,
|
||||||
AxisScale: 1,
|
AxisScale: 1,
|
||||||
AxisOffset: 0,
|
AxisOffset: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if axisMask&(1<<SDLControllerAxisRightY) != 0 {
|
if axisMask&(1<<SDLControllerAxisRightY) != 0 {
|
||||||
|
// https://developer.android.com/reference/android/view/MotionEvent#AXIS_RZ
|
||||||
|
// > On game pads with two analog joysticks, this axis is often reinterpreted to report the absolute Y position of the second joystick instead.
|
||||||
gamepadAxisMappings[id][StandardAxisRightStickVertical] = &mapping{
|
gamepadAxisMappings[id][StandardAxisRightStickVertical] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisRightY,
|
Index: 5,
|
||||||
AxisScale: 1,
|
AxisScale: 1,
|
||||||
AxisOffset: 0,
|
AxisOffset: 0,
|
||||||
}
|
}
|
||||||
@ -773,17 +777,17 @@ func addAndroidDefaultMappings(id string) bool {
|
|||||||
if axisMask&(1<<SDLControllerAxisTriggerLeft) != 0 {
|
if axisMask&(1<<SDLControllerAxisTriggerLeft) != 0 {
|
||||||
gamepadButtonMappings[id][StandardButtonFrontBottomLeft] = &mapping{
|
gamepadButtonMappings[id][StandardButtonFrontBottomLeft] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisTriggerLeft,
|
Index: 6,
|
||||||
AxisScale: 1,
|
AxisScale: 2,
|
||||||
AxisOffset: 0,
|
AxisOffset: -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if axisMask&(1<<SDLControllerAxisTriggerRight) != 0 {
|
if axisMask&(1<<SDLControllerAxisTriggerRight) != 0 {
|
||||||
gamepadButtonMappings[id][StandardButtonFrontBottomRight] = &mapping{
|
gamepadButtonMappings[id][StandardButtonFrontBottomRight] = &mapping{
|
||||||
Type: mappingTypeAxis,
|
Type: mappingTypeAxis,
|
||||||
Index: SDLControllerAxisTriggerRight,
|
Index: 7,
|
||||||
AxisScale: 1,
|
AxisScale: 2,
|
||||||
AxisOffset: 0,
|
AxisOffset: -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user