1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Joystick: Remap joystick-specific KeyTypes to generic ones

According to the following table:
	* MOUSE_L     -> DIG
	* MOUSE_R     -> PLACE
	* SCROLL_UP   -> HOTBAR_NEXT
	* SCROLL_DOWN -> HOTBAR_PREV

This commit entirely removes the special KeyTypes used for joysticks.

Support for the MOUSE KeyTypes had already been removed in the main
game code without adapting the joystick code, breaking joystick
input. This commit restores joystick functionality.
This commit is contained in:
Markus Koch 2020-11-07 17:45:32 +01:00 committed by sfan5
parent 7589cbe086
commit e1142ee57f
3 changed files with 17 additions and 27 deletions

View file

@ -2014,15 +2014,11 @@ void Game::processItemSelection(u16 *new_playeritem)
s32 dir = wheel;
if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN) ||
wasKeyDown(KeyType::HOTBAR_NEXT)) {
if (wasKeyDown(KeyType::HOTBAR_NEXT))
dir = -1;
}
if (input->joystick.wasKeyDown(KeyType::SCROLL_UP) ||
wasKeyDown(KeyType::HOTBAR_PREV)) {
if (wasKeyDown(KeyType::HOTBAR_PREV))
dir = 1;
}
if (dir < 0)
*new_playeritem = *new_playeritem < max_item ? *new_playeritem + 1 : 0;
@ -3138,11 +3134,11 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
input->clearWasKeyPressed();
input->clearWasKeyReleased();
input->joystick.clearWasKeyDown(KeyType::MOUSE_L);
input->joystick.clearWasKeyDown(KeyType::MOUSE_R);
input->joystick.clearWasKeyDown(KeyType::DIG);
input->joystick.clearWasKeyDown(KeyType::PLACE);
input->joystick.clearWasKeyReleased(KeyType::MOUSE_L);
input->joystick.clearWasKeyReleased(KeyType::MOUSE_R);
input->joystick.clearWasKeyReleased(KeyType::DIG);
input->joystick.clearWasKeyReleased(KeyType::PLACE);
}