aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2018-01-06 11:34:03 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-20 16:38:38 +0100
commit362323cdc209956a3d35d8ec7ea03ec31b580d88 (patch)
treedbc07869d43064cc7e054dcbc6225f14e5ecd4a6 /src/client
parent9649e4721467dab348011633c814a63a184bd018 (diff)
downloadminetest-362323cdc209956a3d35d8ec7ea03ec31b580d88.tar.gz
minetest-362323cdc209956a3d35d8ec7ea03ec31b580d88.tar.bz2
minetest-362323cdc209956a3d35d8ec7ea03ec31b580d88.zip
Game/Input refactor [1/X]: make RealInputHandler handle joystick inputs with standard input
Joystick input is a RealInputHandler only usage, make it intelligent and handle the joystick with keyboard direct. This permits to remove many getters in game which should be owned by RealInputHandler
Diffstat (limited to 'src/client')
-rw-r--r--src/client/inputhandler.h59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/client/inputhandler.h b/src/client/inputhandler.h
index 165c75990..c7c29510d 100644
--- a/src/client/inputhandler.h
+++ b/src/client/inputhandler.h
@@ -259,18 +259,53 @@ public:
}
}
- virtual bool getLeftState() { return m_receiver->left_active; }
- virtual bool getRightState() { return m_receiver->right_active; }
-
- virtual bool getLeftClicked() { return m_receiver->leftclicked; }
- virtual bool getRightClicked() { return m_receiver->rightclicked; }
- virtual void resetLeftClicked() { m_receiver->leftclicked = false; }
- virtual void resetRightClicked() { m_receiver->rightclicked = false; }
-
- virtual bool getLeftReleased() { return m_receiver->leftreleased; }
- virtual bool getRightReleased() { return m_receiver->rightreleased; }
- virtual void resetLeftReleased() { m_receiver->leftreleased = false; }
- virtual void resetRightReleased() { m_receiver->rightreleased = false; }
+ virtual bool getLeftState()
+ {
+ return m_receiver->left_active || joystick.isKeyDown(KeyType::MOUSE_L);
+ }
+ virtual bool getRightState()
+ {
+ return m_receiver->right_active || joystick.isKeyDown(KeyType::MOUSE_R);
+ }
+
+ virtual bool getLeftClicked()
+ {
+ return m_receiver->leftclicked || joystick.getWasKeyDown(KeyType::MOUSE_L);
+ }
+ virtual bool getRightClicked()
+ {
+ return m_receiver->rightclicked || joystick.getWasKeyDown(KeyType::MOUSE_R);
+ }
+
+ virtual void resetLeftClicked()
+ {
+ m_receiver->leftclicked = false;
+ joystick.clearWasKeyDown(KeyType::MOUSE_L);
+ }
+ virtual void resetRightClicked() {
+ m_receiver->rightclicked = false;
+ joystick.clearWasKeyDown(KeyType::MOUSE_R);
+ }
+
+ virtual bool getLeftReleased()
+ {
+ return m_receiver->leftreleased || joystick.wasKeyReleased(KeyType::MOUSE_L);
+ }
+ virtual bool getRightReleased()
+ {
+ return m_receiver->rightreleased || joystick.wasKeyReleased(KeyType::MOUSE_R);
+ }
+
+ virtual void resetLeftReleased()
+ {
+ m_receiver->leftreleased = false;
+ joystick.clearWasKeyReleased(KeyType::MOUSE_L);
+ }
+ virtual void resetRightReleased()
+ {
+ m_receiver->rightreleased = false;
+ joystick.clearWasKeyReleased(KeyType::MOUSE_R);
+ }
virtual s32 getMouseWheel() { return m_receiver->getMouseWheel(); }