blob: 27fca07d2bbb8c5a3f7eecf3231ff44fcdfb4d75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#pragma once
#include <stdint.h>
#include <functional>
#include <string>
namespace mgl {
class Event;
}
namespace gsr {
struct Hotkey {
uint64_t key = 0;
uint32_t modifiers = 0;
};
using GlobalHotkeyCallback = std::function<void(const std::string &id)>;
class GlobalHotkeys {
public:
GlobalHotkeys() = default;
GlobalHotkeys(const GlobalHotkeys&) = delete;
GlobalHotkeys& operator=(const GlobalHotkeys&) = delete;
virtual ~GlobalHotkeys() = default;
virtual bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) { (void)hotkey; (void)id; (void)callback; return false; }
virtual void unbind_key_press(const std::string &id) { (void)id; }
virtual void unbind_all_keys() {}
virtual bool bind_action(const std::string &id, GlobalHotkeyCallback callback) { (void)id; (void)callback; return false; };
virtual void poll_events() = 0;
// Returns true if the event wasn't consumed (if the event didn't match a key that has been bound)
virtual bool on_event(mgl::Event &event) { (void)event; return true; }
};
}
|