修复异常
This commit is contained in:
parent
c50ab88ce1
commit
b510c1e535
@ -39,8 +39,8 @@ Keybindings P2_LEFT_BLUE = {};
|
||||
Keybindings P2_LEFT_RED = {};
|
||||
Keybindings P2_RIGHT_RED = {};
|
||||
Keybindings P2_RIGHT_BLUE = {};
|
||||
CardKeybingings* QRCODE_CARDS = {{.keybindings.keycodes = {'W'}, .card = "BNTTCNID1"}, {.keybindings.keycodes = {'E'}, .card = "BNTTCNID2"}};
|
||||
size_t QRCODE_CARDS_LENG = 2;
|
||||
CardKeybindings *QRCODE_CARDS = {};
|
||||
size_t QRCODE_CARDS_LENG = 0;
|
||||
|
||||
namespace bnusio {
|
||||
#define RETURN_FALSE(returnType, functionName, ...) \
|
||||
|
@ -11,16 +11,16 @@
|
||||
extern GameVersion gameVersion;
|
||||
extern Keybindings QR_CARD_READ;
|
||||
extern Keybindings QR_DATA_READ;
|
||||
extern CardKeybingings *QRCODE_CARDS;
|
||||
extern CardKeybindings *QRCODE_CARDS;
|
||||
extern size_t QRCODE_CARDS_LENG;
|
||||
|
||||
namespace patches::Qr {
|
||||
|
||||
enum class State { Ready, CopyWait, AfterCopy1, AfterCopy2 };
|
||||
enum class Mode { Card, Data };
|
||||
State gState = State::Ready;
|
||||
Mode gMode = Mode::Card;
|
||||
std::string card_number = "";
|
||||
enum class Mode { Card, Data, MultiCard };
|
||||
State gState = State::Ready;
|
||||
Mode gMode = Mode::Card;
|
||||
std::string gCardNumber = "";
|
||||
|
||||
HOOK_DYNAMIC (char, __fastcall, qrInit, i64) { return 1; }
|
||||
HOOK_DYNAMIC (char, __fastcall, qrRead, i64 a1) {
|
||||
@ -79,9 +79,9 @@ HOOK_DYNAMIC (i64, __fastcall, copy_data, i64, void *dest, int length) {
|
||||
return card.size () + 1;
|
||||
} else if (gMode == Mode::MultiCard) {
|
||||
if (config) toml_free (config);
|
||||
memcpy (dest, card_number.c_str (), card_number.size () + 1);
|
||||
memcpy (dest, gCardNumber.c_str (), gCardNumber.size () + 1);
|
||||
gState = State::AfterCopy1;
|
||||
return card_number.size () + 1;
|
||||
return gCardNumber.size () + 1;
|
||||
} else {
|
||||
std::string serial = "";
|
||||
u16 type = 0;
|
||||
@ -154,13 +154,13 @@ Update () {
|
||||
std::cout << "Insert" << std::endl;
|
||||
gState = State::CopyWait;
|
||||
gMode = Mode::Data;
|
||||
} else {
|
||||
} else if (QRCODE_CARDS != nullptr) {
|
||||
for (size_t i = 0; i < QRCODE_CARDS_LENG; i++) {
|
||||
if (IsButtonTapped (QRCODE_CARDS[i].keybindings)) {
|
||||
std::cout << "Insert" << std::endl;
|
||||
gState = State::CopyWait;
|
||||
gMode = Mode::MultiCard;
|
||||
card_number = QRCODE_CARDS[i].card;
|
||||
gState = State::CopyWait;
|
||||
gMode = Mode::MultiCard;
|
||||
gCardNumber = QRCODE_CARDS[i].card;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
20
src/poll.cpp
20
src/poll.cpp
@ -186,23 +186,29 @@ SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind) {
|
||||
|
||||
void
|
||||
SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings **cards, size_t *leng) {
|
||||
toml_array_t *array = toml_array_in (table, key);
|
||||
if (!array) {
|
||||
toml_array_t *top_array = toml_array_in (table, key);
|
||||
if (!top_array) {
|
||||
printWarning ("%s (%s): Cannot find array\n", __func__, key);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t length = toml_array_nelem(array);
|
||||
size_t length = toml_array_nelem(top_array);
|
||||
*leng = length;
|
||||
cards = memset(*cards, 0, length * (sizeof (*cards)));
|
||||
memset(cards, 0, length * (sizeof (*cards)));
|
||||
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
const toml_table_t* card_obj = toml_table_at(arr, i);
|
||||
toml_table_t* card_obj = toml_table_at(top_array, i);
|
||||
if (card_obj) {
|
||||
memset (cards[i], 0, sizeof (**cards));
|
||||
cards[i]->card = toml_string_in(obj, "CARD")
|
||||
cards[i]->card = readConfigString(card_obj, "CARD", "");
|
||||
|
||||
for (size_t i = 0; i < COUNTOFARR (keybind->buttons); i++)
|
||||
toml_array_t *array = toml_array_in (card_obj, "READ_KEY");
|
||||
if (!array) {
|
||||
printWarning ("%s (%s): Cannot find READ_KEY in CARD_INFO\n", __func__, key);
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < COUNTOFARR (cards[i]->keybindings.buttons); i++)
|
||||
cards[i]->keybindings.buttons[i] = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
|
||||
for (size_t i = 0;; i++) {
|
||||
|
@ -43,10 +43,10 @@ struct Keybindings {
|
||||
Scroll scroll[2];
|
||||
};
|
||||
|
||||
struct CardKeybingings {
|
||||
struct CardKeybindings {
|
||||
Keybindings keybindings;
|
||||
std::string card;
|
||||
}
|
||||
};
|
||||
|
||||
enum EnumType { none, keycode, button, axis, scroll };
|
||||
|
||||
@ -71,7 +71,7 @@ void UpdatePoll (HWND windowHandle);
|
||||
void DisposePoll ();
|
||||
ConfigValue StringToConfigEnum (const char *value);
|
||||
void SetConfigValue (toml_table_t *table, const char *key, Keybindings *keybind);
|
||||
void SetCardConfigValue (toml_table_t *table, const char *key, CardKeybingings **keybind, size_t *leng);
|
||||
void SetCardConfigValue (toml_table_t *table, const char *key, CardKeybindings **keybind, size_t *leng);
|
||||
InternalButtonState GetInternalButtonState (Keybindings bindings);
|
||||
void SetRumble (int left, int right, int length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user