Răsfoiți Sursa

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini 10 ani în urmă
părinte
comite
de2a20dc80

+ 0 - 1
src/core/containers/container_types.h

@@ -139,7 +139,6 @@ struct Map
 	};
 
 	uint32_t _root;
-	uint32_t _sentinel;
 	Vector<Node> _data;
 };
 

+ 81 - 135
src/core/containers/map.h

@@ -8,7 +8,7 @@
 #include "container_types.h"
 #include "vector.h"
 
-// #define RBTREE_VERIFY
+#define RBTREE_VERIFY
 
 namespace crown
 {
@@ -46,9 +46,9 @@ namespace map
 
 namespace map_internal
 {
-	const uint32_t BLACK = 0xB1B1B1B1u;
-	const uint32_t RED = 0xEDEDEDEDu;
-	const uint32_t NIL = 0xFFFFFFFFu;
+	const uint32_t BLACK = 0xb1b1b1b1u;
+	const uint32_t RED = 0xededededu;
+	const uint32_t NIL = 0xffffffff;
 
 	template <typename TKey, typename TValue>
 	inline uint32_t root(const Map<TKey, TValue>& m)
@@ -80,26 +80,27 @@ namespace map_internal
 	template <typename TKey, typename TValue>
 	inline uint32_t color(const Map<TKey, TValue>& m, uint32_t n)
 	{
+		if (n == NIL) return BLACK;
 		CE_ASSERT(n < vector::size(m._data), "Index out of bounds (size = %d, n = %d)", vector::size(m._data), n);
 		return m._data[n].color;
 	}
 
-	#ifdef RBTREE_VERIFY
+#ifdef RBTREE_VERIFY
 	template<typename TKey, typename TValue>
 	inline int32_t dbg_verify(Map<TKey, TValue>& m, uint32_t n)
 	{
-		if (n == m._sentinel)
+		if (n == NIL)
 		{
 			return 0;
 		}
 
-		if (left(m, n) != m._sentinel)
+		if (left(m, n) != NIL)
 		{
 			CE_ASSERT(parent(m, left(m, n)) == n, "Bad RBTree");
 			CE_ASSERT(m._data[left(m, n)].key < m._data[n].key, "Bad RBTree");
 		}
 
-		if (right(m, n) != m._sentinel)
+		if (right(m, n) != NIL)
 		{
 			CE_ASSERT(parent(m, right(m, n)) == n, "Bad RBTree");
 			CE_ASSERT(m._data[n].key < m._data[right(m, n)].key, "Bad RBTree");
@@ -134,20 +135,16 @@ namespace map_internal
 		printf("\n");
 		return 0;
 	}
-	#endif
+#endif // RBTREE_VERIFY
 
 	template <typename TKey, typename TValue>
 	inline uint32_t min(const Map<TKey, TValue>& m, uint32_t x)
 	{
-		if (x == m._sentinel)
-		{
+		if (x == NIL)
 			return x;
-		}
 
-		while (left(m, x) != m._sentinel)
-		{
+		while (left(m, x) != NIL)
 			x = left(m, x);
-		}
 
 		return x;
 	}
@@ -155,15 +152,11 @@ namespace map_internal
 	template <typename TKey, typename TValue>
 	inline uint32_t max(const Map<TKey, TValue>& m, uint32_t x)
 	{
-		if (x == m._sentinel)
-		{
+		if (x == NIL)
 			return x;
-		}
 
-		while (right(m, x) != m._sentinel)
-		{
+		while (right(m, x) != NIL)
 			x = right(m, x);
-		}
 
 		return x;
 	}
@@ -171,10 +164,8 @@ namespace map_internal
 	template <typename TKey, typename TValue>
 	inline uint32_t successor(const Map<TKey, TValue>& m, uint32_t x)
 	{
-		if (right(m, x) != m._sentinel)
-		{
+		if (right(m, x) != NIL)
 			return min(m, right(m, x));
-		}
 
 		uint32_t y = parent(m, x);
 
@@ -190,10 +181,8 @@ namespace map_internal
 	template <typename TKey, typename TValue>
 	inline uint32_t predecessor(const Map<TKey, TValue>& m, uint32_t x)
 	{
-		if (left(m, x) != m._sentinel)
-		{
+		if (left(m, x) != NIL)
 			return max(m, left(m, x));
-		}
 
 		uint32_t y = parent(m, x);
 
@@ -214,7 +203,7 @@ namespace map_internal
 		uint32_t y = right(m, x);
 		m._data[x].right = left(m, y);
 
-		if (left(m, y) != m._sentinel)
+		if (left(m, y) != NIL)
 		{
 			m._data[left(m, y)].parent = x;
 		}
@@ -249,7 +238,7 @@ namespace map_internal
 		uint32_t y = left(m, x);
 		m._data[x].left = right(m, y);
 
-		if (right(m, y) != m._sentinel)
+		if (right(m, y) != NIL)
 		{
 			m._data[right(m, y)].parent = x;
 		}
@@ -316,10 +305,9 @@ namespace map_internal
 			}
 		}
 
-		#ifdef RBTREE_VERIFY
-			dbg_verify(m, m._root);
-		#endif
-
+#ifdef RBTREE_VERIFY
+		dbg_verify(m, m._root);
+#endif
 		vector::pop_back(m._data);
 	}
 
@@ -395,30 +383,24 @@ namespace map_internal
 	{
 		uint32_t x = m._root;
 
-		while (x != m._sentinel)
+		while (x != NIL)
 		{
 			if (m._data[x].key < key)
 			{
-				if (right(m, x) == m._sentinel)
-				{
+				if (right(m, x) == NIL)
 					return x;
-				}
 
 				x = right(m, x);
 			}
 			else if (key < m._data[x].key)
 			{
-				if (left(m, x) == m._sentinel)
-				{
+				if (left(m, x) == NIL)
 					return x;
-				}
 
 				x = left(m, x);
 			}
 			else
-			{
 				break;
-			}
 		}
 
 		return x;
@@ -429,7 +411,7 @@ namespace map_internal
 	{
 		uint32_t p = inner_find(m, key);
 
-		if (p != m._sentinel && m._data[p].key == key)
+		if (p != NIL && m._data[p].key == key)
 			return p;
 
 		return NIL;
@@ -440,42 +422,34 @@ namespace map_internal
 	{
 		uint32_t p = inner_find(m, key);
 
-		if (p != m._sentinel && m._data[p].key == key)
-		{
+		if (p != NIL && m._data[p].key == key)
 			return p;
-		}
 
 		typename Map<TKey, TValue>::Node n;
 		n.key = key;
 		n.value = TValue();
 		n.color = RED;
-		n.left = m._sentinel;
-		n.right = m._sentinel;
+		n.left = NIL;
+		n.right = NIL;
 		n.parent = NIL;
 
-		if (p == m._sentinel)
-		{
+		if (p == NIL)
 			m._root = n;
-		}
 		else
 		{
 			if (key < m._data[p].key)
-			{
 				m._data[p].left = n;
-			}
 			else
-			{
 				m._data[p].right = n;
-			}
 
 			m._data[n].parent = p;
 		}
 
 		add_fixup(m, n);
 		m._data[m._root].color = BLACK;
-		#ifdef RBTREE_VERIFY
-			dbg_verify(m, m._root);
-		#endif
+#ifdef RBTREE_VERIFY
+		dbg_verify(m, m._root);
+#endif
 		return n;
 	}
 } // namespace map_internal
@@ -485,8 +459,7 @@ namespace map
 	template <typename TKey, typename TValue>
 	uint32_t size(const Map<TKey, TValue>& m)
 	{
-		CE_ASSERT(vector::size(m._data) > 0, "Bad Map"); // There should be at least sentinel
-		return vector::size(m._data) - 1;
+		return vector::size(m._data);
 	}
 
 	template <typename TKey, typename TValue>
@@ -500,10 +473,8 @@ namespace map
 	{
 		uint32_t p = map_internal::inner_find(m, key);
 
-		if (p != m._sentinel && m._data[p].key == key)
-		{
+		if (p != map_internal::NIL && m._data[p].key == key)
 			return m._data[p].value;
-		}
 
 		return deffault;
 	}
@@ -511,22 +482,24 @@ namespace map
 	template <typename TKey, typename TValue>
 	inline void set(Map<TKey, TValue>& m, const TKey& key, const TValue& value)
 	{
+		using namespace map_internal;
+
 		typename Map<TKey, TValue>::Node node;
 		node.key = key;
 		node.value = value;
-		node.color = map_internal::RED;
-		node.left = m._sentinel;
-		node.right = m._sentinel;
-		node.parent = map_internal::NIL;
+		node.color = RED;
+		node.left = NIL;
+		node.right = NIL;
+		node.parent = NIL;
 		uint32_t n = vector::push_back(m._data, node);
 		uint32_t x = m._root;
-		uint32_t y = map_internal::NIL;
+		uint32_t y = NIL;
 
-		if (x == m._sentinel)
+		if (x == NIL)
 			m._root = n;
 		else
 		{
-			while (x != m._sentinel)
+			while (x != NIL)
 			{
 				y = x;
 
@@ -544,11 +517,11 @@ namespace map
 			m._data[n].parent = y;
 		}
 
-		map_internal::insert_fixup(m, n);
-		m._data[m._root].color = map_internal::BLACK;
-		#ifdef RBTREE_VERIFY
-			map_internal::dbg_verify(m, m._root);
-		#endif
+		insert_fixup(m, n);
+		m._data[m._root].color = BLACK;
+#ifdef RBTREE_VERIFY
+		dbg_verify(m, m._root);
+#endif
 	}
 
 	template <typename TKey, typename TValue>
@@ -559,48 +532,32 @@ namespace map
 		uint32_t n = inner_find(m, key);
 
 		if (!(m._data[n].key == key))
-		{
 			return;
-		}
 
 		uint32_t x;
 		uint32_t y;
 
-		if (left(m, n) == m._sentinel || right(m, n) == m._sentinel)
-		{
+		if (left(m, n) == NIL || right(m, n) == NIL)
 			y = n;
-		}
 		else
-		{
 			y = successor(m, n);
-		}
 
-		if (left(m, y) != m._sentinel)
-		{
+		if (left(m, y) != NIL)
 			x = left(m, y);
-		}
 		else
-		{
 			x = right(m, y);
-		}
 
 		m._data[x].parent = parent(m, y);
 
-		if (parent(m, y) != map_internal::NIL)
+		if (parent(m, y) != NIL)
 		{
 			if (y == left(m, parent(m, y)))
-			{
 				m._data[parent(m, y)].left = x;
-			}
 			else
-			{
 				m._data[parent(m, y)].right = x;
-			}
 		}
 		else
-		{
 			m._root = x;
-		}
 
 		if (y != n)
 		{
@@ -609,42 +566,42 @@ namespace map
 		}
 
 		// Do the fixup
-		if (color(m, y) == map_internal::BLACK)
+		if (color(m, y) == BLACK)
 		{
 			uint32_t y;
 
-			while (x != m._root && color(m, x) == map_internal::BLACK)
+			while (x != m._root && color(m, x) == BLACK)
 			{
 				if (x == left(m, parent(m, x)))
 				{
 					y = right(m, parent(m, x));
 
-					if (color(m, y) == map_internal::RED)
+					if (color(m, y) == RED)
 					{
-						m._data[y].color = map_internal::BLACK;
-						m._data[parent(m, x)].color = map_internal::RED;
+						m._data[y].color = BLACK;
+						m._data[parent(m, x)].color = RED;
 						rotate_left(m, parent(m, x));
 						y = right(m, parent(m, x));
 					}
 
-					if (color(m, left(m, y)) == map_internal::BLACK && color(m, right(m, y)) == map_internal::BLACK)
+					if (color(m, left(m, y)) == BLACK && color(m, right(m, y)) == BLACK)
 					{
-						m._data[y].color = map_internal::RED;
+						m._data[y].color = RED;
 						x = parent(m, x);
 					}
 					else
 					{
-						if (color(m, right(m, y)) == map_internal::BLACK)
+						if (color(m, right(m, y)) == BLACK)
 						{
-							m._data[left(m, y)].color = map_internal::BLACK;
-							m._data[y].color = map_internal::RED;
+							m._data[left(m, y)].color = BLACK;
+							m._data[y].color = RED;
 							rotate_right(m, y);
 							y = right(m, parent(m, x));
 						}
 
 						m._data[y].color = color(m, parent(m, x));
-						m._data[parent(m, x)].color = map_internal::BLACK;
-						m._data[right(m, y)].color = map_internal::BLACK;
+						m._data[parent(m, x)].color = BLACK;
+						m._data[right(m, y)].color = BLACK;
 						rotate_left(m, parent(m, x));
 						x = m._root;
 					}
@@ -653,69 +610,58 @@ namespace map
 				{
 					y = left(m, parent(m, x));
 
-					if (color(m, y) == map_internal::RED)
+					if (color(m, y) == RED)
 					{
-						m._data[y].color = map_internal::BLACK;
-						m._data[parent(m, x)].color = map_internal::RED;
+						m._data[y].color = BLACK;
+						m._data[parent(m, x)].color = RED;
 						rotate_right(m, parent(m, x));
 						y = left(m, parent(m, x));
 					}
 
-					if (color(m, right(m, y)) == map_internal::BLACK && color(m, left(m, y)) == map_internal::BLACK)
+					if (color(m, right(m, y)) == BLACK && color(m, left(m, y)) == BLACK)
 					{
-						m._data[y].color = map_internal::RED;
+						m._data[y].color = RED;
 						x = parent(m, x);
 					}
 					else
 					{
-						if (color(m, left(m, y)) == map_internal::BLACK)
+						if (color(m, left(m, y)) == BLACK)
 						{
-							m._data[right(m, y)].color = map_internal::BLACK;
-							m._data[y].color = map_internal::RED;
+							m._data[right(m, y)].color = BLACK;
+							m._data[y].color = RED;
 							rotate_left(m, y);
 							y = left(m, parent(m, x));
 						}
 
 						m._data[y].color = color(m, parent(m, x));
-						m._data[parent(m, x)].color = map_internal::BLACK;
-						m._data[left(m, y)].color = map_internal::BLACK;
+						m._data[parent(m, x)].color = BLACK;
+						m._data[left(m, y)].color = BLACK;
 						rotate_right(m, parent(m, x));
 						x = m._root;
 					}
 				}
 			}
 
-			m._data[x].color = map_internal::BLACK;
+			m._data[x].color = BLACK;
 		}
 
 		destroy(m, y);
-	 	#ifdef RBTREE_VERIFY
-			map_internal::dbg_verify(m, m._root);
-	 	#endif
+#ifdef RBTREE_VERIFY
+		dbg_verify(m, m._root);
+#endif
 	}
 
 	template <typename TKey, typename TValue>
 	void clear(Map<TKey, TValue>& m)
 	{
 		vector::clear(m._data);
-
-		m._root = 0;
-		m._sentinel = 0;
-
-		typename Map<TKey, TValue>::Node r;
-		r.key = TKey();
-		r.value = TValue();
-		r.left = map_internal::NIL;
-		r.right = map_internal::NIL;
-		r.parent = map_internal::NIL;
-		r.color = map_internal::BLACK;
-		vector::push_back(m._data, r);
+		m._root = map_internal::NIL;
 	}
 
 	template <typename TKey, typename TValue>
 	const typename Map<TKey, TValue>::Node* begin(const Map<TKey, TValue>& m)
 	{
-		return vector::begin(m._data) + 1; // Skip sentinel at index 0
+		return vector::begin(m._data);
 	}
 
 	template <typename TKey, typename TValue>
@@ -727,9 +673,9 @@ namespace map
 
 template <typename TKey, typename TValue>
 inline Map<TKey, TValue>::Map(Allocator& a)
-	: _data(a)
+	: _root(map_internal::NIL)
+	, _data(a)
 {
-	map::clear(*this);
 }
 
 template <typename TKey, typename TValue>

+ 0 - 1
src/core/containers/sort_map.h

@@ -42,7 +42,6 @@ namespace sort_map
 	/// efficiently iterate over the elements.
 	template <typename TKey, typename TValue, typename Compare> const typename SortMap<TKey, TValue, Compare>::Entry* begin(const SortMap<TKey, TValue, Compare>& m);
 	template <typename TKey, typename TValue, typename Compare> const typename SortMap<TKey, TValue, Compare>::Entry* end(const SortMap<TKey, TValue, Compare>& m);
-
 } // namespace sort_map
 
 namespace sort_map_internal

+ 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);

+ 10 - 27
src/core/strings/dynamic_string.h

@@ -21,10 +21,8 @@ class DynamicString
 {
 public:
 
-	DynamicString(Allocator& allocator = default_allocator());
-	DynamicString(const char* s, Allocator& allocator = default_allocator());
-
-	~DynamicString();
+	DynamicString(Allocator& a = default_allocator());
+	DynamicString(const char* s, Allocator& a = default_allocator());
 
 	DynamicString& operator+=(const DynamicString& s);
 	DynamicString& operator+=(const char* s);
@@ -68,24 +66,16 @@ private:
 	Array<char> _data;
 };
 
-inline DynamicString::DynamicString(Allocator& allocator)
-	: _data(allocator)
+inline DynamicString::DynamicString(Allocator& a)
+	: _data(a)
 {
-	array::push_back(_data, '\0');
-}
-
-inline DynamicString::DynamicString(const char* s, Allocator& allocator)
-	: _data(allocator)
-{
-	if (s != NULL)
-	{
-		array::push(_data, s, strlen(s));
-	}
-	array::push_back(_data, '\0');
 }
 
-inline DynamicString::~DynamicString()
+inline DynamicString::DynamicString(const char* s, Allocator& a)
+	: _data(a)
 {
+	CE_ASSERT_NOT_NULL(s);
+	array::push(_data, s, strlen(s));
 }
 
 inline DynamicString& DynamicString::operator+=(const DynamicString& s)
@@ -96,17 +86,13 @@ inline DynamicString& DynamicString::operator+=(const DynamicString& s)
 inline DynamicString& DynamicString::operator+=(const char* s)
 {
 	CE_ASSERT_NOT_NULL(s);
-	array::pop_back(_data);
 	array::push(_data, s, strlen(s));
-	array::push_back(_data, '\0');
 	return *this;
 }
 
 inline DynamicString& DynamicString::operator+=(const char c)
 {
-	array::pop_back(_data);
 	array::push_back(_data, c);
-	array::push_back(_data, '\0');
 	return *this;
 }
 
@@ -121,7 +107,6 @@ inline DynamicString& DynamicString::operator=(const char* s)
 	CE_ASSERT_NOT_NULL(s);
 	array::clear(_data);
 	array::push(_data, s, strlen(s));
-	array::push_back(_data, '\0');
 	return *this;
 }
 
@@ -129,7 +114,6 @@ inline DynamicString& DynamicString::operator=(const char c)
 {
 	array::clear(_data);
 	array::push_back(_data, c);
-
 	return *this;
 }
 
@@ -146,7 +130,6 @@ inline bool DynamicString::operator==(const DynamicString& s) const
 inline bool DynamicString::operator==(const char* s) const
 {
 	CE_ASSERT_NOT_NULL(s);
-
 	return strcmp(c_str(), s) == 0;
 }
 
@@ -165,7 +148,6 @@ inline void DynamicString::strip_leading(const char* s)
 
 	memmove(array::begin(_data), array::begin(_data) + s_len, (my_len - s_len));
 	array::resize(_data, my_len - s_len);
-	array::push_back(_data, '\0');
 }
 
 inline void DynamicString::strip_trailing(const char* s)
@@ -176,7 +158,6 @@ inline void DynamicString::strip_trailing(const char* s)
 	const size_t my_len = strlen(c_str());
 	const size_t s_len = strlen(s);
 	array::resize(_data, my_len - s_len);
-	array::push_back(_data, '\0');
 }
 
 inline bool DynamicString::starts_with(const char* s) const
@@ -207,6 +188,8 @@ inline StringId32 DynamicString::to_string_id() const
 
 inline const char* DynamicString::c_str() const
 {
+	array::push_back(const_cast<Array<char>& >(_data), '\0');
+	array::pop_back(const_cast<Array<char>& >(_data));
 	return array::begin(_data);
 }
 

+ 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: