Add key repeat
This commit is contained in:
parent
57097c57bb
commit
60cf16c8de
2 changed files with 14 additions and 3 deletions
2
TODO.txt
2
TODO.txt
|
@ -2,7 +2,6 @@ fuck issue trackers :D
|
||||||
|
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
- menu: key repeat?
|
|
||||||
- controller supports? analog input could be "tapping" the keys with varying
|
- controller supports? analog input could be "tapping" the keys with varying
|
||||||
frequency
|
frequency
|
||||||
- frontends:
|
- frontends:
|
||||||
|
@ -45,6 +44,7 @@ fuck issue trackers :D
|
||||||
=========== HANDLED ==============
|
=========== HANDLED ==============
|
||||||
|
|
||||||
- should drifting make a sound? NO NEED
|
- should drifting make a sound? NO NEED
|
||||||
|
- menu: key repeat?
|
||||||
- replay validation? maybe yes?
|
- replay validation? maybe yes?
|
||||||
- ghost color
|
- ghost color
|
||||||
- make reverse maps
|
- make reverse maps
|
||||||
|
|
15
game.h
15
game.h
|
@ -1366,6 +1366,17 @@ void LCR_gameSaveReplay(void)
|
||||||
LCR_gamePopupMessage(LCR_texts[LCR_TEXTS_SAVED]);
|
LCR_gamePopupMessage(LCR_texts[LCR_TEXTS_SAVED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks if given key is either immediately pressed or repeated after being
|
||||||
|
held for some time.
|
||||||
|
*/
|
||||||
|
uint8_t LCR_gameKeyActive(uint8_t key)
|
||||||
|
{
|
||||||
|
return LCR_game.keyStates[key] == 1 ||
|
||||||
|
(LCR_game.keyStates[key] >= (1200 / LCR_SETTING_FPS)
|
||||||
|
&& ((LCR_game.frame & 0x03) == 0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper subroutine, handles user input during main loop frame, EXCEPT for the
|
Helper subroutine, handles user input during main loop frame, EXCEPT for the
|
||||||
driving input (that is handled in the loop itself).
|
driving input (that is handled in the loop itself).
|
||||||
|
@ -1470,7 +1481,7 @@ void LCR_gameHandleInput(void)
|
||||||
LCR_game.menu.selectedItem = 0;
|
LCR_game.menu.selectedItem = 0;
|
||||||
LCR_audioPlaySound(LCR_SOUND_CLICK);
|
LCR_audioPlaySound(LCR_SOUND_CLICK);
|
||||||
}
|
}
|
||||||
else if (LCR_game.keyStates[LCR_KEY_UP] == 1)
|
else if (LCR_gameKeyActive(LCR_KEY_UP))
|
||||||
{
|
{
|
||||||
LCR_LOG1("menu item up");
|
LCR_LOG1("menu item up");
|
||||||
|
|
||||||
|
@ -1487,7 +1498,7 @@ void LCR_gameHandleInput(void)
|
||||||
scrolled = -1;
|
scrolled = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (LCR_game.keyStates[LCR_KEY_DOWN] == 1)
|
else if (LCR_gameKeyActive(LCR_KEY_DOWN))
|
||||||
{
|
{
|
||||||
LCR_LOG1("menu item down");
|
LCR_LOG1("menu item down");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue