Fixed an off-by-one error and config loading for reader name
Reading card 3 and above resulted in an off by one error that always threw a "this line isn't X bytes long" error. Readername now always gets properly loaded from config : I've added comments in the config file to make it obvious what each line does but that fucked up the reader name config. i'm now discarding the comment after loading the line. Updated readme.md
This commit is contained in:
parent
15ea3691e4
commit
44688bf9be
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
This allows you to a smartcard reader (specifically the acr122u) with segatools
|
This allows you to a smartcard reader (specifically the acr122u) with segatools
|
||||||
|
|
||||||
|
**This has only been confirmed working with Chunithm Sun and Sun + so far. Luminous doesn't seem to work yet !**
|
||||||
|
|
||||||
# Acknowledgments
|
# Acknowledgments
|
||||||
|
|
||||||
This is a plugin destined to be used with [Dniel97](https://gitea.tendokyu.moe/Dniel97)'s [segatools fork](https://gitea.tendokyu.moe/Dniel97/segatools) (but should work on others too).
|
This is a plugin destined to be used with [Dniel97](https://gitea.tendokyu.moe/Dniel97)'s [segatools fork](https://gitea.tendokyu.moe/Dniel97/segatools) (but should work on others too).
|
||||||
@ -26,9 +28,9 @@ scan=0x0D ;Sets the key which will be used to insert a card in game. Th
|
|||||||
|
|
||||||
;Everything below this line is optional.
|
;Everything below this line is optional.
|
||||||
|
|
||||||
;readerOptional=1 ;Make reader optional, so that you can still use the keyboard
|
readerOptional=1 ;Make reader optional, so that you can still use the keyboard
|
||||||
;readerName="ACS ACR122 0" ;Manually select which reader to use
|
readerName=ACS ACR122 0 ;Manually select which reader to use
|
||||||
;disableBuzzer=0 ;Disable the buzzer
|
disableBuzzer=1 ;Disable the buzzer
|
||||||
;aimePath="" ;Manually specify an aime.txt file
|
;aimePath="" ;Manually specify an aime.txt file
|
||||||
;felicaPath="" ;Manually specify a felica.txt file
|
;felicaPath="" ;Manually specify a felica.txt file
|
||||||
;debug=0 ;Display function calls
|
;debug=0 ;Display function calls
|
||||||
|
25
src/aimeio.c
25
src/aimeio.c
@ -9,6 +9,27 @@ static struct aime_io_config aime_io_cfg;
|
|||||||
static struct card_data card_data;
|
static struct card_data card_data;
|
||||||
|
|
||||||
#pragma region CONFIG
|
#pragma region CONFIG
|
||||||
|
// This is used because otherwise loading a reader with a given name while keeping the comment inline in the config file fails..
|
||||||
|
void RemoveCommentAndTruncate(wchar_t *value)
|
||||||
|
{
|
||||||
|
size_t len = wcslen(value);
|
||||||
|
wchar_t *semicolon = NULL;
|
||||||
|
|
||||||
|
// Remove comments
|
||||||
|
semicolon = wcschr(value, L';');
|
||||||
|
if (semicolon != NULL)
|
||||||
|
{
|
||||||
|
*semicolon = L'\0';
|
||||||
|
len = wcslen(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trim trailing whitespaces
|
||||||
|
while (len > 0 && (value[len - 1] == L' ' || value[len - 1] == L'\t' || value[len - 1] == L'\r' || value[len - 1] == L'\n'))
|
||||||
|
{
|
||||||
|
value[--len] = L'\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void aime_io_config_read(struct aime_io_config *cfg, const wchar_t *filename)
|
static void aime_io_config_read(struct aime_io_config *cfg, const wchar_t *filename)
|
||||||
{
|
{
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
@ -43,6 +64,7 @@ static void aime_io_config_read(struct aime_io_config *cfg, const wchar_t *filen
|
|||||||
cfg->reader_name,
|
cfg->reader_name,
|
||||||
_countof(cfg->reader_name),
|
_countof(cfg->reader_name),
|
||||||
filename);
|
filename);
|
||||||
|
RemoveCommentAndTruncate(cfg->reader_name);
|
||||||
|
|
||||||
cfg->reader_optional = GetPrivateProfileIntW(
|
cfg->reader_optional = GetPrivateProfileIntW(
|
||||||
L"aimeio",
|
L"aimeio",
|
||||||
@ -95,7 +117,10 @@ static HRESULT aime_io_read_id_file(const wchar_t *path, uint8_t *bytes, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
{
|
||||||
currentLine++;
|
currentLine++;
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user