diff --git a/src/bakara/io/controller_codes.h b/src/bakara/io/controller_codes.h new file mode 100644 index 0000000..e62ebab --- /dev/null +++ b/src/bakara/io/controller_codes.h @@ -0,0 +1,49 @@ +#pragma once +namespace Bk { + /*! \typedef Bk::ControllerCode + Unsigned integer representing a unique controller button + */ + using ControllerCode = uint16_t; + /*! \typedef Bk::ControllerAxesCode + Unsigned integer representing a unique controller axe + */ + using ControllerAxes = uint16_t; + + /*! \enum Bk::ControllerButton + Enumerator made to bind every controller buttons with a Bk::ControllerCode + */ + typedef enum : ControllerCode + { + BTN_DOWN = 0, //!< Cross, A + BTN_LEFT = 1, //!< Square, X + BTN_UP = 2, //!< Triangle, Y + BTN_RIGHT = 3, //!< Circle, B + SHOULDER_LEFT = 4, //!< L1, LB + SHOULDER_RIGHT = 5, //!< R1, RB + TRIGGER_LEFT = 6, //!< L2, LT + TRIGGER_RIGHT = 7, //!< R2, RT + SELECT = 8, //!< Share, Address + START = 9, //!< Options, Menu + LEFT_STICK = 10, //!< L3, LS + RIGHT_STICK = 11, //!< R3, RS + HOME = 12, //!< Home, Home + CLICK = 13, //!< Touch pad, n/a + DPAD_UP = 14, //!< Dpad up, Dpad up + DPAD_RIGHT = 15, //!< Dpad right, Dpad right + DPAD_DOWN = 16, //!< Dpad down, Dpad down + DPAD_LEFT = 17, //!< Dpad left, Dpad left + } ControllerButton; + + /*! \enum Bk::ControllerJoystick + Enum made to bind every controller axes with a Bk::ControllerAxesCode + */ + typedef enum : ControllerAxes + { + AXES_LEFT_STICK_X = 0, + AXES_LEFT_STICK_Y = 1, + AXES_RIGHT_STICK_X = 2, + AXES_LEFT_TRIGGER = 3, + AXES_RIGHT_TRIGGER = 4, + AXES_RIGHT_STICK_Y = 5, + } ControllerJoystick; +} \ No newline at end of file diff --git a/src/bakara/io/input.h b/src/bakara/io/input.h index 3d55ba5..f2164aa 100644 --- a/src/bakara/io/input.h +++ b/src/bakara/io/input.h @@ -7,6 +7,14 @@ namespace Bk { class Input { - + static bool key_down(KeyCode key); + static bool key_released(KeyCode key); + static bool key_pressed(KeyCode key); + + static bool mouse_button_down(MouseCode btn); + static bool mouse_button_released(MouseCode btn); + static bool mouse_button_pressed(MouseCode btn); + + static Vec2 mouse_position(); }; } \ No newline at end of file diff --git a/src/bakara/io/io_codes.h b/src/bakara/io/io_codes.h index cf1a9aa..1cfb6a1 100644 --- a/src/bakara/io/io_codes.h +++ b/src/bakara/io/io_codes.h @@ -5,217 +5,6 @@ Input codes abstraction to be able to use different window api. Can be converte in the good code for the window api by using a lookup table or defines at compilation. */ -namespace Bk { - - /*! \typedef Bk::KeyCode - Unsigned integer representing a unique keyboard key - */ - using KeyCode = uint16_t; - - /*! \enum Bk::KeyCodes - Enumerator made to bind every keyboard keys with a Bk::KeyCode - */ - typedef enum : KeyCode - { - Space = 32, /*!< _ */ - Apostrophe = 39, /*!< ' */ - Comma = 44, /*!< , */ - Minus = 45, /*!< - */ - Period = 46, /*!< . */ - Slash = 47, /*!< / */ - - D0 = 48, /*!< 0 */ - D1 = 49, /*!< 1 */ - D2 = 50, /*!< 2 */ - D3 = 51, /*!< 3 */ - D4 = 52, /*!< 4 */ - D5 = 53, /*!< 5 */ - D6 = 54, /*!< 6 */ - D7 = 55, /*!< 7 */ - D8 = 56, /*!< 8 */ - D9 = 57, /*!< 9 */ - - Semicolon = 59, /*!< ; */ - Equal = 61, /*!< = */ - - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - - LeftBracket = 91, /*!< [ */ - Backslash = 92, /*!< \ */ - RightBracket = 93, /*!< ] */ - GraveAccent = 96, /*!< ` */ - - World1 = 161, /*!< non-US #1 */ - World2 = 162, /*!< non-US #2 */ - - Escape = 256, - Enter = 257, - Tab = 258, - Backspace = 259, - Insert = 260, - Delete = 261, - Right = 262, - Left = 263, - Down = 264, - Up = 265, - PageUp = 266, - PageDown = 267, - Home = 268, - End = 269, - CapsLock = 280, - ScrollLock = 281, - NumLock = 282, - PrintScreen = 283, - Pause = 284, - F1 = 290, - F2 = 291, - F3 = 292, - F4 = 293, - F5 = 294, - F6 = 295, - F7 = 296, - F8 = 297, - F9 = 298, - F10 = 299, - F11 = 300, - F12 = 301, - F13 = 302, - F14 = 303, - F15 = 304, - F16 = 305, - F17 = 306, - F18 = 307, - F19 = 308, - F20 = 309, - F21 = 310, - F22 = 311, - F23 = 312, - F24 = 313, - F25 = 314, - - KP0 = 320, - KP1 = 321, - KP2 = 322, - KP3 = 323, - KP4 = 324, - KP5 = 325, - KP6 = 326, - KP7 = 327, - KP8 = 328, - KP9 = 329, - KPDecimal = 330, - KPDivide = 331, - KPMultiply = 332, - KPSubtract = 333, - KPAdd = 334, - KPEnter = 335, - KPEqual = 336, - - LeftShift = 340, - LeftControl = 341, - LeftAlt = 342, - LeftSuper = 343, - RightShift = 344, - RightControl = 345, - RightAlt = 346, - RightSuper = 347, - Menu = 348 - } KeyCodes; - - /*! \typedef Bk::MouseCode - Unsigned integer representing a unique mouse button - */ - using MouseCode = uint16_t; - - /*! \enum Bk::MouseCodes - Enumerator made to bind every mouse buttons with a Bk::MouseCode - */ - typedef enum : MouseCode - { - Button0 = 0, /*!< Button left */ - Button1 = 1, /*!< Button right */ - Button2 = 2, /*!< Button middle */ - Button3 = 3, /*!< Macro1 */ - Button4 = 4, /*!< Macro2 */ - Button5 = 5, /*!< Macro3 */ - Button6 = 6, /*!< Macro4 */ - Button7 = 7, /*!< Button last */ - - ButtonLast = Button7, - ButtonLeft = Button0, - ButtonRight = Button1, - ButtonMiddle = Button2 - } MouseCodes; - - /*! \typedef Bk::ControllerCode - Unsigned integer representing a unique controller button - */ - using ControllerCode = uint16_t; - /*! \typedef Bk::ControllerAxesCode - Unsigned integer representing a unique controller axe - */ - using ControllerAxesCode = uint16_t; - - /*! \enum Bk::ControllerButton - Enumerator made to bind every controller buttons with a Bk::ControllerCode - */ - typedef enum : ControllerCode - { - BTN_DOWN = 0, //!< Cross, A - BTN_LEFT = 1, //!< Square, X - BTN_UP = 2, //!< Triangle, Y - BTN_RIGHT = 3, //!< Circle, B - SHOULDER_LEFT = 4, //!< L1, LB - SHOULDER_RIGHT = 5, //!< R1, RB - TRIGGER_LEFT = 6, //!< L2, LT - TRIGGER_RIGHT = 7, //!< R2, RT - SELECT = 8, //!< Share, Address - START = 9, //!< Options, Menu - LEFT_STICK = 10, //!< L3, LS - RIGHT_STICK = 11, //!< R3, RS - HOME = 12, //!< Home, Home - CLICK = 13, //!< Touch pad, n/a - DPAD_UP = 14, //!< Dpad up, Dpad up - DPAD_RIGHT = 15, //!< Dpad right, Dpad right - DPAD_DOWN = 16, //!< Dpad down, Dpad down - DPAD_LEFT = 17, //!< Dpad left, Dpad left - } ControllerButton; - - /*! \enum Bk::ControllerJoystick - Enum made to bind every controller axes with a Bk::ControllerAxesCode - */ - typedef enum : ControllerAxesCode - { - AXES_LEFT_STICK_X = 0, - AXES_LEFT_STICK_Y = 1, - AXES_RIGHT_STICK_X = 2, - AXES_LEFT_TRIGGER = 3, - AXES_RIGHT_TRIGGER = 4, - AXES_RIGHT_STICK_Y = 5, - } ControllerJoystick; -} \ No newline at end of file +#include "key_codes.h" +#include "mouse_codes.h" +#include "controller_codes.h" \ No newline at end of file diff --git a/src/bakara/io/key_codes.h b/src/bakara/io/key_codes.h new file mode 100644 index 0000000..7c67dc6 --- /dev/null +++ b/src/bakara/io/key_codes.h @@ -0,0 +1,143 @@ +#pragma once +namespace Bk { + + /*! \typedef Bk::KeyCode + Unsigned integer representing a unique keyboard key + */ + using KeyCode = uint16_t; + + /*! \enum Bk::KeyCodes + Enumerator made to bind every keyboard keys with a Bk::KeyCode + */ + typedef enum : KeyCode + { + Space = 32, /*!< _ */ + Apostrophe = 39, /*!< ' */ + Comma = 44, /*!< , */ + Minus = 45, /*!< - */ + Period = 46, /*!< . */ + Slash = 47, /*!< / */ + + D0 = 48, /*!< 0 */ + D1 = 49, /*!< 1 */ + D2 = 50, /*!< 2 */ + D3 = 51, /*!< 3 */ + D4 = 52, /*!< 4 */ + D5 = 53, /*!< 5 */ + D6 = 54, /*!< 6 */ + D7 = 55, /*!< 7 */ + D8 = 56, /*!< 8 */ + D9 = 57, /*!< 9 */ + + Semicolon = 59, /*!< ; */ + Equal = 61, /*!< = */ + + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + + LeftBracket = 91, /*!< [ */ + Backslash = 92, /*!< \ */ + RightBracket = 93, /*!< ] */ + GraveAccent = 96, /*!< ` */ + + World1 = 161, /*!< non-US #1 */ + World2 = 162, /*!< non-US #2 */ + + Escape = 256, + Enter = 257, + Tab = 258, + Backspace = 259, + Insert = 260, + Delete = 261, + Right = 262, + Left = 263, + Down = 264, + Up = 265, + PageUp = 266, + PageDown = 267, + Home = 268, + End = 269, + CapsLock = 280, + ScrollLock = 281, + NumLock = 282, + PrintScreen = 283, + Pause = 284, + F1 = 290, + F2 = 291, + F3 = 292, + F4 = 293, + F5 = 294, + F6 = 295, + F7 = 296, + F8 = 297, + F9 = 298, + F10 = 299, + F11 = 300, + F12 = 301, + F13 = 302, + F14 = 303, + F15 = 304, + F16 = 305, + F17 = 306, + F18 = 307, + F19 = 308, + F20 = 309, + F21 = 310, + F22 = 311, + F23 = 312, + F24 = 313, + F25 = 314, + + KP0 = 320, + KP1 = 321, + KP2 = 322, + KP3 = 323, + KP4 = 324, + KP5 = 325, + KP6 = 326, + KP7 = 327, + KP8 = 328, + KP9 = 329, + KPDecimal = 330, + KPDivide = 331, + KPMultiply = 332, + KPSubtract = 333, + KPAdd = 334, + KPEnter = 335, + KPEqual = 336, + + LeftShift = 340, + LeftControl = 341, + LeftAlt = 342, + LeftSuper = 343, + RightShift = 344, + RightControl = 345, + RightAlt = 346, + RightSuper = 347, + Menu = 348 + } KeyCodes; +} \ No newline at end of file diff --git a/src/bakara/io/mouse_codes.h b/src/bakara/io/mouse_codes.h new file mode 100644 index 0000000..f17a6d2 --- /dev/null +++ b/src/bakara/io/mouse_codes.h @@ -0,0 +1,27 @@ +#pragma once +namespace Bk { + /*! \typedef Bk::MouseCode + Unsigned integer representing a unique mouse button + */ + using MouseCode = uint16_t; + + /*! \enum Bk::MouseCodes + Enumerator made to bind every mouse buttons with a Bk::MouseCode + */ + typedef enum : MouseCode + { + Button0 = 0, /*!< Button left */ + Button1 = 1, /*!< Button right */ + Button2 = 2, /*!< Button middle */ + Button3 = 3, /*!< Macro1 */ + Button4 = 4, /*!< Macro2 */ + Button5 = 5, /*!< Macro3 */ + Button6 = 6, /*!< Macro4 */ + Button7 = 7, /*!< Button last */ + + ButtonLast = Button7, + ButtonLeft = Button0, + ButtonRight = Button1, + ButtonMiddle = Button2 + } MouseCodes; +} \ No newline at end of file