Daniele Bartolini 10 年之前
父節點
當前提交
30cada2261
共有 6 個文件被更改,包括 4 次插入72 次删除
  1. 1 3
      src/core/os_event_queue.h
  2. 0 13
      src/input/key_code.h
  3. 1 14
      src/input/keyboard.h
  4. 0 9
      src/lua/lua_keyboard.cpp
  5. 1 17
      src/main/main_linux.cpp
  6. 1 16
      src/main/main_windows.cpp

+ 1 - 3
src/core/os_event_queue.h

@@ -48,7 +48,6 @@ struct OsMouseEvent
 struct OsKeyboardEvent
 {
 	KeyboardButton::Enum button;
-	uint32_t modifier;
 	bool pressed;
 };
 
@@ -155,12 +154,11 @@ struct OsEventQueue
 		push_event(ev);
 	}
 
-	void push_keyboard_event(uint32_t modifier, KeyboardButton::Enum b, bool pressed)
+	void push_keyboard_event(KeyboardButton::Enum b, bool pressed)
 	{
 		OsEvent ev;
 		ev.type = OsEvent::KEYBOARD;
 		ev.keyboard.button = b;
-		ev.keyboard.modifier = modifier;
 		ev.keyboard.pressed = pressed;
 
 		push_event(ev);

+ 0 - 13
src/input/key_code.h

@@ -8,19 +8,6 @@
 namespace crown
 {
 
-/// Enumerates keyboard modifier buttons.
-///
-/// @ingroup Input
-struct ModifierButton
-{
-	enum Enum
-	{
-		SHIFT = 1,
-		CTRL  = 2,
-		ALT   = 4
-	};
-};
-
 /// Enumerates keyboard buttons.
 ///
 /// @ingroup Input

+ 1 - 14
src/input/keyboard.h

@@ -18,23 +18,12 @@ namespace crown
 struct Keyboard
 {
 	Keyboard()
-		: _modifier(0), _last_button(KeyboardButton::NONE)
+		: _last_button(KeyboardButton::NONE)
 	{
 		memset(_last_state, 0, KeyboardButton::COUNT);
 		memset(_current_state, 0, KeyboardButton::COUNT);
 	}
 
-	/// Returns whether the specified @a modifier is pressed.
-	/// @note
-	/// A modifier is a special key that modifies the normal action
-	/// of another key when the two are pressed in combination.
-	/// @note
-	/// Crown currently supports three different modifier keys: Shift, Ctrl and Alt.
-	bool modifier_pressed(ModifierButton::Enum modifier) const
-	{
-		return (_modifier & (uint8_t) modifier) == modifier;
-	}
-
 	/// Returns whether the specified @a b button is pressed in the current frame.
 	bool button_pressed(KeyboardButton::Enum b) const
 	{
@@ -72,8 +61,6 @@ struct Keyboard
 
 public:
 
-	uint8_t _modifier;
-
 	KeyboardButton::Enum _last_button;
 	uint8_t _last_state[KeyboardButton::COUNT];
 	uint8_t _current_state[KeyboardButton::COUNT];

+ 0 - 9
src/lua/lua_keyboard.cpp

@@ -8,18 +8,10 @@
 #include "input.h"
 #include "keyboard.h"
 
-
 namespace crown
 {
 using namespace input_globals;
 
-static int keyboard_modifier_pressed(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_bool(keyboard().modifier_pressed((ModifierButton::Enum) stack.get_int(1)));
-	return 1;
-}
-
 static int keyboard_button_pressed(lua_State* L)
 {
 	LuaStack stack(L);
@@ -50,7 +42,6 @@ static int keyboard_any_released(lua_State* L)
 
 void load_keyboard(LuaEnvironment& env)
 {
-	env.load_module_function("Keyboard", "modifier_pressed", keyboard_modifier_pressed);
 	env.load_module_function("Keyboard", "button_pressed",   keyboard_button_pressed);
 	env.load_module_function("Keyboard", "button_released",  keyboard_button_released);
 	env.load_module_function("Keyboard", "any_pressed",      keyboard_any_pressed);

+ 1 - 17
src/main/main_linux.cpp

@@ -356,23 +356,7 @@ struct LinuxDevice
 					KeySym keysym = XLookupKeysym(&event.xkey, 0);
 					KeyboardButton::Enum kb = x11_translate_key(keysym);
 
-					// Check if any modifier key is pressed or released
-					int32_t modifier_mask = 0;
-
-					if (kb == KeyboardButton::LSHIFT || kb == KeyboardButton::RSHIFT)
-					{
-						(event.type == KeyPress) ? modifier_mask |= ModifierButton::SHIFT : modifier_mask &= ~ModifierButton::SHIFT;
-					}
-					else if (kb == KeyboardButton::LCONTROL || kb == KeyboardButton::RCONTROL)
-					{
-						(event.type == KeyPress) ? modifier_mask |= ModifierButton::CTRL : modifier_mask &= ~ModifierButton::CTRL;
-					}
-					else if (kb == KeyboardButton::LALT || kb == KeyboardButton::RALT)
-					{
-						(event.type == KeyPress) ? modifier_mask |= ModifierButton::ALT : modifier_mask &= ~ModifierButton::ALT;
-					}
-
-					_queue.push_keyboard_event(modifier_mask, kb, event.type == KeyPress);
+					_queue.push_keyboard_event(kb, event.type == KeyPress);
 					break;
 				}
 				case KeymapNotify:

+ 1 - 16
src/main/main_windows.cpp

@@ -277,22 +277,7 @@ struct WindowsDevice
 			{
 				KeyboardButton::Enum kb = win_translate_key(wparam & 0xff);
 
-				int32_t modifier_mask = 0;
-
-				if (kb == KeyboardButton::LSHIFT || kb == KeyboardButton::RSHIFT)
-				{
-					(id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::SHIFT : modifier_mask &= ~ModifierButton::SHIFT;
-				}
-				else if (kb == KeyboardButton::LCONTROL || kb == KeyboardButton::RCONTROL)
-				{
-					(id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::CTRL : modifier_mask &= ~ModifierButton::CTRL;
-				}
-				else if (kb == KeyboardButton::LALT || kb == KeyboardButton::RALT)
-				{
-					(id == WM_KEYDOWN || id == WM_SYSKEYDOWN) ? modifier_mask |= ModifierButton::ALT : modifier_mask &= ~ModifierButton::ALT;
-				}
-
-				_queue.push_keyboard_event(modifier_mask, kb, (id == WM_KEYDOWN || id == WM_SYSKEYDOWN));
+				_queue.push_keyboard_event(kb, (id == WM_KEYDOWN || id == WM_SYSKEYDOWN));
 				break;
 			}
 			default: