mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
cmd/ebitenmobile: remove counting buttons and use a constant instead
Updates #2309
This commit is contained in:
parent
db1255cdf8
commit
d66c599938
@ -545,15 +545,6 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
||||
return;
|
||||
}
|
||||
|
||||
boolean[] keyExistences = inputDevice.hasKeys(gamepadButtons);
|
||||
int nbuttons = 0;
|
||||
for (int i = 0; i < gamepadButtons.length; i++) {
|
||||
if (!keyExistences[i]) {
|
||||
break;
|
||||
}
|
||||
nbuttons++;
|
||||
}
|
||||
|
||||
int naxes = 0;
|
||||
int nhats2 = 0;
|
||||
for (int i = 0; i < axes.length; i++) {
|
||||
@ -576,7 +567,7 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
||||
int buttonMask = getButtonMask(inputDevice);
|
||||
int axisMask = getAxisMask(inputDevice);
|
||||
|
||||
Ebitenmobileview.onGamepadAdded(deviceId, inputDevice.getName(), nbuttons, naxes, nhats2/2, descriptor, vendorId, productId, buttonMask, axisMask);
|
||||
Ebitenmobileview.onGamepadAdded(deviceId, inputDevice.getName(), naxes, nhats2/2, descriptor, vendorId, productId, buttonMask, axisMask);
|
||||
}
|
||||
|
||||
// The implementation is copied from SDL:
|
||||
|
File diff suppressed because one or more lines are too long
@ -28,8 +28,8 @@ const (
|
||||
AndroidHatDirectionY
|
||||
)
|
||||
|
||||
func AddAndroidGamepad(androidDeviceID int, name, sdlID string, axisCount, buttonCount, hatCount int) {
|
||||
theGamepads.addAndroidGamepad(androidDeviceID, name, sdlID, axisCount, buttonCount, hatCount)
|
||||
func AddAndroidGamepad(androidDeviceID int, name, sdlID string, axisCount, hatCount int) {
|
||||
theGamepads.addAndroidGamepad(androidDeviceID, name, sdlID, axisCount, hatCount)
|
||||
}
|
||||
|
||||
func RemoveAndroidGamepad(androidDeviceID int) {
|
||||
@ -48,7 +48,7 @@ func UpdateAndroidGamepadHat(androidDeviceID int, hat int, dir AndroidHatDirecti
|
||||
theGamepads.updateAndroidGamepadHat(androidDeviceID, hat, dir, value)
|
||||
}
|
||||
|
||||
func (g *gamepads) addAndroidGamepad(androidDeviceID int, name, sdlID string, axisCount, buttonCount, hatCount int) {
|
||||
func (g *gamepads) addAndroidGamepad(androidDeviceID int, name, sdlID string, axisCount, hatCount int) {
|
||||
g.m.Lock()
|
||||
defer g.m.Unlock()
|
||||
|
||||
@ -56,7 +56,7 @@ func (g *gamepads) addAndroidGamepad(androidDeviceID int, name, sdlID string, ax
|
||||
gp.native = &nativeGamepadImpl{
|
||||
androidDeviceID: androidDeviceID,
|
||||
axes: make([]float64, axisCount),
|
||||
buttons: make([]bool, buttonCount),
|
||||
buttons: make([]bool, ButtonCount),
|
||||
hats: make([]int, hatCount),
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func OnGamepadAxesOrHatsChanged(deviceID int, axisID int, value float32) {
|
||||
}
|
||||
}
|
||||
|
||||
func OnGamepadAdded(deviceID int, name string, buttonCount int, axisCount int, hatCount int, descriptor string, vendorID int, productID int, buttonMask int, axisMask int) {
|
||||
func OnGamepadAdded(deviceID int, name string, axisCount int, hatCount int, descriptor string, vendorID int, productID int, buttonMask int, axisMask int) {
|
||||
// This emulates the implementation of Android_AddJoystick.
|
||||
// https://github.com/libsdl-org/SDL/blob/0e9560aea22818884921e5e5064953257bfe7fa7/src/joystick/android/SDL_sysjoystick.c#L386
|
||||
const SDL_HARDWARE_BUS_BLUETOOTH = 0x05
|
||||
@ -280,7 +280,7 @@ func OnGamepadAdded(deviceID int, name string, buttonCount int, axisCount int, h
|
||||
sdlid[14] = byte(axisMask)
|
||||
sdlid[15] = byte(axisMask >> 8)
|
||||
|
||||
gamepad.AddAndroidGamepad(deviceID, name, hex.EncodeToString(sdlid[:]), axisCount, buttonCount, hatCount)
|
||||
gamepad.AddAndroidGamepad(deviceID, name, hex.EncodeToString(sdlid[:]), axisCount, hatCount)
|
||||
}
|
||||
|
||||
func OnInputDeviceRemoved(deviceID int) {
|
||||
|
Loading…
Reference in New Issue
Block a user