Page 1 of 2

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.

Re: Improved keyboard/dpad handling

Posted: Sun Jan 02, 2022 2:37 am
by slacker
Hope to see improved keyboard. I play on both phones/tablets and on Android TV. Gameplay on TV is good, but lack of keyboard shortcuts is a major hassle.

Re: Improved keyboard/dpad handling

Posted: Sun Jan 02, 2022 1:13 pm
by rijackson741
I am not against this, but it is not high priority. Think about the number of players this would benefit relative to the total number of players. I have no way to know exactly what that is, but I am sure it's very small.

Re: Improved keyboard/dpad handling

Posted: Mon Jan 03, 2022 3:42 am
by slacker
Number of users would be small, agreed. But it would make the TV experience much more enjoyable. And, who knows, may drive TV usage.

Re: Improved keyboard/dpad handling

Posted: Mon Jan 03, 2022 4:03 am
by slacker
Guess nothing has changed since 2012.

viewtopic.php?p=21992&hilit=Keyboard#p21992
> Full support for keyboards with key mapping and such is low on our priority list

Re: Improved keyboard/dpad handling

Posted: Mon Jan 03, 2022 6:17 am
by Einsame Hirte
The pull request I submitted last April supports 4- and 8-way dpad controls (both direct and chording) and hot keys for attack, flee, end turn and hero info. Most of the game is playable without touching the screen, although some of the menu navigation is a bit tricky, as I recall - it's been a while since I worked on it. I was planning on working to add additional functions, but gave up when I didn't get any feedback and the dev team's position on the subject became clear (see above).

The patch is showing a conflict against the current master branch, and I don't have the AT development environment set up anymore (it requires an ancient version of Android Studio), but I can set it up again and resolve it if there is actually interest in merging it.

Re: Improved keyboard/dpad handling

Posted: Mon Jan 03, 2022 11:30 am
by Antison
Einsame Hirte wrote: Mon Jan 03, 2022 6:17 am

The patch is showing a conflict against the current master branch, and I don't have the AT development environment set up anymore (it requires an ancient version of Android Studio), but I can set it up again and resolve it if there is actually interest in merging it.
You just hit on one of our biggest needs. Getting the source code and ATCS migrated to the latest version of Java.

Re: Improved keyboard/dpad handling

Posted: Mon Jan 03, 2022 4:14 pm
by Einsame Hirte
I'm not an experienced Android or Java developer (I actually updated AS to start learning Kotlin), so this might be a bit over my head, but can you outline what the major issues are in updating the code?