Improved keyboard/dpad handling
Posted: Sat Apr 17, 2021 5:23 pm
I just submitted a draft pull request for improved keyboard and dpad input handling, including diagonals and keys for attack, flee, end turn, and the hero info screen. I'm interested in what people think would be good choices for these shortcut keys. Ultimately, there should be a way for the player to choose them, but at least initially they'll probably need to be hard coded. The current mappings are below; I tried to pick keys that are easy to use for the different available input methods (WASD, arrows, numpad).
Note that the Attack and Flee keys freeze motion while pressed to allow initial diagonal movement on 4-way controllers/WASD/arrow keys (these controls combine two key events for diagonals, so one will always get processed first resulting an initial orthogonal movement if not frozen).
Please see the notes on the pull request for additional info.
Note that the Attack and Flee keys freeze motion while pressed to allow initial diagonal movement on 4-way controllers/WASD/arrow keys (these controls combine two key events for diagonals, so one will always get processed first resulting an initial orthogonal movement if not frozen).
Code: Select all
// Keys mapping to ATTACK
key = KEY_ATTACK;
keyMap.put(KeyEvent.KEYCODE_DPAD_CENTER, key);
keyMap.put(KeyEvent.KEYCODE_BUTTON_A, key);
keyMap.put(KeyEvent.KEYCODE_SPACE, key);
keyMap.put(KeyEvent.KEYCODE_NUMPAD_5, key);
// Keys mapping to FLEE
key = KEY_FLEE;
keyMap.put(KeyEvent.KEYCODE_BUTTON_X, key);
keyMap.put(KeyEvent.KEYCODE_F, key);
keyMap.put(KeyEvent.KEYCODE_NUMPAD_ENTER, key);
keyMap.put(KeyEvent.KEYCODE_ENTER, key);
// Keys mapping to END_TURN
key = KEY_END_TURN;
keyMap.put(KeyEvent.KEYCODE_BUTTON_Y, key);
keyMap.put(KeyEvent.KEYCODE_E, key);
keyMap.put(KeyEvent.KEYCODE_FORWARD_DEL, key);
keyMap.put(KeyEvent.KEYCODE_NUMPAD_DOT, key);
// Keys mapping to HERO_INFO
key = KEY_HERO_INFO;
//keyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, key);
keyMap.put(KeyEvent.KEYCODE_BUTTON_L1, key);
keyMap.put(KeyEvent.KEYCODE_NUM_LOCK, key);
keyMap.put(KeyEvent.KEYCODE_C, key);
// Keys mapping to TOOLBOX ((DOES NOT WORK YET)
key = KEY_TOOLBOX;
keyMap.put(KeyEvent.KEYCODE_BUTTON_R1, key);
keyMap.put(KeyEvent.KEYCODE_NUMPAD_DIVIDE, key);
keyMap.put(KeyEvent.KEYCODE_B, key);