KeyCodes, MouseCodes
- Added nameless enums for KeyCodes and MouseCodes - Removed InputCodes
This commit is contained in:
		
							parent
							
								
									55869f6106
								
							
						
					
					
						commit
						c34f5e03f0
					
				
					 6 changed files with 223 additions and 149 deletions
				
			
		| 
						 | 
				
			
			@ -1,136 +0,0 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#define MOUSE_BUTTON_1    0
 | 
			
		||||
#define MOUSE_BUTTON_2    1
 | 
			
		||||
#define MOUSE_BUTTON_3    2
 | 
			
		||||
#define MOUSE_BUTTON_4    3
 | 
			
		||||
#define MOUSE_BUTTON_5    4
 | 
			
		||||
#define MOUSE_BUTTON_6    5
 | 
			
		||||
#define MOUSE_BUTTON_7    6
 | 
			
		||||
#define MOUSE_BUTTON_8    7
 | 
			
		||||
 | 
			
		||||
#define MOUSE_BUTTON_LEFT     MOUSE_BUTTON_1
 | 
			
		||||
#define MOUSE_BUTTON_RIGHT    MOUSE_BUTTON_2
 | 
			
		||||
#define MOUSE_BUTTON_MIDDLE   MOUSE_BUTTON_3
 | 
			
		||||
 | 
			
		||||
#define KEY_SPACE            32
 | 
			
		||||
#define KEY_APOSTROPHE       39 /* ' */
 | 
			
		||||
#define KEY_COMMA            44 /* , */
 | 
			
		||||
#define KEY_MINUS            45 /* - */
 | 
			
		||||
#define KEY_PERIOD           46 /* . */
 | 
			
		||||
#define KEY_SLASH            47 /* / */
 | 
			
		||||
#define KEY_0                48
 | 
			
		||||
#define KEY_1                49
 | 
			
		||||
#define KEY_2                50
 | 
			
		||||
#define KEY_3                51
 | 
			
		||||
#define KEY_4                52
 | 
			
		||||
#define KEY_5                53
 | 
			
		||||
#define KEY_6                54
 | 
			
		||||
#define KEY_7                55
 | 
			
		||||
#define KEY_8                56
 | 
			
		||||
#define KEY_9                57
 | 
			
		||||
#define KEY_SEMICOLON        59 /* ; */
 | 
			
		||||
#define KEY_EQUAL            61 /* = */
 | 
			
		||||
#define KEY_A                65
 | 
			
		||||
#define KEY_B                66
 | 
			
		||||
#define KEY_C                67
 | 
			
		||||
#define KEY_D                68
 | 
			
		||||
#define KEY_E                69
 | 
			
		||||
#define KEY_F                70
 | 
			
		||||
#define KEY_G                71
 | 
			
		||||
#define KEY_H                72
 | 
			
		||||
#define KEY_I                73
 | 
			
		||||
#define KEY_J                74
 | 
			
		||||
#define KEY_K                75
 | 
			
		||||
#define KEY_L                76
 | 
			
		||||
#define KEY_M                77
 | 
			
		||||
#define KEY_N                78
 | 
			
		||||
#define KEY_O                79
 | 
			
		||||
#define KEY_P                80
 | 
			
		||||
#define KEY_Q                81
 | 
			
		||||
#define KEY_R                82
 | 
			
		||||
#define KEY_S                83
 | 
			
		||||
#define KEY_T                84
 | 
			
		||||
#define KEY_U                85
 | 
			
		||||
#define KEY_V                86
 | 
			
		||||
#define KEY_W                87
 | 
			
		||||
#define KEY_X                88
 | 
			
		||||
#define KEY_Y                89
 | 
			
		||||
#define KEY_Z                90
 | 
			
		||||
#define KEY_LEFT_BRACKET     91 /* [ */
 | 
			
		||||
#define KEY_BACKSLASH        92 /* \ */
 | 
			
		||||
#define KEY_RIGHT_BRACKET    93 /* ] */
 | 
			
		||||
#define KEY_GRAVE_ACCENT     96 /* ` */
 | 
			
		||||
#define KEY_WORLD_1          161 /* non-US #1 */
 | 
			
		||||
#define KEY_WORLD_2          162 /* non-US #2 */
 | 
			
		||||
#define KEY_ESCAPE           256
 | 
			
		||||
#define KEY_ESC              KEY_ESCAPE
 | 
			
		||||
#define KEY_ENTER            257
 | 
			
		||||
#define KEY_TAB              258
 | 
			
		||||
#define KEY_BACKSPACE        259
 | 
			
		||||
#define KEY_INSERT           260
 | 
			
		||||
#define KEY_DELETE           261
 | 
			
		||||
#define KEY_RIGHT            262
 | 
			
		||||
#define KEY_LEFT             263
 | 
			
		||||
#define KEY_DOWN             264
 | 
			
		||||
#define KEY_UP               265
 | 
			
		||||
#define KEY_PAGE_UP          266
 | 
			
		||||
#define KEY_PAGE_DOWN        267
 | 
			
		||||
#define KEY_HOME             268
 | 
			
		||||
#define KEY_END              269
 | 
			
		||||
#define KEY_CAPS_LOCK        280
 | 
			
		||||
#define KEY_SCROLL_LOCK      281
 | 
			
		||||
#define KEY_NUM_LOCK         282
 | 
			
		||||
#define KEY_PRINT_SCREEN     283
 | 
			
		||||
#define KEY_PAUSE            284
 | 
			
		||||
#define KEY_F1               290
 | 
			
		||||
#define KEY_F2               291
 | 
			
		||||
#define KEY_F3               292
 | 
			
		||||
#define KEY_F4               293
 | 
			
		||||
#define KEY_F5               294
 | 
			
		||||
#define KEY_F6               295
 | 
			
		||||
#define KEY_F7               296
 | 
			
		||||
#define KEY_F8               297
 | 
			
		||||
#define KEY_F9               298
 | 
			
		||||
#define KEY_F10              299
 | 
			
		||||
#define KEY_F11              300
 | 
			
		||||
#define KEY_F12              301
 | 
			
		||||
#define KEY_F13              302
 | 
			
		||||
#define KEY_F14              303
 | 
			
		||||
#define KEY_F15              304
 | 
			
		||||
#define KEY_F16              305
 | 
			
		||||
#define KEY_F17              306
 | 
			
		||||
#define KEY_F18              307
 | 
			
		||||
#define KEY_F19              308
 | 
			
		||||
#define KEY_F20              309
 | 
			
		||||
#define KEY_F21              310
 | 
			
		||||
#define KEY_F22              311
 | 
			
		||||
#define KEY_F23              312
 | 
			
		||||
#define KEY_F24              313
 | 
			
		||||
#define KEY_F25              314
 | 
			
		||||
#define KEY_KP_0             320
 | 
			
		||||
#define KEY_KP_1             321
 | 
			
		||||
#define KEY_KP_2             322
 | 
			
		||||
#define KEY_KP_3             323
 | 
			
		||||
#define KEY_KP_4             324
 | 
			
		||||
#define KEY_KP_5             325
 | 
			
		||||
#define KEY_KP_6             326
 | 
			
		||||
#define KEY_KP_7             327
 | 
			
		||||
#define KEY_KP_8             328
 | 
			
		||||
#define KEY_KP_9             329
 | 
			
		||||
#define KEY_KP_DECIMAL       330
 | 
			
		||||
#define KEY_KP_DIVIDE        331
 | 
			
		||||
#define KEY_KP_MULTIPLY      332
 | 
			
		||||
#define KEY_KP_SUBTRACT      333
 | 
			
		||||
#define KEY_KP_ADD           334
 | 
			
		||||
#define KEY_KP_ENTER         335
 | 
			
		||||
#define KEY_KP_EQUAL         336
 | 
			
		||||
#define KEY_LEFT_SHIFT       340
 | 
			
		||||
#define KEY_LEFT_CONTROL     341
 | 
			
		||||
#define KEY_LEFT_ALT         342
 | 
			
		||||
#define KEY_LEFT_SUPER       343
 | 
			
		||||
#define KEY_RIGHT_SHIFT      344
 | 
			
		||||
#define KEY_RIGHT_CONTROL    345
 | 
			
		||||
#define KEY_RIGHT_ALT        346
 | 
			
		||||
#define KEY_RIGHT_SUPER      347
 | 
			
		||||
#define KEY_MENU             348
 | 
			
		||||
							
								
								
									
										183
									
								
								Engine/src/Engine/Input/KeyCodes.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								Engine/src/Engine/Input/KeyCodes.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,183 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	namespace Key
 | 
			
		||||
	{
 | 
			
		||||
		enum : uint16_t
 | 
			
		||||
		{
 | 
			
		||||
			/* DIGITS */
 | 
			
		||||
			D0              = 48,
 | 
			
		||||
			D1              = 49,
 | 
			
		||||
			D2              = 50,
 | 
			
		||||
			D3              = 51,
 | 
			
		||||
			D4              = 52,
 | 
			
		||||
			D5              = 53,
 | 
			
		||||
			D6              = 54,
 | 
			
		||||
			D7              = 55,
 | 
			
		||||
			D8              = 56,
 | 
			
		||||
			D9              = 57,
 | 
			
		||||
			Semicolon       = 59, // ;
 | 
			
		||||
			Equal           = 61, // =
 | 
			
		||||
 | 
			
		||||
			/* LETTERS */
 | 
			
		||||
			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,
 | 
			
		||||
 | 
			
		||||
			/* BRACKETS */
 | 
			
		||||
			LeftBracket     = 91, // [
 | 
			
		||||
			LBracket        = LeftBracket, // [
 | 
			
		||||
			RightBracket    = 93, // ]
 | 
			
		||||
			RBracket        = RightBracket, // ]
 | 
			
		||||
 | 
			
		||||
			/* ARROW */
 | 
			
		||||
			Right           = 262,
 | 
			
		||||
			RightArrow      = Right,
 | 
			
		||||
			RArrow          = Right,
 | 
			
		||||
			Left            = 263,
 | 
			
		||||
			LeftArrow       = Left,
 | 
			
		||||
			LArrow          = Left,
 | 
			
		||||
			Down            = 264,
 | 
			
		||||
			DownArrow       = Down,
 | 
			
		||||
			DArrow          = Down,
 | 
			
		||||
			Up              = 265,
 | 
			
		||||
			UpArrow         = Up,
 | 
			
		||||
			UArrow          = Up,
 | 
			
		||||
 | 
			
		||||
			/* PAGE */
 | 
			
		||||
			PageUp          = 266,
 | 
			
		||||
			PageDown        = 267,
 | 
			
		||||
 | 
			
		||||
			/* HOME/END */
 | 
			
		||||
			Home            = 268,
 | 
			
		||||
			End             = 269,
 | 
			
		||||
 | 
			
		||||
			/* LOCKS */
 | 
			
		||||
			CapsLock        = 280,
 | 
			
		||||
			ScrollLock      = 281,
 | 
			
		||||
			NumLock         = 282,
 | 
			
		||||
			NumberLock      = NumLock,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			PrintScreen     = 283,
 | 
			
		||||
			Pause           = 284,
 | 
			
		||||
 | 
			
		||||
			/* FUNCTION */
 | 
			
		||||
			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,
 | 
			
		||||
 | 
			
		||||
			/* KEYPAD */
 | 
			
		||||
			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,
 | 
			
		||||
			KpSubstract     = 333,
 | 
			
		||||
			KpAdd           = 334,
 | 
			
		||||
			KpEnter         = 335,
 | 
			
		||||
			KpEqual         = 336,
 | 
			
		||||
 | 
			
		||||
			/* Modifiers */
 | 
			
		||||
			LeftShift       = 340,
 | 
			
		||||
			LShift          = LeftShift,
 | 
			
		||||
			LeftControl     = 341,
 | 
			
		||||
			LControl        = LeftControl,
 | 
			
		||||
			LeftAlt         = 342,
 | 
			
		||||
			LAlt            = LeftAlt,
 | 
			
		||||
			LeftSuper       = 343,
 | 
			
		||||
			LSuper          = LeftSuper,
 | 
			
		||||
			RightShift      = 344,
 | 
			
		||||
			RShift          = 344,
 | 
			
		||||
			RightControl    = 345,
 | 
			
		||||
			RControl        = 345,
 | 
			
		||||
			RightAlt        = 346,
 | 
			
		||||
			RAlt            = 346,
 | 
			
		||||
			RightSuper      = 347,
 | 
			
		||||
			RSuper          = 347,
 | 
			
		||||
 | 
			
		||||
			/* MISC */
 | 
			
		||||
			Space           = 32,
 | 
			
		||||
			Apostrophe      = 39, // '
 | 
			
		||||
			Quote           = Apostrophe,
 | 
			
		||||
			
 | 
			
		||||
			GraveAccent     = 96, // `
 | 
			
		||||
			Console         = GraveAccent,
 | 
			
		||||
			World1          = 161, // non-US #1
 | 
			
		||||
			World2          = 162, // non-US #2
 | 
			
		||||
			Escape          = 256,
 | 
			
		||||
			Esc             = Escape,
 | 
			
		||||
			Enter           = 257,
 | 
			
		||||
			Tab             = 258,
 | 
			
		||||
			BackSpace       = 259,
 | 
			
		||||
			Insert          = 260,
 | 
			
		||||
			Delete          = 261,
 | 
			
		||||
 | 
			
		||||
			Comma           = 44, // ,
 | 
			
		||||
			Minus           = 45, // -
 | 
			
		||||
			Period          = 46, // .
 | 
			
		||||
			Slash           = 47, // /
 | 
			
		||||
			ForwardSlash    = Slash, // /
 | 
			
		||||
			BackSlash       = 92, // \
 | 
			
		||||
 | 
			
		||||
			Menu            = 348,
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								Engine/src/Engine/Input/MouseCodes.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Engine/src/Engine/Input/MouseCodes.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	namespace Mouse
 | 
			
		||||
	{
 | 
			
		||||
		enum : uint8_t
 | 
			
		||||
		{
 | 
			
		||||
			Button1 = 0,
 | 
			
		||||
			Button2 = 1,
 | 
			
		||||
			Button3 = 2,
 | 
			
		||||
			Button4 = 3,
 | 
			
		||||
			Button5 = 4,
 | 
			
		||||
			Button6 = 5,
 | 
			
		||||
			Button7 = 6,
 | 
			
		||||
			Button8 = 7,
 | 
			
		||||
 | 
			
		||||
			LButton = Button1,
 | 
			
		||||
			RButton = Button2,
 | 
			
		||||
			MButton = Button3,
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,8 @@
 | 
			
		|||
 | 
			
		||||
//** INPUT **//
 | 
			
		||||
#include "Input/Input.h"
 | 
			
		||||
#include "Input/InputCodes.h"
 | 
			
		||||
#include "Input/KeyCodes.h"
 | 
			
		||||
#include "Input/MouseCodes.h"
 | 
			
		||||
 | 
			
		||||
//** LAYER **//
 | 
			
		||||
#include "Layer/Layer.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,16 +85,16 @@ namespace Light {
 | 
			
		|||
 | 
			
		||||
		void OnUpdate(float deltaTime) override
 | 
			
		||||
		{
 | 
			
		||||
			if (Input::GetKeyboardKey(KEY_A))
 | 
			
		||||
			if (Input::GetKeyboardKey(Key::A))
 | 
			
		||||
				m_Direction.x = -1.0f;
 | 
			
		||||
			else if (Input::GetKeyboardKey(KEY_D))
 | 
			
		||||
			else if (Input::GetKeyboardKey(Key::D))
 | 
			
		||||
				m_Direction.x = 1.0f;
 | 
			
		||||
			else
 | 
			
		||||
				m_Direction.x = 0.0f;
 | 
			
		||||
 | 
			
		||||
			if (Input::GetKeyboardKey(KEY_W))
 | 
			
		||||
			if (Input::GetKeyboardKey(Key::W))
 | 
			
		||||
				m_Direction.y = 1.0f;
 | 
			
		||||
			else if (Input::GetKeyboardKey(KEY_S))
 | 
			
		||||
			else if (Input::GetKeyboardKey(Key::S))
 | 
			
		||||
				m_Direction.y = -1.0f;
 | 
			
		||||
			else
 | 
			
		||||
				m_Direction.y = 0.0f;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,14 +47,14 @@ public:
 | 
			
		|||
 | 
			
		||||
	bool OnKeyPressed(const Light::KeyPressedEvent& event) override
 | 
			
		||||
	{
 | 
			
		||||
		if (event.GetKey() == 65) // GLFW_KEY_A
 | 
			
		||||
		if (event.GetKey() == Light::Key::A)
 | 
			
		||||
			m_Direction.x +=  -1.0f;
 | 
			
		||||
		if(event.GetKey() == 68)  // GLFW_KEY_D
 | 
			
		||||
		if(event.GetKey() == Light::Key::D)
 | 
			
		||||
			m_Direction.x += 1.0f;
 | 
			
		||||
 | 
			
		||||
		if (event.GetKey() == 87) // GLFW_KEY_W
 | 
			
		||||
		if (event.GetKey() == Light::Key::W)
 | 
			
		||||
			m_Direction.y +=  1.0f;
 | 
			
		||||
		if (event.GetKey() == 83) // GLFW_KEY_S
 | 
			
		||||
		if (event.GetKey() == Light::Key::S)
 | 
			
		||||
			m_Direction.y += -1.0f;
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,14 +63,14 @@ public:
 | 
			
		|||
	bool OnKeyReleased(const Light::KeyReleasedEvent& event) override
 | 
			
		||||
	{
 | 
			
		||||
		// #todo: add input class
 | 
			
		||||
		if (event.GetKey() == 65)  // GLFW_KEY_A
 | 
			
		||||
		if (event.GetKey() == Light::Key::A)
 | 
			
		||||
			m_Direction.x -= -1.0f;
 | 
			
		||||
		if (event.GetKey() == 68)  // GLFW_KEY_D
 | 
			
		||||
		if (event.GetKey() == Light::Key::D)
 | 
			
		||||
			m_Direction.x -= 1.0f;
 | 
			
		||||
 | 
			
		||||
		if (event.GetKey() == 87) // GLFW_KEY_W
 | 
			
		||||
		if (event.GetKey() == Light::Key::W)
 | 
			
		||||
			m_Direction.y -=  1.0f;
 | 
			
		||||
		if (event.GetKey() == 83) // GLFW_KEY_S
 | 
			
		||||
		if (event.GetKey() == Light::Key::S)
 | 
			
		||||
			m_Direction.y -= -1.0f;
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue