Fix
This commit is contained in:
parent
dab7a7abfe
commit
9e4ce5a59a
@ -39,8 +39,11 @@ Keybindings P2_LEFT_BLUE = {};
|
|||||||
Keybindings P2_LEFT_RED = {};
|
Keybindings P2_LEFT_RED = {};
|
||||||
Keybindings P2_RIGHT_RED = {};
|
Keybindings P2_RIGHT_RED = {};
|
||||||
Keybindings P2_RIGHT_BLUE = {};
|
Keybindings P2_RIGHT_BLUE = {};
|
||||||
CardKeybindings *QRCODE_CARDS = new CardKeybindings[0];
|
CardKeybindings *QRCODE_CARDS = new CardKeybindings[] {
|
||||||
size_t QRCODE_CARDS_LENG = 0;
|
{.keybindings = {.keycodes = {'W'}}, .card = "BNTTCNID1"},
|
||||||
|
{.keybindings = {.keycodes = {'E'}}, .card = "BNTTCNID2"},
|
||||||
|
};
|
||||||
|
size_t QRCODE_CARDS_LENG = 2;
|
||||||
|
|
||||||
namespace bnusio {
|
namespace bnusio {
|
||||||
#define RETURN_FALSE(returnType, functionName, ...) \
|
#define RETURN_FALSE(returnType, functionName, ...) \
|
||||||
@ -344,7 +347,7 @@ Init () {
|
|||||||
SetConfigValue (keyconfig, "P2_RIGHT_RED", &P2_RIGHT_RED);
|
SetConfigValue (keyconfig, "P2_RIGHT_RED", &P2_RIGHT_RED);
|
||||||
SetConfigValue (keyconfig, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE);
|
SetConfigValue (keyconfig, "P2_RIGHT_BLUE", &P2_RIGHT_BLUE);
|
||||||
|
|
||||||
SetCardConfigValue (keyconfig, "QRCODE_CARD", QRCODE_CARDS, &QRCODE_CARDS_LENG);
|
SetCardConfigValue (keyconfig, "QRCODE_CARD", &QRCODE_CARDS, &QRCODE_CARDS_LENG);
|
||||||
|
|
||||||
toml_free (keyconfig);
|
toml_free (keyconfig);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ Update () {
|
|||||||
} else if (QRCODE_CARDS != nullptr) {
|
} else if (QRCODE_CARDS != nullptr) {
|
||||||
for (size_t i = 0; i < QRCODE_CARDS_LENG; i++) {
|
for (size_t i = 0; i < QRCODE_CARDS_LENG; i++) {
|
||||||
if (IsButtonTapped (QRCODE_CARDS[i].keybindings)) {
|
if (IsButtonTapped (QRCODE_CARDS[i].keybindings)) {
|
||||||
std::cout << "Insert" << std::endl;
|
std::cout << "Insert: " << QRCODE_CARDS[i].card << std::endl;
|
||||||
gState = State::CopyWait;
|
gState = State::CopyWait;
|
||||||
gMode = Mode::MultiCard;
|
gMode = Mode::MultiCard;
|
||||||
gCardNumber = QRCODE_CARDS[i].card;
|
gCardNumber = QRCODE_CARDS[i].card;
|
||||||
|
21
src/poll.cpp
21
src/poll.cpp
@ -130,6 +130,7 @@ SDL_GameController *controllers[255];
|
|||||||
|
|
||||||
void
|
void
|
||||||
SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind) {
|
SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind) {
|
||||||
|
std::cout << "Name: " << key << std::endl;
|
||||||
toml_array_t *array = toml_array_in (table, key);
|
toml_array_t *array = toml_array_in (table, key);
|
||||||
if (!array) {
|
if (!array) {
|
||||||
printWarning ("%s (%s): Cannot find array\n", __func__, key);
|
printWarning ("%s (%s): Cannot find array\n", __func__, key);
|
||||||
@ -143,6 +144,7 @@ SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind) {
|
|||||||
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);
|
||||||
if (!bind.ok) break;
|
if (!bind.ok) break;
|
||||||
|
std::cout << "Key: " << bind.u.s << std::endl;
|
||||||
ConfigValue value = StringToConfigEnum (bind.u.s);
|
ConfigValue value = StringToConfigEnum (bind.u.s);
|
||||||
free (bind.u.s);
|
free (bind.u.s);
|
||||||
|
|
||||||
@ -185,22 +187,24 @@ SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards, size_t *leng) {
|
SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings **cards, size_t *leng) {
|
||||||
toml_array_t *top_array = toml_array_in (table, key);
|
toml_array_t *top_array = toml_array_in (table, key);
|
||||||
if (!top_array) {
|
if (!top_array) {
|
||||||
printWarning ("%s (%s): Cannot find array\n", __func__, key);
|
printWarning ("%s (%s): Cannot find array\n", __func__, key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length = toml_array_nelem(top_array);
|
*leng = toml_array_nelem(top_array);
|
||||||
*leng = length;
|
*cards = (CardKeybindings*) calloc (*leng, sizeof(CardKeybindings));
|
||||||
cards = new CardKeybindings[length];
|
|
||||||
|
|
||||||
for (size_t top_i = 0; top_i < length; ++top_i) {
|
for (size_t top_i = 0; top_i < *leng; ++top_i) {
|
||||||
toml_table_t* card_obj = toml_table_at(top_array, top_i);
|
toml_table_t* card_obj = toml_table_at(top_array, top_i);
|
||||||
if (card_obj) {
|
if (card_obj) {
|
||||||
CardKeybindings cardInfo = cards[top_i] = {};
|
std::string read_card = readConfigString (card_obj, "CARD", "");
|
||||||
cardInfo.card = readConfigString(card_obj, "CARD", "");
|
(*cards)[top_i].card = (char*) calloc (read_card.size() + 1, sizeof(char));
|
||||||
|
strcpy((*cards)[top_i].card, read_card.c_str());
|
||||||
|
|
||||||
|
std::cout << "Card: " << (*cards)[top_i].card << std::endl;
|
||||||
|
|
||||||
toml_array_t *array = toml_array_in (card_obj, "READ_KEY");
|
toml_array_t *array = toml_array_in (card_obj, "READ_KEY");
|
||||||
if (!array) {
|
if (!array) {
|
||||||
@ -208,7 +212,7 @@ SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Keybindings *keybind = &(cardInfo.keybindings);
|
Keybindings *keybind = &((*cards)[top_i].keybindings);
|
||||||
memset (keybind, 0, sizeof (*keybind));
|
memset (keybind, 0, sizeof (*keybind));
|
||||||
for (size_t i = 0; i < COUNTOFARR (keybind->buttons); i++)
|
for (size_t i = 0; i < COUNTOFARR (keybind->buttons); i++)
|
||||||
keybind->buttons[i] = SDL_CONTROLLER_BUTTON_INVALID;
|
keybind->buttons[i] = SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
@ -216,6 +220,7 @@ SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *cards
|
|||||||
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);
|
||||||
if (!bind.ok) break;
|
if (!bind.ok) break;
|
||||||
|
std::cout << "Key: " << bind.u.s << std::endl;
|
||||||
ConfigValue value = StringToConfigEnum (bind.u.s);
|
ConfigValue value = StringToConfigEnum (bind.u.s);
|
||||||
free (bind.u.s);
|
free (bind.u.s);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ struct Keybindings {
|
|||||||
|
|
||||||
struct CardKeybindings {
|
struct CardKeybindings {
|
||||||
Keybindings keybindings;
|
Keybindings keybindings;
|
||||||
std::string card;
|
char* card;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EnumType { none, keycode, button, axis, scroll };
|
enum EnumType { none, keycode, button, axis, scroll };
|
||||||
@ -71,7 +71,7 @@ void UpdatePoll (HWND windowHandle);
|
|||||||
void DisposePoll ();
|
void DisposePoll ();
|
||||||
ConfigValue StringToConfigEnum (const char *value);
|
ConfigValue StringToConfigEnum (const char *value);
|
||||||
void SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind);
|
void SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind);
|
||||||
void SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings *keybind, size_t *leng);
|
void SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings **keybind, size_t *leng);
|
||||||
InternalButtonState GetInternalButtonState (Keybindings bindings);
|
InternalButtonState GetInternalButtonState (Keybindings bindings);
|
||||||
void SetRumble (int left, int right, int length);
|
void SetRumble (int left, int right, int length);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user