Skip to content

Commit 0809fa8

Browse files
committed
clean up optional api
1 parent f70ce1a commit 0809fa8

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ Adds support for customizing keybinds in the editor and while playing.
66

77
You can use Custom Keybinds as a dependency by declaring it in your `mod.json`:
88

9-
```json
9+
```jsonc
1010
{
11-
"dependencies": [
12-
{
11+
"dependencies": {
12+
"geode.custom-keybinds": {
1313
"id": "geode.custom-keybinds",
1414
"version": "v1.1.0",
1515
"importance": "required"
16-
}
16+
},
1717
// or the optional api version
18-
{
19-
"id": "geode.custom-keybinds",
18+
"geode.custom-keybinds": {
2019
"version": "v1.1.0",
2120
"importance": "recommended"
2221
}
23-
]
22+
}
2423
}
2524
```
2625

@@ -30,6 +29,8 @@ Registering can be done easily using `$execute`:
3029

3130
```cpp
3231
#include <geode.custom-keybinds/include/Keybinds.hpp>
32+
// optional api version
33+
#include <geode.custom-keybinds/include/OptionalAPI.hpp>
3334

3435
using namespace keybinds;
3536

@@ -72,13 +73,15 @@ Now your bind shows up in the UI, and the user can assign their own binds to it.
7273

7374
```cpp
7475
#include <geode.custom-keybinds/include/Keybinds.hpp>
76+
// optional api version
77+
#include <geode.custom-keybinds/include/OptionalAPI.hpp>
7578

7679
using namespace keybinds;
7780

7881
bool MyLayer::init() {
7982
...
8083

81-
this->template addEventListener<InvokeBindFilter>([=](InvokeBindEvent* event) {
84+
this->addEventListener<InvokeBindFilter>([=](InvokeBindEvent* event) {
8285
if (event->isDown()) {
8386
// do a backflip!
8487
}
@@ -88,7 +91,7 @@ bool MyLayer::init() {
8891
}, "backflip"_spr);
8992

9093
// optional api version
91-
this->template addEventListener<InvokeBindFilterV2>([=](InvokeBindEventV2* event) {
94+
this->addEventListener<InvokeBindFilterV2>([=](InvokeBindEventV2* event) {
9295
if (event->isDown()) {
9396
// do a backflip!
9497
}
@@ -109,6 +112,8 @@ You can listen for global keybinds via an `$execute` block:
109112

110113
```cpp
111114
#include <geode.custom-keybinds/include/Keybinds.hpp>
115+
// optional api version
116+
#include <geode.custom-keybinds/include/OptionalAPI.hpp>
112117

113118
using namespace keybinds;
114119

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Changelog
1+
## v1.11.0
2+
- Add optional API for developers!
23

34
## v1.10.4
45
- Fix the keybind search box being offset by half its width

include/OptionalAPI.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ namespace keybinds {
4646
class Impl;
4747
std::unique_ptr<Impl> m_impl;
4848
public:
49-
static geode::Result<Keybind*> create(cocos2d::enumKeyCodes key, Modifier modifiers = Modifier::None) GEODE_EVENT_EXPORT(&KeybindV2::create, (key, modifiers));
49+
static geode::Result<Keybind*> create(cocos2d::enumKeyCodes key, ModifierV2 modifiers = ModifierV2::None) GEODE_EVENT_EXPORT(&KeybindV2::create, (key, modifiers));
5050
};
5151

5252
class MouseBindV2 final {
5353
class Impl;
5454
std::unique_ptr<Impl> m_impl;
5555
public:
56-
static geode::Result<MouseBind*> create(MouseButton button, Modifier modifiers = Modifier::None) GEODE_EVENT_EXPORT(&MouseBindV2::create, (button, modifiers));
56+
static geode::Result<MouseBind*> create(MouseButton button, ModifierV2 modifiers = ModifierV2::None) GEODE_EVENT_EXPORT(&MouseBindV2::create, (button, modifiers));
5757
};
5858

5959
class ControllerBindV2 final {

mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"geode": "4.6.1",
2+
"geode": "4.8.0",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",
66
"mac": "2.2074"
77
},
8-
"version": "v1.10.4",
8+
"version": "v1.11.0",
99
"id": "geode.custom-keybinds",
1010
"name": "Custom Keybinds",
1111
"developer": "Geode Team",
@@ -33,4 +33,4 @@
3333
"type": "custom:open-menu"
3434
}
3535
}
36-
}
36+
}

src/Keybinds.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,11 @@ void BindManager::save() {
763763
BindManager::get()->save();
764764
}
765765

766-
Result<Keybind*> KeybindV2::create(cocos2d::enumKeyCodes key, Modifier modifiers) {
766+
Result<Keybind*> KeybindV2::create(cocos2d::enumKeyCodes key, ModifierV2 modifiers) {
767767
return Ok(Keybind::create(key, modifiers));
768768
}
769769

770-
Result<MouseBind*> MouseBindV2::create(MouseButton button, Modifier modifiers) {
770+
Result<MouseBind*> MouseBindV2::create(MouseButton button, ModifierV2 modifiers) {
771771
return Ok(MouseBind::create(button, modifiers));
772772
}
773773

0 commit comments

Comments
 (0)