-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathsetup.dm
69 lines (56 loc) · 2.14 KB
/
setup.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Set a client's focus to an object and override these procs on that object to let it handle keypresses
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially
return
/datum/proc/key_up(key, client/user) // Called when a key is released
return
/datum/proc/keyLoop(client/user) // Called once every frame
set waitfor = FALSE
return
// removes all the existing macros
/client/proc/erase_all_macros()
var/erase_output = ""
var/list/macro_set = params2list(winget(src, "default.*", "command")) // The third arg doesnt matter here as we're just removing them all
for(var/k in 1 to length(macro_set))
var/list/split_name = splittext(macro_set[k], ".")
var/macro_name = "[split_name[1]].[split_name[2]]" // [3] is "command"
erase_output = "[erase_output];[macro_name].parent=null"
winset(src, null, erase_output)
/client/proc/set_macros()
set waitfor = FALSE
//Reset the buffer
reset_held_keys()
erase_all_macros()
var/list/macro_set = SSinput.macro_set
for(var/k in 1 to length(macro_set))
var/key = macro_set[k]
var/command = macro_set[key]
winset(src, "default-\ref[key]", "parent=default;name=[key];command=[command]")
if(prefs?.hotkeys)
winset(src, null, "outputwindow.input.focus=true input.background-color=[COLOR_INPUT_ENABLED]")
else
winset(src, null, "outputwindow.input.focus=true input.background-color=[COLOR_INPUT_DISABLED]")
update_special_keybinds()
// byond bug ID:2694120
/client/verb/reset_macros_wrapper()
set name = "Fix Keybindings"
set category = "OOC"
reset_macros()
/client/proc/reset_macros(skip = FALSE)
if(!skip)
if(alert(src, "Change your keyboard language to ENG and press Ok", "Reset macros") != "Ok")
return
to_chat(src, SPAN_NOTICE("Keybindings should be fixed now."))
set_macros()
/**
* Manually clears any held keys, in case due to lag or other undefined behavior a key gets stuck.
*
* Hardcoded to the ESC key.
*/
/client/verb/reset_held_keys()
set name = "Reset Held Keys"
set hidden = TRUE
for(var/key in keys_held)
keyUp(key)
//In case one got stuck and the previous loop didn't clean it, somehow.
for(var/key in key_combos_held)
keyUp(key_combos_held[key])