Page 1 of 1

Improved keyboard/dpad handling

Posted: Sat Apr 17, 2021 5:23 pm
by Einsame Hirte
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).

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);
Please see the notes on the pull request for additional info.

Re: Improved keyboard/dpad handling

Posted: Sat Apr 17, 2021 5:37 pm
by Antison
I really don't see a need for keyboard support as the game is designed for touch screen on mobile devices (phones mostly, but tablets are supported to some extend) and don't have a need for a keyboard.

Re: Improved keyboard/dpad handling

Posted: Thu Apr 22, 2021 3:23 pm
by Einsame Hirte
To be clear, this patch doesn't add keyboard support; it just improves what is already there. And while playing on the touch screen is certainly the most convenient for casual gaming, there are some advantages to using a dpad or keyboard - not least avoiding RSI from constant tapping during combat (someone actually complained about this on Google Play). Even without this patch, grinding is a LOT easier with a keyboard/dpad - you just walk into the monster and it keeps hitting them until they die (or they get a critical hit and kill you because you're not paying enough attention).

Decent keyboard support may also open it up to more players, including disabled people with alternate input devices, and possibly platforms like Android TV (hypothetically; I don't know much about it).

And every rogue-like I've played uses a keyboard, starting with vi-style HJKL in hack. It's tradition, if nothing else.