Skip to content

Commit d3c48de

Browse files
committed
update keybind docs
1 parent c9f0b18 commit d3c48de

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

mods/settings.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ Keybind settings allow the user to pick a key or combination of keys for a speci
367367
"multiple-keybind-example": {
368368
"type": "keybind",
369369
"name": "Groovy Action Keybinds",
370-
"default": ["G", "Ctrl+W"]
370+
"default": ["G", "Ctrl+W"],
371+
"category": "gameplay",
372+
"priority": 1,
373+
"migrate-from": "me.previous-groovy-mod/groovy-action"
371374
}
372375
```
373376

@@ -397,11 +400,14 @@ protected:
397400
if (!CCLayer::init())
398401
return false;
399402

400-
this->addEventListener(KeybindSettingPressedEventV3(Mod::get(), "keybind-example"), [this](Keybind const& keybind, bool down, bool repeat, double timestamp) {
401-
if (down && !repeat) {
402-
// do something
403+
this->addEventListener(
404+
KeybindSettingPressedEventV3(Mod::get(), "keybind-example"),
405+
[this](Keybind const& keybind, bool down, bool repeat, double timestamp) {
406+
if (down && !repeat) {
407+
// do something
408+
}
403409
}
404-
});
410+
);
405411

406412
return true;
407413
}
@@ -417,6 +423,41 @@ A list of keybind names can be found [in the Geode repository](https://github.co
417423

418424
Traditionally, due to conflicts with system keybinds, Geometry Dash on macOS assigns the same actions to Control and Command modifiers. This can be accomplished for any mod through per-platform default values.
419425

426+
Keybinds have three special keys: `priority`, `category`, and `migrate-from`.
427+
428+
`priority` is an integer that defines the priority of the keybind (whether it should execute before or after other keybinds); higher values mean higher priority, meaning that the keybind executes first. **You should not specify priority unless you have a good reason to.**
429+
430+
`category` is one of `editor` (keybinds that work in the level editor), `gameplay` (keybinds that works while playing levels), or `universal` (keybinds that work everywhere in the game). **Categories are not required**; they're intended for situations where your keybind clearly fits into one of the categories. If your keybind doesn't – for example, it's for a mod-specific layer – then just leave the category out.
431+
432+
`migrate-from` is the name of a keybind from the old Custom Keybinds mod. For example, in the code snippet below is an old definition from BetterEdit for a keybind with the ID `"rotate-45-ccw"_spr` (aka `hjfod.betteredit/rotate-45-ccw`).
433+
434+
```cpp
435+
BindManager::get()->registerBindable(BindableAction(
436+
"rotate-45-ccw"_spr,
437+
"Rotate 45 CCW",
438+
"Rotate the Selected Object(s) 45 Degrees Counter-Clockwise",
439+
{ Keybind::create(KEY_Q, Modifier::Shift) },
440+
Category::EDITOR_MODIFY
441+
));
442+
```
443+
444+
Migration means that the user's configuration for this keybind is automatically migrated over to the new system. For example, if an user had bound the `rotate-45-ccw` keybind to `Shift+U`, then the migration system would automatically move that over. In other words, **if your keybindings existed under the old system, you should always specify `migrate-from`**.
445+
446+
The key value needs to be the full key name, including mod ID. For example, to migrate the keybind above:
447+
448+
```json
449+
{
450+
"new-rotate-45-ccw": {
451+
"type": "keybind",
452+
"name": "Rotate 45 CCW",
453+
"description": "Rotate the Selected Object(s) 45 Degrees Counter-Clockwise",
454+
"default": ["Shift+Q"],
455+
"category": "editor",
456+
"migrate-from": "hjfod.betteredit/rotate-45-ccw"
457+
}
458+
}
459+
```
460+
420461
---
421462

422463
## Custom Settings

0 commit comments

Comments
 (0)