test
This commit is contained in:
parent
df389c72fc
commit
9e0f973e85
33
src/poll.cpp
33
src/poll.cpp
@ -196,11 +196,10 @@ SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards
|
|||||||
*leng = length;
|
*leng = length;
|
||||||
cards = new CardKeybindings[length];
|
cards = new CardKeybindings[length];
|
||||||
|
|
||||||
for (size_t i = 0; i < length; ++i) {
|
for (size_t top_i = 0; top_i < length; ++top_i) {
|
||||||
toml_table_t* card_obj = toml_table_at(top_array, i);
|
toml_table_t* card_obj = toml_table_at(top_array, i);
|
||||||
if (card_obj) {
|
if (card_obj) {
|
||||||
CardKeybindings cardInfo = cards[i] = {};
|
CardKeybindings cardInfo = cards[i] = {};
|
||||||
memset(&cardInfo.keybindings, 0, sizeof(cardInfo.keybindings));
|
|
||||||
cardInfo.card = readConfigString(card_obj, "CARD", "");
|
cardInfo.card = readConfigString(card_obj, "CARD", "");
|
||||||
|
|
||||||
toml_array_t *array = toml_array_in (card_obj, "READ_KEY");
|
toml_array_t *array = toml_array_in (card_obj, "READ_KEY");
|
||||||
@ -209,8 +208,10 @@ SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < COUNTOFARR (cardInfo.keybindings.buttons); i++)
|
Keybindings *keybind = &(cardInfo.keybindings);
|
||||||
cardInfo.keybindings.buttons[i] = SDL_CONTROLLER_BUTTON_INVALID;
|
memset (keybind, 0, sizeof (*keybind));
|
||||||
|
for (size_t i = 0; i < COUNTOFARR (keybind->buttons); i++)
|
||||||
|
keybind->buttons[i] = SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
|
|
||||||
for (size_t i = 0;; i++) {
|
for (size_t i = 0;; i++) {
|
||||||
toml_datum_t bind = toml_string_at (array, i);
|
toml_datum_t bind = toml_string_at (array, i);
|
||||||
@ -220,32 +221,32 @@ SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards
|
|||||||
|
|
||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
case keycode:
|
case keycode:
|
||||||
for (size_t i = 0; i < COUNTOFARR (cardInfo.keybindings.keycodes); i++) {
|
for (size_t i = 0; i < COUNTOFARR (keybind->keycodes); i++) {
|
||||||
if (cardInfo.keybindings.keycodes[i] == 0) {
|
if (keybind->keycodes[i] == 0) {
|
||||||
cardInfo.keybindings.keycodes[i] = value.keycode;
|
keybind->keycodes[i] = value.keycode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case button:
|
case button:
|
||||||
for (size_t i = 0; i < COUNTOFARR (cardInfo.keybindings.buttons); i++) {
|
for (size_t i = 0; i < COUNTOFARR (keybind->buttons); i++) {
|
||||||
if (cardInfo.keybindings.buttons[i] == SDL_CONTROLLER_BUTTON_INVALID) {
|
if (keybind->buttons[i] == SDL_CONTROLLER_BUTTON_INVALID) {
|
||||||
cardInfo.keybindings.buttons[i] = value.button;
|
keybind->buttons[i] = value.button;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case axis:
|
case axis:
|
||||||
for (size_t i = 0; i < COUNTOFARR (cardInfo.keybindings.axis); i++) {
|
for (size_t i = 0; i < COUNTOFARR (keybind->axis); i++) {
|
||||||
if (cardInfo.keybindings.axis[i] == 0) {
|
if (keybind->axis[i] == 0) {
|
||||||
cardInfo.keybindings.axis[i] = value.axis;
|
keybind->axis[i] = value.axis;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case scroll:
|
case scroll:
|
||||||
for (size_t i = 0; i < COUNTOFARR (cardInfo.keybindings.scroll); i++) {
|
for (size_t i = 0; i < COUNTOFARR (keybind->scroll); i++) {
|
||||||
if (cardInfo.keybindings.scroll[i] == 0) {
|
if (keybind->scroll[i] == 0) {
|
||||||
cardInfo.keybindings.scroll[i] = value.scroll;
|
keybind->scroll[i] = value.scroll;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user