@@ -11,7 +11,14 @@ You can use Custom Keybinds as a dependency by declaring it in your `mod.json`:
1111 "dependencies" : [
1212 {
1313 "id" : " geode.custom-keybinds" ,
14- "version" : " v1.1.0"
14+ "version" : " v1.1.0" ,
15+ "importance" : " required"
16+ }
17+ // or the optional api version
18+ {
19+ "id" : " geode.custom-keybinds" ,
20+ "version" : " v1.1.0" ,
21+ "importance" : " recommended"
1522 }
1623 ]
1724}
@@ -40,6 +47,24 @@ $execute {
4047 // Category class for default categories
4148 "My Mod/Awesome Tricks"
4249 });
50+
51+ // optional api version
52+ (void)[&]() -> Result<> {
53+ GEODE_UNWRAP (BindManagerV2::registerBindable (GEODE_UNWRAP (BindableActionV2::create (
54+ // ID, should be prefixed with mod ID
55+ "backflip"_spr,
56+ // Name
57+ "Do a Backflip!",
58+ // Description, leave empty for none
59+ "Throw a backflip",
60+ // Default binds
61+ { GEODE_UNWRAP(KeybindV2::create(KEY_Q, Modifier::None)) },
62+ // Category; use slashes for specifying subcategories. See the
63+ // Category class for default categories
64+ GEODE_UNWRAP (CategoryV2::create ("My Mod/Awesome Tricks"))
65+ ))));
66+ return Ok();
67+ }();
4368}
4469```
4570
@@ -62,6 +87,16 @@ bool MyLayer::init() {
6287 return ListenerResult::Propagate;
6388 }, "backflip"_spr);
6489
90+ // optional api version
91+ this->template addEventListener<InvokeBindFilterV2>([=](InvokeBindEventV2* event) {
92+ if (event->isDown()) {
93+ // do a backflip!
94+ }
95+ // Return Propagate if you want other actions with the same bind to
96+ // also be fired, or Stop if you want to halt propagation
97+ return ListenerResult::Propagate;
98+ }, "backflip"_spr);
99+
65100 ...
66101}
67102```
@@ -82,6 +117,12 @@ $execute {
82117 // do stuff
83118 return ListenerResult::Propagate;
84119 }, InvokeBindFilter(nullptr, "event-id"));
120+
121+ // optional api version
122+ new EventListener([=](InvokeBindEventV2* event) {
123+ // do stuff
124+ return ListenerResult::Propagate;
125+ }, InvokeBindFilterV2(nullptr, "event-id"));
85126}
86127```
87128
0 commit comments