-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
212 additions
and
28 deletions.
There are no files selected for viewing
Binary file modified
BIN
+431 Bytes
(100%)
app_pojavlauncher/src/main/assets/components/lwjgl3/lwjgl-glfw-classes.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1732218529630 | ||
1735293224932 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...uncher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/direct/DirectGamepad.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
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.sGamepadButtonBuffer; | ||
|
||
import android.util.Log; | ||
import android.view.KeyEvent; | ||
import android.view.MotionEvent; | ||
|
||
import fr.spse.gamepad_remapper.GamepadHandler; | ||
|
||
public class DirectGamepad implements GamepadHandler { | ||
@Override | ||
public void handleGamepadInput(int keycode, float value) { | ||
int gKeycode = -1, gAxis = -1; | ||
switch (keycode) { | ||
case KeyEvent.KEYCODE_BUTTON_A: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_A; break; | ||
case KeyEvent.KEYCODE_BUTTON_B: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_B; break; | ||
case KeyEvent.KEYCODE_BUTTON_X: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_X; break; | ||
case KeyEvent.KEYCODE_BUTTON_Y: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_Y; break; | ||
case KeyEvent.KEYCODE_BUTTON_L1: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_LEFT_BUMPER; break; | ||
case KeyEvent.KEYCODE_BUTTON_R1: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER; break; | ||
case KeyEvent.KEYCODE_BUTTON_L2: | ||
case MotionEvent.AXIS_LTRIGGER: | ||
gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER; | ||
break; | ||
case KeyEvent.KEYCODE_BUTTON_R2: | ||
case MotionEvent.AXIS_RTRIGGER: | ||
gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER; | ||
break; | ||
case KeyEvent.KEYCODE_BUTTON_THUMBL: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_LEFT_THUMB; break; | ||
case KeyEvent.KEYCODE_BUTTON_THUMBR: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_RIGHT_THUMB; break; | ||
case KeyEvent.KEYCODE_BUTTON_START: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_START; break; | ||
case KeyEvent.KEYCODE_BUTTON_SELECT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_BACK; break; | ||
case KeyEvent.KEYCODE_DPAD_UP: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP; 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_RIGHT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT; break; | ||
case KeyEvent.KEYCODE_DPAD_CENTER: break; // TODO | ||
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_Z: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_X; break; | ||
case MotionEvent.AXIS_RZ: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_Y; break; | ||
case AXIS_HAT_X: | ||
sGamepadButtonBuffer.put( | ||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT, | ||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE | ||
); | ||
sGamepadButtonBuffer.put( | ||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, | ||
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE | ||
); | ||
return; | ||
case AXIS_HAT_Y: | ||
sGamepadButtonBuffer.put( | ||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP, | ||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE | ||
); | ||
sGamepadButtonBuffer.put( | ||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN, | ||
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE | ||
); | ||
return; | ||
} | ||
if(gKeycode != -1) { | ||
sGamepadButtonBuffer.put(gKeycode, value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE); | ||
} | ||
if(gAxis != -1) { | ||
sGamepadAxisBuffer.put(gAxis, value); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...cher/src/main/java/net/kdt/pojavlaunch/customcontrols/gamepad/direct/GamepadKeycodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct; | ||
|
||
public class GamepadKeycodes { | ||
public static final byte GLFW_RELEASE = 0; | ||
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_B = 1; | ||
public static final short GLFW_GAMEPAD_BUTTON_X = 2; | ||
public static final short GLFW_GAMEPAD_BUTTON_Y = 3; | ||
public static final short GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4; | ||
public static final short GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5; | ||
public static final short GLFW_GAMEPAD_BUTTON_BACK = 6; | ||
public static final short GLFW_GAMEPAD_BUTTON_START = 7; | ||
public static final short GLFW_GAMEPAD_BUTTON_GUIDE = 8; | ||
public static final short GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9; | ||
public static final short GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10; | ||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_UP = 11; | ||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12; | ||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13; | ||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14; | ||
public static final short GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT; | ||
public static final short GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A; | ||
public static final short GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B; | ||
public static final short GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X; | ||
public static final short GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y; | ||
|
||
public static final short GLFW_GAMEPAD_AXIS_LEFT_X = 0; | ||
public static final short GLFW_GAMEPAD_AXIS_LEFT_Y = 1; | ||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_X = 2; | ||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_Y = 3; | ||
public static final short GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4; | ||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5; | ||
public static final short GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.