aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------depends/mgl0
-rw-r--r--include/mglpp/window/Event.hpp12
-rw-r--r--include/mglpp/window/Keyboard.hpp7
-rw-r--r--meson.build1
-rw-r--r--src/window/Keyboard.cpp22
5 files changed, 42 insertions, 0 deletions
diff --git a/depends/mgl b/depends/mgl
-Subproject 97d24e6a1b1fe8d2a4e217f9ee3f82a1accf468
+Subproject 227b96247baeec7a3f44cf82c4560f2aca282c1
diff --git a/include/mglpp/window/Event.hpp b/include/mglpp/window/Event.hpp
index bcd1e91..35b83a4 100644
--- a/include/mglpp/window/Event.hpp
+++ b/include/mglpp/window/Event.hpp
@@ -63,6 +63,16 @@ namespace mgl {
int id;
};
+ enum class MappingChangedType : int {
+ MODIFIER,
+ KEYBOARD,
+ POINTER
+ };
+
+ struct MappingChangedEvent {
+ MappingChangedType type;
+ };
+
enum Type : int {
Unknown,
Closed, /* Window closed */
@@ -79,6 +89,7 @@ namespace mgl {
MonitorConnected,
MonitorDisconnected,
MonitorPropertyChanged,
+ MappingChanged
};
Type type;
@@ -93,6 +104,7 @@ namespace mgl {
MonitorConnectedEvent monitor_connected;
MonitorDisconnectedEvent monitor_disconnected;
MonitorPropertyChangedEvent monitor_property_changed;
+ MappingChangedEvent mapping_changed;
};
};
}
diff --git a/include/mglpp/window/Keyboard.hpp b/include/mglpp/window/Keyboard.hpp
index 17c4d7c..7200f5f 100644
--- a/include/mglpp/window/Keyboard.hpp
+++ b/include/mglpp/window/Keyboard.hpp
@@ -1,6 +1,8 @@
#ifndef MGLPP_KEYBOARD_HPP
#define MGLPP_KEYBOARD_HPP
+#include <stdint.h>
+
namespace mgl {
class Keyboard {
public:
@@ -112,6 +114,11 @@ namespace mgl {
/* This should always be the last key */
__NumKeys__
};
+
+ /* Returns nullptr if unknown key */
+ static const char* key_to_string(Key key);
+ static bool key_is_modifier(Key key);
+ static uint64_t key_to_x11_keysym(Key key);
};
}
diff --git a/meson.build b/meson.build
index 214ef63..258fae0 100644
--- a/meson.build
+++ b/meson.build
@@ -19,6 +19,7 @@ src = [
'src/system/Clock.cpp',
'src/system/Utf8.cpp',
'src/window/Window.cpp',
+ 'src/window/Keyboard.cpp',
'src/mglpp.cpp',
]
diff --git a/src/window/Keyboard.cpp b/src/window/Keyboard.cpp
new file mode 100644
index 0000000..34d28be
--- /dev/null
+++ b/src/window/Keyboard.cpp
@@ -0,0 +1,22 @@
+#include "../../include/mglpp/window/Keyboard.hpp"
+
+extern "C" {
+#include <mgl/window/key.h>
+}
+
+namespace mgl {
+ // static
+ const char* Keyboard::key_to_string(Key key) {
+ return mgl_key_to_string((mgl_key)key);
+ }
+
+ // static
+ bool Keyboard::key_is_modifier(Key key) {
+ return mgl_key_is_modifier((mgl_key)key);
+ }
+
+ // static
+ uint64_t Keyboard::key_to_x11_keysym(Key key) {
+ return mgl_key_to_x11_keysym((mgl_key)key);
+ }
+} \ No newline at end of file