Skip to content

Commit f70ce1a

Browse files
committed
modifierv2
1 parent 0d9de78 commit f70ce1a

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $execute {
5858
// Description, leave empty for none
5959
"Throw a backflip",
6060
// Default binds
61-
{ GEODE_UNWRAP(KeybindV2::create(KEY_Q, Modifier::None)) },
61+
{ GEODE_UNWRAP(KeybindV2::create(KEY_Q, ModifierV2::None)) },
6262
// Category; use slashes for specifying subcategories. See the
6363
// Category class for default categories
6464
GEODE_UNWRAP(CategoryV2::create("My Mod/Awesome Tricks"))

include/OptionalAPI.hpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,35 @@
99
#define MY_MOD_ID "geode.custom-keybinds"
1010

1111
namespace keybinds {
12-
enum class Modifier2 : unsigned int {
13-
None = 0b0000,
14-
Control = 0b0001,
15-
Shift = 0b0010,
16-
Alt = 0b0100,
17-
Command = 0b1000,
12+
struct ModifierV2 {
13+
enum {
14+
None = 0b0000,
15+
Control = 0b0001,
16+
Shift = 0b0010,
17+
Alt = 0b0100,
18+
Command = 0b1000,
19+
} m_value;
20+
ModifierV2() = default;
21+
ModifierV2(uint32_t value) : m_value(static_cast<decltype(m_value)>(value)) {}
22+
23+
operator Modifier() const {
24+
return static_cast<Modifier>(m_value);
25+
}
26+
operator uint32_t() const {
27+
return static_cast<uint32_t>(m_value);
28+
}
1829
};
1930

20-
inline Modifier2 operator|(Modifier2 const& a, Modifier2 const& b) {
21-
return static_cast<Modifier2>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
31+
inline ModifierV2 operator|(ModifierV2 const& a, ModifierV2 const& b) {
32+
return ModifierV2(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
2233
}
2334

24-
inline Modifier2& operator|=(Modifier2& a, Modifier2 const& b) {
35+
inline ModifierV2& operator|=(ModifierV2& a, ModifierV2 const& b) {
2536
a = a | b;
2637
return a;
2738
}
2839

29-
inline bool operator&(Modifier2 const& a, Modifier2 const& b) {
40+
inline bool operator&(ModifierV2 const& a, ModifierV2 const& b) {
3041
return (static_cast<unsigned int>(a) & static_cast<unsigned int>(b)) != 0;
3142
}
3243

0 commit comments

Comments
 (0)