-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(keybindings): ports Nebula's KBs
- Loading branch information
1 parent
a3f1a4c
commit 932c0bb
Showing
35 changed files
with
1,293 additions
and
1,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// /Max length of a keypress command before it's considered to be a forged packet/bogus command | ||
#define MAX_KEYPRESS_COMMANDLENGTH 16 | ||
/// Maximum keys that can be bound to one button | ||
#define MAX_COMMANDS_PER_KEY 5 | ||
/// Maximum keys per keybind | ||
#define MAX_KEYS_PER_KEYBIND 3 | ||
/// Length of held key buffer | ||
#define HELD_KEY_BUFFER_LENGTH 15 | ||
|
||
//NOTE: INTENT_HOTKEY_* defines are not actual intents! | ||
//they are here to support hotkeys | ||
#define INTENT_HOTKEY_LEFT "left" | ||
#define INTENT_HOTKEY_RIGHT "right" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
GLOBAL_LIST_EMPTY(hotkey_keybinding_list_by_key) | ||
GLOBAL_LIST_INIT(keybindings_by_name, init_kb_by_name()) | ||
|
||
/proc/init_kb_by_name() | ||
var/list/keybindings = list() | ||
for(var/path in subtypesof(/datum/keybinding)) | ||
var/datum/keybinding/keybinding = path | ||
if(!keybinding::name) | ||
continue | ||
|
||
var/datum/keybinding/instance = new keybinding() | ||
keybindings[instance.name] = instance | ||
if(length(instance.hotkey_keys)) | ||
for(var/bound_key in instance.hotkey_keys) | ||
GLOB.hotkey_keybinding_list_by_key[bound_key] += list(instance.name) | ||
|
||
return keybindings | ||
|
||
// This is a mapping from JS keys to Byond - ref: https://keycode.info/ | ||
GLOBAL_LIST_INIT(_kbMap, list( | ||
"UP" = "North", | ||
"RIGHT" = "East", | ||
"DOWN" = "South", | ||
"LEFT" = "West", | ||
"INSERT" = "Insert", | ||
"HOME" = "Northwest", | ||
"PAGEUP" = "Northeast", | ||
"DEL" = "Delete", | ||
"END" = "Southwest", | ||
"PAGEDOWN" = "Southeast", | ||
"SPACEBAR" = "Space", | ||
"ALT" = "Alt", | ||
"SHIFT" = "Shift", | ||
"CONTROL" = "Ctrl" | ||
)) | ||
|
||
// Without alt, shift, ctrl and etc because its not necessary | ||
GLOBAL_LIST_INIT(_kbMap_reverse, list( | ||
"North" = "Up", | ||
"East" = "Right", | ||
"South" = "Down", | ||
"West" = "Left", | ||
"Northwest" = "Home", | ||
"Northeast" = "PageUp", | ||
"Southwest" = "End", | ||
"Southeast" = "PageDown", | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
SUBSYSTEM_DEF(input) | ||
name = "Input" | ||
wait = 1 | ||
init_order = SS_INIT_INPUT | ||
flags = SS_TICKER | ||
priority = SS_PRIORITY_INPUT | ||
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY | ||
|
||
var/list/macro_set | ||
|
||
/datum/controller/subsystem/input/Initialize() | ||
. = ..() | ||
setup_default_macro_sets() | ||
refresh_client_macro_sets() | ||
|
||
/// This is for when macro sets are eventualy datumized | ||
/datum/controller/subsystem/input/proc/setup_default_macro_sets() | ||
macro_set = list( | ||
"Any" = "\"KeyDown \[\[*\]\]\"", | ||
"Any+UP" = "\"KeyUp \[\[*\]\]\"", | ||
"Back" = "\".winset \\\"outputwindow.input.text=\\\"\\\"\\\"\"", | ||
"Tab" = "\".winset \\\"outputwindow.input.focus=true?mapwindow.map.focus=true outputwindow.input.background-color=[COLOR_INPUT_DISABLED]:outputwindow.input.focus=true outputwindow.input.background-color=[COLOR_INPUT_ENABLED]\\\"\"", | ||
"Escape" = "Reset-Held-Keys", | ||
) | ||
|
||
/// Badmins just wanna have fun | ||
/datum/controller/subsystem/input/proc/refresh_client_macro_sets() | ||
for(var/client/C in GLOB.clients) | ||
C.set_macros() | ||
|
||
/** | ||
* It feels input's fire should have CHECK_TICK | ||
* However, stoplag() will probably fuck up all clients' input. | ||
*/ | ||
|
||
/datum/controller/subsystem/input/fire() | ||
for(var/client/C in GLOB.clients) | ||
C.keyLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.