mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-04-04 01:27:11 +02:00
keysc: have getkey() sleep
This was embarassingly no longer the case since the move to the keydev API.
This commit is contained in:
parent
e95a91d5ab
commit
2b4075c8f9
3 changed files with 14 additions and 5 deletions
|
@ -284,8 +284,11 @@ void keydev_set_transform(keydev_t *d, keydev_transform_t tr);
|
||||||
@next_us Delay between subsequent repeats (microseconds) */
|
@next_us Delay between subsequent repeats (microseconds) */
|
||||||
void keydev_set_standard_repeats(keydev_t *d, int first_us, int next_us);
|
void keydev_set_standard_repeats(keydev_t *d, int first_us, int next_us);
|
||||||
|
|
||||||
/* keydev_read(): Retrieve the next transformed event */
|
/* keydev_read(): Retrieve the next transformed event
|
||||||
key_event_t keydev_read(keydev_t *d);
|
If there is no event, returns an event with type KEYEV_NONE, unless
|
||||||
|
[wait=true], in which case waits for an event to occur or *timeout to
|
||||||
|
become non-zero (if timeout is not NULL), whichever comes first. */
|
||||||
|
key_event_t keydev_read(keydev_t *d, bool wait, volatile int *timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ key_event_t getkey_opt(int opt, volatile int *timeout)
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
e = keydev_read(d);
|
e = keydev_read(d, true, timeout);
|
||||||
if(e.type == KEYEV_NONE && timeout && *timeout) break;
|
if(e.type == KEYEV_NONE && timeout && *timeout) break;
|
||||||
|
|
||||||
/* Skip repeat events that are not enabled by options */
|
/* Skip repeat events that are not enabled by options */
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//---
|
//---
|
||||||
|
|
||||||
#include <gint/keyboard.h>
|
#include <gint/keyboard.h>
|
||||||
|
#include <gint/cpu.h>
|
||||||
#include <gint/drivers/keydev.h>
|
#include <gint/drivers/keydev.h>
|
||||||
#include <gint/defs/types.h>
|
#include <gint/defs/types.h>
|
||||||
#include <gint/defs/util.h>
|
#include <gint/defs/util.h>
|
||||||
|
@ -239,7 +240,7 @@ void keydev_set_standard_repeats(keydev_t *d, int first, int next)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keydev_read(): Retrieve the next transformed event */
|
/* keydev_read(): Retrieve the next transformed event */
|
||||||
key_event_t keydev_read(keydev_t *d)
|
key_event_t keydev_read(keydev_t *d, bool wait, volatile int *timeout)
|
||||||
{
|
{
|
||||||
#define opt(NAME) (d->tr.enabled & KEYDEV_TR_ ## NAME)
|
#define opt(NAME) (d->tr.enabled & KEYDEV_TR_ ## NAME)
|
||||||
key_event_t e;
|
key_event_t e;
|
||||||
|
@ -248,7 +249,12 @@ key_event_t keydev_read(keydev_t *d)
|
||||||
{
|
{
|
||||||
e = keydev_unqueue_event(d);
|
e = keydev_unqueue_event(d);
|
||||||
if(e.type == KEYEV_NONE)
|
if(e.type == KEYEV_NONE)
|
||||||
return e;
|
{
|
||||||
|
if(!wait || (timeout && *timeout))
|
||||||
|
return e;
|
||||||
|
sleep();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int k = e.key;
|
int k = e.key;
|
||||||
e.mod = (opt(ALL_MODS) != 0);
|
e.mod = (opt(ALL_MODS) != 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue