MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / InputBind_Load

Function InputBind_Load

src/Input.c:474–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472}
473
474void InputBind_Load(const struct InputDevice* device) {
475 cc_string name; char nameBuffer[STRING_SIZE + 1];
476 const BindMapping* defaults = device->defaultBinds;
477 BindMapping* keybinds = device->currentBinds;
478 BindMapping mapping;
479 cc_string str, part1, part2;
480 int i;
481
482 String_InitArray_NT(name, nameBuffer);
483 for (i = 0; i < BIND_COUNT; i++)
484 {
485 name.length = 0;
486 String_Format1(&name, device->bindPrefix, bindNames[i]);
487 name.buffer[name.length] = '\0';
488
489 if (!Options_UNSAFE_Get(name.buffer, &str)) {
490 keybinds[i] = defaults[i];
491 continue;
492 }
493
494 String_UNSAFE_Separate(&str, ',', &part1, &part2);
495 mapping.button1 = Utils_ParseEnum(&part1, defaults[i].button1, Input_StorageNames, INPUT_COUNT);
496 mapping.button2 = Utils_ParseEnum(&part2, defaults[i].button2, Input_StorageNames, INPUT_COUNT);
497
498 if (mapping.button1 == CCKEY_ESCAPE) keybinds[i] = defaults[i];
499 keybinds[i] = mapping;
500 }
501}
502
503void InputBind_Set(InputBind binding, int btn, const struct InputDevice* device) {
504 cc_string name; char nameBuffer[STRING_SIZE];

Callers 2

Gamepad_AddFunction · 0.85
OnInitFunction · 0.85

Calls 4

String_Format1Function · 0.85
Options_UNSAFE_GetFunction · 0.85
String_UNSAFE_SeparateFunction · 0.85
Utils_ParseEnumFunction · 0.85

Tested by

no test coverage detected