1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#include "binds.h"
4
5#include <base/dbg.h>
6#include <base/log.h>
7#include <base/mem.h>
8#include <base/str.h>
9
10#include <engine/client/keyboard.h>
11#include <engine/config.h>
12#include <engine/console.h>
13#include <engine/shared/config.h>
14
15#include <game/client/components/chat.h>
16#include <game/client/components/console.h>
17#include <game/client/gameclient.h>
18
19static constexpr LOG_COLOR BIND_PRINT_COLOR{.r: 255, .g: 255, .b: 204};
20
21bool CBinds::CBindsSpecial::OnInput(const IInput::CEvent &Event)
22{
23 if((Event.m_Flags & (IInput::FLAG_PRESS | IInput::FLAG_RELEASE)) == 0)
24 return false;
25
26 // only handle F and composed F binds
27 // do not handle F5 bind while menu is active
28 if(((Event.m_Key >= KEY_F1 && Event.m_Key <= KEY_F12) || (Event.m_Key >= KEY_F13 && Event.m_Key <= KEY_F24)) &&
29 (Event.m_Key != KEY_F5 || !GameClient()->m_Menus.IsActive()))
30 {
31 return m_pBinds->OnInput(Event);
32 }
33
34 return false;
35}
36
37CBinds::CBinds()
38{
39 mem_zero(block: m_aapKeyBindings, size: sizeof(m_aapKeyBindings));
40 m_SpecialBinds.m_pBinds = this;
41 m_HandlingNewBind = false;
42}
43
44CBinds::~CBinds()
45{
46 UnbindAll();
47}
48
49void CBinds::Bind(int KeyId, const char *pStr, bool FreeOnly, int ModifierCombination)
50{
51 dbg_assert(KeyId >= KEY_FIRST && KeyId < KEY_LAST, "KeyId invalid");
52 dbg_assert(ModifierCombination >= KeyModifier::NONE && ModifierCombination < KeyModifier::COMBINATION_COUNT, "ModifierCombination invalid");
53
54 if(FreeOnly && Get(KeyId, ModifierCombination)[0])
55 return;
56
57 free(ptr: m_aapKeyBindings[ModifierCombination][KeyId]);
58 m_aapKeyBindings[ModifierCombination][KeyId] = nullptr;
59
60 char aBindName[128];
61 GetKeyBindName(Key: KeyId, ModifierMask: ModifierCombination, pBuf: aBindName, BufSize: sizeof(aBindName));
62 if(!pStr[0])
63 {
64 log_info_color(BIND_PRINT_COLOR, "binds", "unbound %s", aBindName);
65 }
66 else
67 {
68 int Size = str_length(str: pStr) + 1;
69 m_aapKeyBindings[ModifierCombination][KeyId] = (char *)malloc(size: Size);
70 str_copy(dst: m_aapKeyBindings[ModifierCombination][KeyId], src: pStr, dst_size: Size);
71 log_info_color(BIND_PRINT_COLOR, "binds", "bound %s = %s", aBindName, m_aapKeyBindings[ModifierCombination][KeyId]);
72 }
73}
74
75int CBinds::GetModifierMask(IInput *pInput)
76{
77 int Mask = 0;
78 static const auto s_aModifierKeys = {
79 KEY_LSHIFT,
80 KEY_RSHIFT,
81 KEY_LCTRL,
82 KEY_RCTRL,
83 KEY_LALT,
84 KEY_RALT,
85 KEY_LGUI,
86 KEY_RGUI,
87 };
88 for(const auto Key : s_aModifierKeys)
89 {
90 if(pInput->KeyIsPressed(Key))
91 {
92 Mask |= GetModifierMaskOfKey(Key);
93 }
94 }
95
96 return Mask;
97}
98
99int CBinds::GetModifierMaskOfKey(int Key)
100{
101 switch(Key)
102 {
103 case KEY_LSHIFT:
104 case KEY_RSHIFT:
105 return 1 << KeyModifier::SHIFT;
106 case KEY_LCTRL:
107 case KEY_RCTRL:
108 return 1 << KeyModifier::CTRL;
109 case KEY_LALT:
110 case KEY_RALT:
111 return 1 << KeyModifier::ALT;
112 case KEY_LGUI:
113 case KEY_RGUI:
114 return 1 << KeyModifier::GUI;
115 default:
116 return KeyModifier::NONE;
117 }
118}
119
120bool CBinds::OnInput(const IInput::CEvent &Event)
121{
122 if((Event.m_Flags & (IInput::FLAG_PRESS | IInput::FLAG_RELEASE)) == 0)
123 return false;
124
125 const int KeyModifierMask = GetModifierMaskOfKey(Key: Event.m_Key);
126 const int ModifierMask = GetModifierMask(pInput: Input()) & ~KeyModifierMask;
127
128 bool Handled = false;
129
130 if(Event.m_Flags & IInput::FLAG_PRESS)
131 {
132 auto ActiveBind = std::find_if(first: m_vActiveBinds.begin(), last: m_vActiveBinds.end(), pred: [&](const CBindSlot &Bind) {
133 return Event.m_Key == Bind.m_Key;
134 });
135 if(ActiveBind == m_vActiveBinds.end())
136 {
137 m_HandlingNewBind = true;
138 const auto &&OnKeyPress = [&](int Mask) {
139 // Have to copy bind because it can unbind itself during ExecuteLineStroked
140 const std::string BindCopy = m_aapKeyBindings[Mask][Event.m_Key];
141 Console()->ExecuteLineStroked(Stroke: 1, pStr: BindCopy.c_str(), ClientId: IConsole::CLIENT_ID_UNSPECIFIED);
142 m_vActiveBinds.emplace_back(args: Event.m_Key, args&: Mask);
143 };
144
145 if(m_aapKeyBindings[ModifierMask][Event.m_Key])
146 {
147 OnKeyPress(ModifierMask);
148 Handled = true;
149 }
150 else if(m_aapKeyBindings[KeyModifier::NONE][Event.m_Key] &&
151 ModifierMask != ((1 << KeyModifier::CTRL) | (1 << KeyModifier::SHIFT)) &&
152 ModifierMask != ((1 << KeyModifier::GUI) | (1 << KeyModifier::SHIFT)))
153 {
154 OnKeyPress(KeyModifier::NONE);
155 Handled = true;
156 }
157 m_HandlingNewBind = false;
158 }
159 else
160 {
161 // Repeat active bind while key is held down
162 // Have to check for nullptr again because the previous execute can unbind itself
163 if(m_aapKeyBindings[ActiveBind->m_ModifierMask][ActiveBind->m_Key])
164 {
165 // Have to copy bind because it can unbind itself during ExecuteLineStroked
166 const std::string BindCopy = m_aapKeyBindings[ActiveBind->m_ModifierMask][ActiveBind->m_Key];
167 Console()->ExecuteLineStroked(Stroke: 1, pStr: BindCopy.c_str(), ClientId: IConsole::CLIENT_ID_UNSPECIFIED);
168 }
169 Handled = true;
170 }
171 }
172
173 if(Event.m_Flags & IInput::FLAG_RELEASE)
174 {
175 const auto &&OnKeyRelease = [&](const CBindSlot &Bind) {
176 // Prevent binds from being deactivated while chat, console and menus are open, as these components will
177 // still allow key release events to be forwarded to this component, so the active binds can be cleared.
178 if(GameClient()->m_Chat.IsActive() ||
179 GameClient()->m_GameConsole.IsActive() ||
180 GameClient()->m_Menus.IsActive())
181 {
182 return;
183 }
184 // Have to check for nullptr again because the previous execute can unbind itself
185 if(!m_aapKeyBindings[Bind.m_ModifierMask][Bind.m_Key])
186 {
187 return;
188 }
189 // Have to copy bind because it can unbind itself during ExecuteLineStroked
190 const std::string BindCopy = m_aapKeyBindings[Bind.m_ModifierMask][Bind.m_Key];
191 Console()->ExecuteLineStroked(Stroke: 0, pStr: BindCopy.c_str(), ClientId: IConsole::CLIENT_ID_UNSPECIFIED);
192 };
193
194 // Release active bind that uses this primary key
195 auto ActiveBind = std::find_if(first: m_vActiveBinds.begin(), last: m_vActiveBinds.end(), pred: [&](const CBindSlot &Bind) {
196 return Event.m_Key == Bind.m_Key;
197 });
198 if(ActiveBind != m_vActiveBinds.end())
199 {
200 OnKeyRelease(*ActiveBind);
201 m_vActiveBinds.erase(position: ActiveBind);
202 Handled = true;
203 }
204
205 // Release all active binds that use this modifier key
206 if(KeyModifierMask != KeyModifier::NONE)
207 {
208 while(true)
209 {
210 auto ActiveModifierBind = std::find_if(first: m_vActiveBinds.begin(), last: m_vActiveBinds.end(), pred: [&](const CBindSlot &Bind) {
211 return (Bind.m_ModifierMask & KeyModifierMask) != 0;
212 });
213 if(ActiveModifierBind == m_vActiveBinds.end())
214 break;
215 OnKeyRelease(*ActiveModifierBind);
216 m_vActiveBinds.erase(position: ActiveModifierBind);
217 Handled = true;
218 }
219 }
220 }
221
222 return Handled;
223}
224
225void CBinds::UnbindAll()
226{
227 for(auto &apKeyBinding : m_aapKeyBindings)
228 {
229 for(auto &pKeyBinding : apKeyBinding)
230 {
231 free(ptr: pKeyBinding);
232 pKeyBinding = nullptr;
233 }
234 }
235}
236
237const char *CBinds::Get(int KeyId, int ModifierCombination) const
238{
239 dbg_assert(KeyId >= KEY_FIRST && KeyId < KEY_LAST, "KeyId invalid");
240 dbg_assert(ModifierCombination >= KeyModifier::NONE && ModifierCombination < KeyModifier::COMBINATION_COUNT, "ModifierCombination invalid");
241 return m_aapKeyBindings[ModifierCombination][KeyId] ? m_aapKeyBindings[ModifierCombination][KeyId] : "";
242}
243
244const char *CBinds::Get(const CBindSlot &BindSlot) const
245{
246 return Get(KeyId: BindSlot.m_Key, ModifierCombination: BindSlot.m_ModifierMask);
247}
248
249void CBinds::GetKey(const char *pBindStr, char *pBuf, size_t BufSize) const
250{
251 pBuf[0] = '\0';
252 for(int Modifier = KeyModifier::NONE; Modifier < KeyModifier::COMBINATION_COUNT; Modifier++)
253 {
254 for(int KeyId = KEY_FIRST; KeyId < KEY_LAST; KeyId++)
255 {
256 const char *pBind = Get(KeyId, ModifierCombination: Modifier);
257 if(!pBind[0])
258 continue;
259
260 if(str_comp(a: pBind, b: pBindStr) == 0)
261 {
262 GetKeyBindName(Key: KeyId, ModifierMask: Modifier, pBuf, BufSize);
263 return;
264 }
265 }
266 }
267}
268
269void CBinds::SetDefaults()
270{
271 UnbindAll();
272
273 Bind(KeyId: KEY_F1, pStr: "toggle_local_console");
274 Bind(KeyId: KEY_F2, pStr: "toggle_remote_console");
275 Bind(KeyId: KEY_TAB, pStr: "+scoreboard");
276 Bind(KeyId: KEY_EQUALS, pStr: "+statboard");
277 Bind(KeyId: KEY_F10, pStr: "screenshot");
278
279 Bind(KeyId: KEY_A, pStr: "+left");
280 Bind(KeyId: KEY_D, pStr: "+right");
281
282 Bind(KeyId: KEY_SPACE, pStr: "+jump");
283 Bind(KeyId: KEY_MOUSE_1, pStr: "+fire");
284 Bind(KeyId: KEY_MOUSE_2, pStr: "+hook");
285 Bind(KeyId: KEY_LSHIFT, pStr: "+emote");
286 Bind(KeyId: KEY_RETURN, pStr: "+show_chat; chat all");
287 Bind(KeyId: KEY_RIGHT, pStr: "spectate_next");
288 Bind(KeyId: KEY_LEFT, pStr: "spectate_previous");
289 Bind(KeyId: KEY_RSHIFT, pStr: "+spectate");
290
291 Bind(KeyId: KEY_1, pStr: "+weapon1");
292 Bind(KeyId: KEY_2, pStr: "+weapon2");
293 Bind(KeyId: KEY_3, pStr: "+weapon3");
294 Bind(KeyId: KEY_4, pStr: "+weapon4");
295 Bind(KeyId: KEY_5, pStr: "+weapon5");
296
297 Bind(KeyId: KEY_MOUSE_WHEEL_UP, pStr: "+prevweapon");
298 Bind(KeyId: KEY_MOUSE_WHEEL_DOWN, pStr: "+nextweapon");
299
300 Bind(KeyId: KEY_T, pStr: "+show_chat; chat all");
301 Bind(KeyId: KEY_Y, pStr: "+show_chat; chat team");
302 Bind(KeyId: KEY_U, pStr: "+show_chat");
303 Bind(KeyId: KEY_I, pStr: "+show_chat; chat all /c ");
304
305 Bind(KeyId: KEY_F3, pStr: "vote yes");
306 Bind(KeyId: KEY_F4, pStr: "vote no");
307
308 Bind(KeyId: KEY_K, pStr: "kill");
309 Bind(KeyId: KEY_Q, pStr: "say /spec");
310 Bind(KeyId: KEY_P, pStr: "say /pause");
311
312 g_Config.m_ClDDRaceBindsSet = 0;
313 SetDDRaceBinds(false);
314}
315
316void CBinds::OnConsoleInit()
317{
318 ConfigManager()->RegisterCallback(pfnFunc: ConfigSaveCallback, pUserData: this);
319
320 Console()->Register(pName: "bind", pParams: "s[key] ?r[command]", Flags: CFGFLAG_CLIENT, pfnFunc: ConBind, pUser: this, pHelp: "Bind key to execute a command or view keybindings");
321 Console()->Register(pName: "binds", pParams: "?s[key]", Flags: CFGFLAG_CLIENT, pfnFunc: ConBinds, pUser: this, pHelp: "Print command executed by this keybinding or all binds");
322 Console()->Register(pName: "unbind", pParams: "s[key]", Flags: CFGFLAG_CLIENT, pfnFunc: ConUnbind, pUser: this, pHelp: "Unbind key");
323 Console()->Register(pName: "unbindall", pParams: "", Flags: CFGFLAG_CLIENT, pfnFunc: ConUnbindAll, pUser: this, pHelp: "Unbind all keys");
324
325 SetDefaults();
326}
327
328void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData)
329{
330 CBinds *pBinds = (CBinds *)pUserData;
331 const char *pBindStr = pResult->GetString(Index: 0);
332 const CBindSlot BindSlot = pBinds->GetBindSlot(pBindString: pBindStr);
333
334 if(!BindSlot.m_Key)
335 {
336 log_info_color(BIND_PRINT_COLOR, "binds", "key %s not found", pBindStr);
337 return;
338 }
339
340 if(pResult->NumArguments() == 1)
341 {
342 ConBinds(pResult, pUserData);
343 return;
344 }
345
346 pBinds->Bind(KeyId: BindSlot.m_Key, pStr: pResult->GetString(Index: 1), FreeOnly: false, ModifierCombination: BindSlot.m_ModifierMask);
347}
348
349void CBinds::ConBinds(IConsole::IResult *pResult, void *pUserData)
350{
351 CBinds *pBinds = (CBinds *)pUserData;
352 if(pResult->NumArguments() == 1)
353 {
354 const char *pKeyName = pResult->GetString(Index: 0);
355 const CBindSlot BindSlot = pBinds->GetBindSlot(pBindString: pKeyName);
356 if(!BindSlot.m_Key)
357 {
358 log_info_color(BIND_PRINT_COLOR, "binds", "key '%s' not found", pKeyName);
359 }
360 else
361 {
362 if(!pBinds->m_aapKeyBindings[BindSlot.m_ModifierMask][BindSlot.m_Key])
363 {
364 log_info_color(BIND_PRINT_COLOR, "binds", "%s is not bound", pKeyName);
365 }
366 else
367 {
368 char *pBuf = pBinds->GetKeyBindCommand(ModifierCombination: BindSlot.m_ModifierMask, Key: BindSlot.m_Key);
369 log_info_color(BIND_PRINT_COLOR, "binds", "%s", pBuf);
370 free(ptr: pBuf);
371 }
372 }
373 }
374 else
375 {
376 for(int Modifier = KeyModifier::NONE; Modifier < KeyModifier::COMBINATION_COUNT; Modifier++)
377 {
378 for(int Key = KEY_FIRST; Key < KEY_LAST; Key++)
379 {
380 if(!pBinds->m_aapKeyBindings[Modifier][Key])
381 continue;
382 char *pBuf = pBinds->GetKeyBindCommand(ModifierCombination: Modifier, Key);
383 log_info_color(BIND_PRINT_COLOR, "binds", "%s", pBuf);
384 free(ptr: pBuf);
385 }
386 }
387 }
388}
389
390void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
391{
392 CBinds *pBinds = (CBinds *)pUserData;
393 const char *pKeyName = pResult->GetString(Index: 0);
394 const CBindSlot BindSlot = pBinds->GetBindSlot(pBindString: pKeyName);
395
396 if(!BindSlot.m_Key)
397 {
398 log_info_color(BIND_PRINT_COLOR, "binds", "key %s not found", pKeyName);
399 return;
400 }
401
402 pBinds->Bind(KeyId: BindSlot.m_Key, pStr: "", FreeOnly: false, ModifierCombination: BindSlot.m_ModifierMask);
403}
404
405void CBinds::ConUnbindAll(IConsole::IResult *pResult, void *pUserData)
406{
407 CBinds *pBinds = (CBinds *)pUserData;
408 pBinds->UnbindAll();
409}
410
411CBindSlot CBinds::GetBindSlot(const char *pBindString) const
412{
413 int ModifierMask = KeyModifier::NONE;
414 char aMod[32];
415 aMod[0] = '\0';
416 const char *pKey = str_next_token(str: pBindString, delim: "+", buffer: aMod, buffer_size: sizeof(aMod));
417 while(aMod[0] && *(pKey))
418 {
419 if(!str_comp_nocase(a: aMod, b: "shift"))
420 ModifierMask |= (1 << KeyModifier::SHIFT);
421 else if(!str_comp_nocase(a: aMod, b: "ctrl"))
422 ModifierMask |= (1 << KeyModifier::CTRL);
423 else if(!str_comp_nocase(a: aMod, b: "alt"))
424 ModifierMask |= (1 << KeyModifier::ALT);
425 else if(!str_comp_nocase(a: aMod, b: "gui"))
426 ModifierMask |= (1 << KeyModifier::GUI);
427 else
428 return EMPTY_BIND_SLOT;
429
430 if(str_find(haystack: pKey + 1, needle: "+"))
431 {
432 pKey = str_next_token(str: pKey + 1, delim: "+", buffer: aMod, buffer_size: sizeof(aMod));
433 if(pKey == nullptr)
434 return EMPTY_BIND_SLOT;
435 }
436 else
437 break;
438 }
439 int Key = Input()->FindKeyByName(pKeyName: ModifierMask == KeyModifier::NONE ? aMod : pKey + 1);
440 if(Key == KEY_ESCAPE)
441 {
442 // Binding to Escape key is not supported
443 Key = KEY_UNKNOWN;
444 }
445 return {Key, ModifierMask};
446}
447
448const char *CBinds::GetModifierName(int Modifier)
449{
450 switch(Modifier)
451 {
452 case KeyModifier::SHIFT:
453 return "shift";
454 case KeyModifier::CTRL:
455 return "ctrl";
456 case KeyModifier::ALT:
457 return "alt";
458 case KeyModifier::GUI:
459 return "gui";
460 default:
461 dbg_assert_failed("Modifier invalid: %d", Modifier);
462 }
463}
464
465void CBinds::GetKeyBindName(int Key, int ModifierMask, char *pBuf, size_t BufSize) const
466{
467 pBuf[0] = '\0';
468 for(int Modifier = KeyModifier::CTRL; Modifier < KeyModifier::COUNT; Modifier++)
469 {
470 if(ModifierMask & (1 << Modifier))
471 {
472 str_append(dst: pBuf, src: GetModifierName(Modifier), dst_size: BufSize);
473 str_append(dst: pBuf, src: "+", dst_size: BufSize);
474 }
475 }
476 str_append(dst: pBuf, src: KeyName(Key), dst_size: BufSize);
477}
478
479char *CBinds::GetKeyBindCommand(int ModifierCombination, int Key) const
480{
481 char aBindName[128];
482 GetKeyBindName(Key, ModifierMask: ModifierCombination, pBuf: aBindName, BufSize: sizeof(aBindName));
483 // worst case the str_escape can double the string length
484 int Size = str_length(str: m_aapKeyBindings[ModifierCombination][Key]) * 2 + str_length(str: aBindName) + 16;
485 auto *pBuf = static_cast<char *>(malloc(size: Size));
486 str_format(buffer: pBuf, buffer_size: Size, format: "bind %s \"", aBindName);
487 char *pDst = pBuf + str_length(str: pBuf);
488 // process the string. we need to escape some characters
489 str_escape(dst: &pDst, src: m_aapKeyBindings[ModifierCombination][Key], end: pBuf + Size);
490 str_append(dst: pBuf, src: "\"", dst_size: Size);
491 return pBuf;
492}
493
494void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
495{
496 CBinds *pSelf = (CBinds *)pUserData;
497
498 pConfigManager->WriteLine(pLine: "unbindall");
499 for(int Modifier = KeyModifier::NONE; Modifier < KeyModifier::COMBINATION_COUNT; Modifier++)
500 {
501 for(int Key = KEY_FIRST; Key < KEY_LAST; Key++)
502 {
503 if(!pSelf->m_aapKeyBindings[Modifier][Key])
504 continue;
505 char *pBuf = pSelf->GetKeyBindCommand(ModifierCombination: Modifier, Key);
506 pConfigManager->WriteLine(pLine: pBuf);
507 free(ptr: pBuf);
508 }
509 }
510}
511
512// DDRace
513
514void CBinds::SetDDRaceBinds(bool FreeOnly)
515{
516 if(g_Config.m_ClDDRaceBindsSet < 1)
517 {
518 Bind(KeyId: KEY_KP_PLUS, pStr: "zoom+", FreeOnly);
519 Bind(KeyId: KEY_KP_MINUS, pStr: "zoom-", FreeOnly);
520 Bind(KeyId: KEY_KP_MULTIPLY, pStr: "zoom", FreeOnly);
521 Bind(KeyId: KEY_PAUSE, pStr: "say /pause", FreeOnly);
522 Bind(KeyId: KEY_UP, pStr: "+jump", FreeOnly);
523 Bind(KeyId: KEY_LEFT, pStr: "+left", FreeOnly);
524 Bind(KeyId: KEY_RIGHT, pStr: "+right", FreeOnly);
525 Bind(KeyId: KEY_LEFTBRACKET, pStr: "+prevweapon", FreeOnly);
526 Bind(KeyId: KEY_RIGHTBRACKET, pStr: "+nextweapon", FreeOnly);
527 Bind(KeyId: KEY_C, pStr: "say /rank", FreeOnly);
528 Bind(KeyId: KEY_V, pStr: "say /info", FreeOnly);
529 Bind(KeyId: KEY_B, pStr: "say /top5", FreeOnly);
530 Bind(KeyId: KEY_S, pStr: "+showhookcoll", FreeOnly);
531 Bind(KeyId: KEY_X, pStr: "toggle cl_dummy 0 1", FreeOnly);
532 Bind(KeyId: KEY_H, pStr: "toggle cl_dummy_hammer 0 1", FreeOnly);
533 Bind(KeyId: KEY_SLASH, pStr: "+show_chat; chat all /", FreeOnly);
534 Bind(KeyId: KEY_KP_0, pStr: "say /emote normal 999999", FreeOnly);
535 Bind(KeyId: KEY_KP_1, pStr: "say /emote happy 999999", FreeOnly);
536 Bind(KeyId: KEY_KP_2, pStr: "say /emote angry 999999", FreeOnly);
537 Bind(KeyId: KEY_KP_3, pStr: "say /emote pain 999999", FreeOnly);
538 Bind(KeyId: KEY_KP_4, pStr: "say /emote surprise 999999", FreeOnly);
539 Bind(KeyId: KEY_KP_5, pStr: "say /emote blink 999999", FreeOnly);
540 Bind(KeyId: KEY_MINUS, pStr: "spectate_previous", FreeOnly);
541 Bind(KeyId: KEY_EQUALS, pStr: "spectate_next", FreeOnly);
542 }
543
544 if(g_Config.m_ClDDRaceBindsSet < 2)
545 {
546 const bool DontModifySpectate = FreeOnly && str_comp(a: Get(KeyId: KEY_MOUSE_3, ModifierCombination: KeyModifier::NONE), b: "+spectate") != 0;
547 Bind(KeyId: KEY_MOUSE_3, pStr: "toggle_scoreboard_cursor; +spectate", FreeOnly: DontModifySpectate);
548 Bind(KeyId: KEY_LALT, pStr: "toggle_scoreboard_cursor", FreeOnly);
549 }
550
551 if(g_Config.m_ClDDRaceBindsSet < 3)
552 {
553 Bind(KeyId: KEY_W, pStr: "+jump", FreeOnly);
554 }
555
556 g_Config.m_ClDDRaceBindsSet = 3;
557}
558