]> git.localhorst.tv Git - l2e.git/blobdiff - src/app/Input.h
removed stupid file headers that eclipse put in
[l2e.git] / src / app / Input.h
index ad5086920ac954119cb57ced60041d2fba956c75..f13208e8ebe126dc47b22e3849ef833958346b83 100644 (file)
@@ -1,10 +1,3 @@
-/*
- * Input.h
- *
- *  Created on: Aug 6, 2012
- *      Author: holy
- */
-
 #ifndef APP_INPUT_H_
 #define APP_INPUT_H_
 
 
 namespace app {
 
+/// Maps SDL key events to virtual buttons.
+/// Records the state and whether it was pressed/released in the current
+/// iteration.
+/// Multiple buttons can be passed by ORing them bitwise.
+/// The MapKey(SDLKey, Button) function introduces a mapping for the given key
+/// to the given virtual button. Each key can be assigned to one button only,
+/// but there is no limit (well, except for memory, I guess) on how many keys
+/// may map to the same button.
+/// Each iteration should first call ResetInteractiveState() to drop the just
+/// pressed/released information and then pass each SDL_KeyboardEvent to
+/// HandleKeyboardEvent(const SDL_KeyboardEvent &).
+/// The four DEBUG_? buttons do not map to any real SNES/Lufia 2 button and may
+/// be used for debugging or non-gameplay-related input.
 class Input {
 
 public:
        enum Button {
-               PAD_UP = 1,
-               PAD_RIGHT = 2,
-               PAD_DOWN = 4,
-               PAD_LEFT = 8,
-               ACTION_A = 16,
-               ACTION_B = 32,
-               ACTION_X = 64,
-               ACTION_Y = 128,
-               START = 256,
-               SELECT = 512,
-               SHOULDER_RIGHT = 1024,
-               SHOULDER_LEFT = 2048
+               PAD_UP = 0x0001,
+               PAD_RIGHT = 0x0002,
+               PAD_DOWN = 0x0004,
+               PAD_LEFT = 0x0008,
+               ACTION_A = 0x0010,
+               ACTION_B = 0x0020,
+               ACTION_X = 0x0040,
+               ACTION_Y = 0x0080,
+               START = 0x0100,
+               SELECT = 0x0200,
+               SHOULDER_RIGHT = 0x0400,
+               SHOULDER_LEFT = 0x0800,
+
+               DEBUG_1 = 0x1000,
+               DEBUG_2 = 0x2000,
+               DEBUG_3 = 0x4000,
+               DEBUG_4 = 0x8000,
        };
 
 public:
        Input();
 
 public:
-       bool IsDown(Button b) const {
+       bool IsDown(int b) const {
                return down & b;
        }
-       bool JustPressed(Button b) const {
+       bool JustPressed(int b) const {
                return pressed & b;
        }
-       bool JustReleased(Button b) const {
+       bool JustReleased(int b) const {
                return released & b;
        }