]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/inputhandler.h
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / src / client / inputhandler.h
index 3db105c518ecf6d066d1436247b6f558e3f1f21c..47a61d4b85ba86f6b5f454295170ab2ccfcdae6b 100644 (file)
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #endif
 
 class InputHandler;
+class TouchScreenGUI;
 
 /****************************************************************************
  Fast key cache for main game loop
@@ -201,7 +202,6 @@ class MyEventReceiver : public IEventReceiver
        TouchScreenGUI *m_touchscreengui;
 #endif
 
-private:
        s32 mouse_wheel = 0;
 
        // The current state of keys
@@ -241,6 +241,8 @@ class InputHandler
        }
 
        virtual bool isKeyDown(GameKeyType k) = 0;
+       virtual void setKeypress(const KeyPress &keyCode) = 0;
+       virtual void unsetKeypress(const KeyPress &keyCode) = 0;
        virtual bool wasKeyDown(GameKeyType k) = 0;
        virtual bool wasKeyPressed(GameKeyType k) = 0;
        virtual bool wasKeyReleased(GameKeyType k) = 0;
@@ -288,6 +290,15 @@ class RealInputHandler : public InputHandler
        {
                return m_receiver->IsKeyDown(keycache.key[k]) || joystick.isKeyDown(k);
        }
+       virtual void setKeypress(const KeyPress &keyCode)
+       {
+               m_receiver->keyIsDown.set(keyCode);
+               m_receiver->keyWasDown.set(keyCode);
+       }
+       virtual void unsetKeypress(const KeyPress &keyCode)
+       {
+               m_receiver->keyIsDown.unset(keyCode);
+       }
        virtual bool wasKeyDown(GameKeyType k)
        {
                return m_receiver->WasKeyDown(keycache.key[k]) || joystick.wasKeyDown(k);
@@ -411,6 +422,14 @@ class RandomInputHandler : public InputHandler
        }
 
        virtual bool isKeyDown(GameKeyType k) { return keydown[keycache.key[k]]; }
+       virtual void setKeypress(const KeyPress &keyCode)
+       {
+               keydown.set(keyCode);
+       }
+       virtual void unsetKeypress(const KeyPress &keyCode)
+       {
+               keydown.unset(keyCode);
+       }
        virtual bool wasKeyDown(GameKeyType k) { return false; }
        virtual bool wasKeyPressed(GameKeyType k) { return false; }
        virtual bool wasKeyReleased(GameKeyType k) { return false; }