#484 key api always should return bool value

This commit is contained in:
BADIM-PC\Vadim
2017-12-29 19:11:52 +03:00
parent 375df9ba81
commit 16ba85425d
4 changed files with 10 additions and 12 deletions
+4 -6
View File
@@ -1648,14 +1648,14 @@ static u32 api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)
return ((~previous.data) & machine->memory.ram.input.gamepads.data) & (1 << index);
}
static u32 api_key(tic_mem* tic, tic_key key)
static bool api_key(tic_mem* tic, tic_key key)
{
return key >= TIC_KEY_START_INDEX
? isKeyPressed(&tic->ram.input.keyboard, key)
: tic->ram.input.keyboard.data;
}
static u32 api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period)
static bool api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period)
{
tic_machine* machine = (tic_machine*)tic;
@@ -1672,8 +1672,6 @@ static u32 api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period)
return !prevDown && down;
}
tic80_keyboard prev = {.data = 0};
for(s32 i = 0; i < TIC_KEY_BUFFER; i++)
{
tic_key key = tic->ram.input.keyboard.keys[i];
@@ -1692,11 +1690,11 @@ static u32 api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period)
}
if(!wasPressed)
prev.keys[i] = key;
return true;
}
}
return prev.data;
return false;
}