1
0
mirror of synced 2024-11-24 15:10:16 +01:00

Add QR customfolder support

This commit is contained in:
esuo1198 2023-09-24 01:08:12 +09:00
parent 92c3e6aa81
commit db6a0c061b
10 changed files with 97 additions and 34 deletions

9
dist/config.toml vendored
View File

@ -1,7 +1,12 @@
[amauth]
server = "127.0.0.1"
[patches]
res = { x = 1920, y = 1080 }
unlock_songs = true
shared_audio = true
vsync = false
qr_card_string = ""
qr_data_string = ""
[qr]
card = ""
data = { serial = "", type = 0, song_no = [] }

4
dist/keyconfig.toml vendored
View File

@ -7,9 +7,9 @@ DEBUG_DOWN = ["DOWNARROW"]
DEBUG_ENTER = ["ENTER"]
COIN_ADD = ["ENTER", "SDL_START"]
CARD_INSERT_1 = ["P"]
CARD_INSERT_1 = []
CARD_INSERT_2 = []
QR_CARD_READ = ["O"]
QR_CARD_READ = []
QR_DATA_READ = ["Q"]
P1_LEFT_BLUE = ["D", "SDL_LTRIGGER"]

View File

@ -114,7 +114,10 @@ DllMain (HMODULE module, DWORD reason, LPVOID reserved) {
auto configPath = std::filesystem::current_path () / "config.toml";
toml_table_t *config = openConfig (configPath);
if (config) {
server = readConfigString (config, "server", server);
auto amauth = openConfigSection(config, "amauth");
if (amauth) {
server = readConfigString(amauth, "server", server);
}
toml_free (config);
}

View File

@ -71,6 +71,21 @@ readConfigString (toml_table_t *table, const char *key, const char *notFoundValu
return data.u.s;
}
std::vector<int64_t>
readConfigIntArray (toml_table_t *table, const char *key, std::vector<int64_t> notFoundValue) {
toml_array_t *array = toml_array_in (table, key);
if (!array) return notFoundValue;
std::vector<int64_t> datas;
for (int i = 0; ; i++) {
toml_datum_t data = toml_int_at (array, i);
if (!data.ok) break;
datas.push_back (data.u.i);
}
return datas;
}
void
printColour (int colour, const char *format, ...) {
va_list args;

View File

@ -119,4 +119,5 @@ toml_table_t *openConfigSection (toml_table_t *config, const char *sectionName);
bool readConfigBool (toml_table_t *table, const char *key, bool notFoundValue);
int64_t readConfigInt (toml_table_t *table, const char *key, int64_t notFoundValue);
const char *readConfigString (toml_table_t *table, const char *key, const char *notFoundValue);
std::vector<int64_t> readConfigIntArray (toml_table_t *table, const char *key, std::vector<int64_t> notFoundValue);
void printColour (int colour, const char *format, ...);

View File

@ -9,9 +9,9 @@ Keybindings DEBUG_UP = {.keycodes = {VK_UP}};
Keybindings DEBUG_DOWN = {.keycodes = {VK_DOWN}};
Keybindings DEBUG_ENTER = {.keycodes = {VK_RETURN}};
Keybindings COIN_ADD = {.keycodes = {VK_RETURN}, .buttons = {SDL_CONTROLLER_BUTTON_START}};
Keybindings CARD_INSERT_1 = {.keycodes = {'P'}};
Keybindings CARD_INSERT_1 = {};
Keybindings CARD_INSERT_2 = {};
Keybindings QR_CARD_READ = {.keycodes = {'O'}};
Keybindings QR_CARD_READ = {};
Keybindings QR_DATA_READ = {.keycodes = {'Q'}};
Keybindings P1_LEFT_BLUE = {.keycodes = {'D'}, .axis = {SDL_AXIS_LTRIGGER_DOWN}};
Keybindings P1_LEFT_RED = {.keycodes = {'F'}, .buttons = {SDL_CONTROLLER_BUTTON_LEFTSTICK}};

View File

@ -13,7 +13,7 @@ DWORD reg = 0;
#undef DEFINE_GUID
#endif
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
DEFINE_GUID (IID_CAuthFactory, 0x4603BB03, 0x058D, 0x43D9, 0xB9, 0x6F, 0x63, 0x9B, 0xE9, 0x08, 0xC1, 0xED);
DEFINE_GUID (IID_CAuth, 0x045A5150, 0xD2B3, 0x4590, 0xA3, 0x8B, 0xC1, 0x15, 0x86, 0x78, 0xE1, 0xAC);

View File

@ -48,14 +48,17 @@ Init () {
auto configPath = std::filesystem::current_path () / "config.toml";
toml_table_t *config = openConfig (configPath);
if (config) {
auto res = openConfigSection (config, "res");
if (res) {
xRes = readConfigInt (res, "x", xRes);
yRes = readConfigInt (res, "y", yRes);
auto patches = openConfigSection(config, "patches");
if (patches) {
auto res = openConfigSection (patches, "res");
if (res) {
xRes = readConfigInt (res, "x", xRes);
yRes = readConfigInt (res, "y", yRes);
}
unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs);
sharedAudio = readConfigBool (patches, "shared_audio", sharedAudio);
vsync = readConfigBool (patches, "vsync", vsync);
}
unlockSongs = readConfigBool (config, "unlock_songs", unlockSongs);
sharedAudio = readConfigBool (config, "shared_audio", sharedAudio);
vsync = readConfigBool (config, "vsync", vsync);
toml_free (config);
}

View File

@ -22,14 +22,17 @@ Init () {
auto configPath = std::filesystem::current_path () / "config.toml";
toml_table_t *config = openConfig (configPath);
if (config) {
auto res = openConfigSection (config, "res");
if (res) {
xRes = readConfigInt (res, "x", xRes);
yRes = readConfigInt (res, "y", yRes);
auto patches = openConfigSection(config, "patches");
if (patches) {
auto res = openConfigSection (patches, "res");
if (res) {
xRes = readConfigInt (res, "x", xRes);
yRes = readConfigInt (res, "y", yRes);
}
unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs);
sharedAudio = readConfigBool (patches, "shared_audio", sharedAudio);
vsync = readConfigBool (patches, "vsync", vsync);
}
unlockSongs = readConfigBool (config, "unlock_songs", unlockSongs);
sharedAudio = readConfigBool (config, "shared_audio", sharedAudio);
vsync = readConfigBool (config, "vsync", vsync);
toml_free (config);
}

View File

@ -65,31 +65,64 @@ HOOK_DYNAMIC (bool, __fastcall, Send4, int64_t a1) {
HOOK_DYNAMIC (int64_t, __fastcall, copy_data, int64_t this_, void *dest, int length) {
if (gState == State::CopyWait) {
std::cout << "Copy data, length: " << length << std::endl;
auto configPath = std::filesystem::current_path () / "config.toml";
toml_table_t *config = openConfig (configPath);
std::string data = "";
if (gMode == Mode::Card) {
std::string card = "";
if (config) {
data = readConfigString (config, "qr_card_string", "");
toml_free (config);
auto qr = openConfigSection(config, "qr");
if (qr) {
card = readConfigString(qr, "card", "");
}
toml_free(config);
}
memcpy (dest, data.c_str (), data.size () + 1);
memcpy (dest, card.c_str (), card.size () + 1);
gState = State::AfterCopy1;
return data.size () + 1;
} else if (gMode == Mode::Data) {
return card.size () + 1;
} else {
std::string serial = "";
u16 type = 0;
std::vector<i64> songNoes;
if (config) {
data = readConfigString (config, "qr_data_string", "");
toml_free (config);
auto qr = openConfigSection (config, "qr");
if (qr) {
auto data = openConfigSection (qr, "data");
if (data) {
serial = readConfigString (data, "serial", "");
type = readConfigInt (data, "type", 0);
songNoes = readConfigIntArray (data, "song_no", songNoes);
}
}
}
BYTE data_length = static_cast<BYTE> (data.size ());
std::vector<BYTE> byteBuffer = {0x53, 0x31, 0x32, 0x00, 0x00, 0xFF, 0xFF, data_length, 0x01, 0x00};
BYTE serial_length = static_cast<BYTE> (serial.size ());
std::vector<BYTE> byteBuffer = {0x53, 0x31, 0x32, 0x00, 0x00, 0xFF, 0xFF, serial_length, 0x01, 0x00};
for (char c : data)
for (char c : serial)
byteBuffer.push_back (static_cast<BYTE> (c));
if (type == 5) {
std::vector<BYTE> folderData = {0xFF, 0xFF};
folderData.push_back (songNoes.size() * 2);
folderData.push_back (static_cast<u8> (type & 0xFF));
folderData.push_back (static_cast<u8> ((type >> 8) & 0xFF));
for (u16 songNo:songNoes) {
folderData.push_back (static_cast<u8> (songNo & 0xFF));
folderData.push_back (static_cast<u8> ((songNo >> 8) & 0xFF));
}
for (auto c:folderData) {
byteBuffer.push_back (c);
}
}
byteBuffer.push_back (0xEE);
byteBuffer.push_back (0xFF);