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
2b6d5455b0
@ -1,7 +1,7 @@
|
||||
project(
|
||||
'aimeio_scard',
|
||||
'c',
|
||||
version : '0.0.2'
|
||||
version : '0.4.0'
|
||||
)
|
||||
|
||||
inc = include_directories('.')
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
;readerOptional=1 ;Make reader optional, so that you can still use the keyboard
|
||||
;readerName="ACS ACR122 0" ;Manually select which reader to use
|
||||
;disableBuzzer=0 ;Disable the buzzer
|
||||
readerOptional=1 ;Make reader optional, so that you can still use the keyboard
|
||||
readerName=ACS ACR122 0 ;Manually select which reader to use
|
||||
disableBuzzer=1 ;Disable the buzzer
|
||||
;aimePath="" ;Manually specify an aime.txt file
|
||||
;felicaPath="" ;Manually specify a felica.txt file
|
||||
;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;
|
||||
|
||||
#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)
|
||||
{
|
||||
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,
|
||||
_countof(cfg->reader_name),
|
||||
filename);
|
||||
RemoveCommentAndTruncate(cfg->reader_name);
|
||||
|
||||
cfg->reader_optional = GetPrivateProfileIntW(
|
||||
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')
|
||||
{
|
||||
currentLine++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user