-
Notifications
You must be signed in to change notification settings - Fork 173
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
1 parent
9b4da19
commit 7dea895
Showing
3 changed files
with
200 additions
and
5 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
FCLauncher/src/main/java/com/tungsten/fclauncher/keycodes/GamepadKeycodeMap.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,54 @@ | ||
package com.tungsten.fclauncher.keycodes; | ||
|
||
import android.view.KeyEvent; | ||
|
||
import java.util.HashMap; | ||
|
||
public class GamepadKeycodeMap { | ||
private static final HashMap<Integer, Integer> KEY_MAP = new HashMap<>(); | ||
private static final int MOUSE_LEFT = 1000; | ||
private static final int MOUSE_MIDDLE = 1001; | ||
private static final int MOUSE_RIGHT = 1002; | ||
private static final int MOUSE_SCROLL_UP = 1003; | ||
private static final int MOUSE_SCROLL_DOWN = 1004; | ||
public static final int LEFT_JOYSTICK_RIGHT = 2000; | ||
public static final int LEFT_JOYSTICK_UP = 2002; | ||
public static final int LEFT_JOYSTICK_LEFT = 2004; | ||
public static final int LEFT_JOYSTICK_DOWN = 2006; | ||
|
||
private static void add(int key, int value) { | ||
KEY_MAP.put(key, value); | ||
} | ||
|
||
//todo: custom keycode | ||
public static void modify(int key, int value) { | ||
KEY_MAP.replace(key, value); | ||
} | ||
|
||
public static int convert(int key) { | ||
return KEY_MAP.getOrDefault(key, -1); | ||
} | ||
|
||
static { | ||
add(KeyEvent.KEYCODE_BUTTON_A, FCLKeycodes.KEY_SPACE); | ||
add(KeyEvent.KEYCODE_BUTTON_B, FCLKeycodes.KEY_Q); | ||
add(KeyEvent.KEYCODE_BUTTON_X, FCLKeycodes.KEY_E); | ||
add(KeyEvent.KEYCODE_BUTTON_Y, FCLKeycodes.KEY_F); | ||
add(KeyEvent.KEYCODE_BUTTON_L1, MOUSE_SCROLL_UP); | ||
add(KeyEvent.KEYCODE_BUTTON_R1, MOUSE_SCROLL_DOWN); | ||
add(KeyEvent.KEYCODE_BUTTON_L2, MOUSE_LEFT); | ||
add(KeyEvent.KEYCODE_BUTTON_R2, MOUSE_RIGHT); | ||
add(KeyEvent.KEYCODE_BUTTON_THUMBL, FCLKeycodes.KEY_LEFTCTRL); | ||
add(KeyEvent.KEYCODE_BUTTON_THUMBR, FCLKeycodes.KEY_LEFTSHIFT); | ||
add(KeyEvent.KEYCODE_BUTTON_START, FCLKeycodes.KEY_ESC); | ||
add(KeyEvent.KEYCODE_BUTTON_SELECT, FCLKeycodes.KEY_TAB); | ||
add(KeyEvent.KEYCODE_DPAD_UP, FCLKeycodes.KEY_LEFTSHIFT); | ||
add(KeyEvent.KEYCODE_DPAD_DOWN, FCLKeycodes.KEY_O); | ||
add(KeyEvent.KEYCODE_DPAD_LEFT, FCLKeycodes.KEY_J); | ||
add(KeyEvent.KEYCODE_DPAD_RIGHT, FCLKeycodes.KEY_K); | ||
add(LEFT_JOYSTICK_UP, FCLKeycodes.KEY_W); | ||
add(LEFT_JOYSTICK_DOWN, FCLKeycodes.KEY_S); | ||
add(LEFT_JOYSTICK_LEFT, FCLKeycodes.KEY_A); | ||
add(LEFT_JOYSTICK_RIGHT, FCLKeycodes.KEY_D); | ||
} | ||
} |