Skip to content

Commit 6ddd1eb

Browse files
committed
initial keybinds
1 parent ff95939 commit 6ddd1eb

File tree

3 files changed

+424
-0
lines changed

3 files changed

+424
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#ifndef guard_keybinds_h_df5h456sdcvr5u8io
2+
#define guard_keybinds_h_df5h456sdcvr5u8io
3+
4+
#include <cage-engine/inputs.h>
5+
6+
namespace cage
7+
{
8+
class Ini;
9+
10+
class CAGE_ENGINE_API Keybind : private Immovable
11+
{
12+
public:
13+
String name() const;
14+
String value(uint32 index = 0) const;
15+
bool process(const GenericInput &input) const;
16+
17+
uint32 count() const;
18+
void override(uint32 index, const GenericInput &input);
19+
void add(const GenericInput &input = {});
20+
void remove(uint32 index);
21+
void clear();
22+
void reset(); // uses defaults
23+
24+
Delegate<bool(const GenericInput &)> event;
25+
};
26+
27+
enum class KeybindDevicesFlags : uint32
28+
{
29+
None = 0,
30+
Keyboard = 1 << 0,
31+
Mouse = 1 << 1,
32+
Wheel = 1 << 2,
33+
// todo controller
34+
};
35+
GCHL_ENUM_BITS(KeybindDevicesFlags);
36+
37+
struct CAGE_ENGINE_API KeybindCreateConfig
38+
{
39+
String id;
40+
sint32 eventOrder = 0;
41+
ModifiersFlags requiredFlags = ModifiersFlags::None;
42+
ModifiersFlags forbiddenFlags = ModifiersFlags::Super;
43+
KeybindDevicesFlags devices = KeybindDevicesFlags::Keyboard;
44+
};
45+
46+
CAGE_ENGINE_API Holder<Keybind> newKeybind(const KeybindCreateConfig &config, const GenericInput &defaults = {}, Delegate<bool(const GenericInput &)> event = {});
47+
CAGE_ENGINE_API Holder<Keybind> newKeybind(const KeybindCreateConfig &config, PointerRange<const GenericInput> defaults, Delegate<bool(const GenericInput &)> event = {});
48+
CAGE_ENGINE_API Keybind *findKeybind(const String &id);
49+
50+
CAGE_ENGINE_API void keybindsRegisterListeners(EventDispatcher<bool(const GenericInput &)> &dispatcher);
51+
52+
namespace input
53+
{
54+
struct CAGE_ENGINE_API Tick
55+
{};
56+
}
57+
CAGE_ENGINE_API void keybindsDispatchTick();
58+
59+
CAGE_ENGINE_API Holder<Ini> keybindsExport();
60+
CAGE_ENGINE_API void keybindsImport(const Ini *ini);
61+
}
62+
63+
#endif

0 commit comments

Comments
 (0)