mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 06:39:54 -04:00
Feat[gamepad_direct]: remove unnecessary strings, improve documentation
This commit is contained in:
parent
f0005fa912
commit
13d0f97558
@ -454,6 +454,11 @@ public class Gamepad implements GrabListener, GamepadHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the Gamepad and removes all traces of the Gamepad from the view hierarchy.
|
||||||
|
* After this call, the Gamepad is not recoverable and a new one must be made.
|
||||||
|
*/
|
||||||
public void removeSelf() {
|
public void removeSelf() {
|
||||||
mRemoved = true;
|
mRemoved = true;
|
||||||
mMapProvider.detachGrabListener(this);
|
mMapProvider.detachGrabListener(this);
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
||||||
|
|
||||||
import static android.view.MotionEvent.AXIS_HAT_X;
|
|
||||||
import static android.view.MotionEvent.AXIS_HAT_Y;
|
|
||||||
import static org.lwjgl.glfw.CallbackBridge.sGamepadAxisBuffer;
|
import static org.lwjgl.glfw.CallbackBridge.sGamepadAxisBuffer;
|
||||||
import static org.lwjgl.glfw.CallbackBridge.sGamepadButtonBuffer;
|
import static org.lwjgl.glfw.CallbackBridge.sGamepadButtonBuffer;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
@ -38,12 +35,19 @@ public class DirectGamepad implements GamepadHandler {
|
|||||||
case KeyEvent.KEYCODE_DPAD_DOWN: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN; break;
|
case KeyEvent.KEYCODE_DPAD_DOWN: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN; break;
|
||||||
case KeyEvent.KEYCODE_DPAD_LEFT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT; break;
|
case KeyEvent.KEYCODE_DPAD_LEFT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT; break;
|
||||||
case KeyEvent.KEYCODE_DPAD_RIGHT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT; break;
|
case KeyEvent.KEYCODE_DPAD_RIGHT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT; break;
|
||||||
case KeyEvent.KEYCODE_DPAD_CENTER: break; // TODO
|
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||||
|
// Behave the same way as the Gamepad here, as GLFW doesn't have a keycode
|
||||||
|
// for the dpad center.
|
||||||
|
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP, GamepadKeycodes.GLFW_RELEASE);
|
||||||
|
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN, GamepadKeycodes.GLFW_RELEASE);
|
||||||
|
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT, GamepadKeycodes.GLFW_RELEASE);
|
||||||
|
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, GamepadKeycodes.GLFW_RELEASE);
|
||||||
|
return;
|
||||||
case MotionEvent.AXIS_X: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_X; break;
|
case MotionEvent.AXIS_X: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_X; break;
|
||||||
case MotionEvent.AXIS_Y: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_Y; break;
|
case MotionEvent.AXIS_Y: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_Y; break;
|
||||||
case MotionEvent.AXIS_Z: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_X; break;
|
case MotionEvent.AXIS_Z: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_X; break;
|
||||||
case MotionEvent.AXIS_RZ: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_Y; break;
|
case MotionEvent.AXIS_RZ: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_Y; break;
|
||||||
case AXIS_HAT_X:
|
case MotionEvent.AXIS_HAT_X:
|
||||||
sGamepadButtonBuffer.put(
|
sGamepadButtonBuffer.put(
|
||||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT,
|
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||||
@ -53,7 +57,7 @@ public class DirectGamepad implements GamepadHandler {
|
|||||||
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
case AXIS_HAT_Y:
|
case MotionEvent.AXIS_HAT_Y:
|
||||||
sGamepadButtonBuffer.put(
|
sGamepadButtonBuffer.put(
|
||||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP,
|
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP,
|
||||||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface that is called once when the GLFW implementation requests to switch from
|
||||||
|
* the default gamepad implementation to the direct one. The implementor of this interface
|
||||||
|
* must take the necessary steps to disable the default gamepad implementation and replace
|
||||||
|
* it with an instance of DirectGamepad.
|
||||||
|
|
||||||
|
* This is useful for switching from default to direct input after the user has already
|
||||||
|
* interacted with the gamepad.
|
||||||
|
*/
|
||||||
public interface DirectGamepadEnableHandler {
|
public interface DirectGamepadEnableHandler {
|
||||||
|
/**
|
||||||
|
* Called once when GLFW requests switching the gamepad mode from default to direct.
|
||||||
|
*/
|
||||||
void onDirectGamepadEnabled();
|
void onDirectGamepadEnabled();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
|||||||
public class GamepadKeycodes {
|
public class GamepadKeycodes {
|
||||||
public static final byte GLFW_RELEASE = 0;
|
public static final byte GLFW_RELEASE = 0;
|
||||||
public static final byte GLFW_PRESS = 1;
|
public static final byte GLFW_PRESS = 1;
|
||||||
public static int NUM_KEYCODES = 0;
|
|
||||||
|
|
||||||
public static final short GLFW_GAMEPAD_BUTTON_A = 0;
|
public static final short GLFW_GAMEPAD_BUTTON_A = 0;
|
||||||
public static final short GLFW_GAMEPAD_BUTTON_B = 1;
|
public static final short GLFW_GAMEPAD_BUTTON_B = 1;
|
||||||
|
@ -22,7 +22,8 @@ public class CallbackBridge {
|
|||||||
public static final Choreographer sChoreographer = Choreographer.getInstance();
|
public static final Choreographer sChoreographer = Choreographer.getInstance();
|
||||||
private static boolean isGrabbing = false;
|
private static boolean isGrabbing = false;
|
||||||
private static final ArrayList<GrabListener> grabListeners = new ArrayList<>();
|
private static final ArrayList<GrabListener> grabListeners = new ArrayList<>();
|
||||||
private static WeakReference<DirectGamepadEnableHandler> sDirectGamepadEnableHandler;
|
// Use a weak reference here to avoid possibly statically referencing a Context.
|
||||||
|
private static @Nullable WeakReference<DirectGamepadEnableHandler> sDirectGamepadEnableHandler;
|
||||||
|
|
||||||
public static final int CLIPBOARD_COPY = 2000;
|
public static final int CLIPBOARD_COPY = 2000;
|
||||||
public static final int CLIPBOARD_PASTE = 2001;
|
public static final int CLIPBOARD_PASTE = 2001;
|
||||||
|
@ -422,6 +422,4 @@
|
|||||||
<string name="local_login_bad_username_title">Unsuitable username</string>
|
<string name="local_login_bad_username_title">Unsuitable username</string>
|
||||||
<string name="local_login_bad_username_text">The username must be between 3–16 characters long, and must only contain latin letters, arabic numerals and underscores.</string>
|
<string name="local_login_bad_username_text">The username must be between 3–16 characters long, and must only contain latin letters, arabic numerals and underscores.</string>
|
||||||
<string name="quick_setting_title">Quick settings</string>
|
<string name="quick_setting_title">Quick settings</string>
|
||||||
<string name="preference_direct_controller_title">Use direct controller input</string>
|
|
||||||
<string name="preference_direct_controller_description">Disables keyboard/mouse emulation and lets the game use gamepad inputs directly.</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user