forked from len0rd/rockbox
Added raw button reading functionality
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4907 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
69697aefe8
commit
a754dd84b8
6 changed files with 41 additions and 16 deletions
|
|
@ -253,6 +253,8 @@ static const struct plugin_api rockbox_api = {
|
||||||
#endif
|
#endif
|
||||||
settings_parseline,
|
settings_parseline,
|
||||||
strcmp,
|
strcmp,
|
||||||
|
button_status,
|
||||||
|
button_clear_queue,
|
||||||
};
|
};
|
||||||
|
|
||||||
int plugin_load(char* plugin, void* parameter)
|
int plugin_load(char* plugin, void* parameter)
|
||||||
|
|
@ -332,7 +334,10 @@ int plugin_load(char* plugin, void* parameter)
|
||||||
|
|
||||||
plugin_loaded = true;
|
plugin_loaded = true;
|
||||||
rc = plugin_start((struct plugin_api*) &rockbox_api, parameter);
|
rc = plugin_start((struct plugin_api*) &rockbox_api, parameter);
|
||||||
/* explicitly casting the pointer here to avoid touching every plugin. */
|
/* explicitly casting the pointer here to avoid touching every plugin. */
|
||||||
|
|
||||||
|
button_clear_queue();
|
||||||
|
|
||||||
plugin_loaded = false;
|
plugin_loaded = false;
|
||||||
|
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,8 @@ struct plugin_api {
|
||||||
#endif
|
#endif
|
||||||
bool (*settings_parseline)(char* line, char** name, char** value);
|
bool (*settings_parseline)(char* line, char** name, char** value);
|
||||||
int (*strcmp)(const char *, const char *);
|
int (*strcmp)(const char *, const char *);
|
||||||
|
int (*button_status)(void);
|
||||||
|
void (*button_clear_queue)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* defined by the plugin loader (plugin.c) */
|
/* defined by the plugin loader (plugin.c) */
|
||||||
|
|
|
||||||
|
|
@ -421,3 +421,13 @@ int button_add(unsigned int button)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int button_status(void)
|
||||||
|
{
|
||||||
|
return button_read();
|
||||||
|
}
|
||||||
|
|
||||||
|
void button_clear_queue(void)
|
||||||
|
{
|
||||||
|
queue_empty(&button_queue);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ extern struct event_queue button_queue;
|
||||||
void button_init (void);
|
void button_init (void);
|
||||||
int button_get (bool block);
|
int button_get (bool block);
|
||||||
int button_get_w_tmo(int ticks);
|
int button_get_w_tmo(int ticks);
|
||||||
|
int button_status(void);
|
||||||
|
void button_clear_queue(void);
|
||||||
#ifdef HAVE_RECORDER_KEYPAD
|
#ifdef HAVE_RECORDER_KEYPAD
|
||||||
void button_set_flip(bool flip); /* turn 180 degrees */
|
void button_set_flip(bool flip); /* turn 180 degrees */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,14 @@
|
||||||
|
|
||||||
struct event_queue button_queue;
|
struct event_queue button_queue;
|
||||||
|
|
||||||
|
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
||||||
|
|
||||||
void button_event(int key, bool pressed)
|
void button_event(int key, bool pressed)
|
||||||
{
|
{
|
||||||
bool post = false;
|
bool post = false;
|
||||||
int new_btn = 0;
|
int new_btn = 0;
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
|
||||||
static int lastbtn;
|
static int lastbtn;
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
static int repeat_count = 0;
|
static int repeat_count = 0;
|
||||||
|
|
@ -180,6 +181,11 @@ void button_event(int key, bool pressed)
|
||||||
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int button_status(void)
|
||||||
|
{
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
void button_init(void)
|
void button_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -203,3 +209,8 @@ int button_get_w_tmo(int ticks)
|
||||||
queue_wait_w_tmo(&button_queue, &ev, ticks);
|
queue_wait_w_tmo(&button_queue, &ev, ticks);
|
||||||
return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
|
return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void button_clear_queue(void)
|
||||||
|
{
|
||||||
|
queue_empty(&button_queue);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,6 @@ void button_init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int button_set_repeat(int newmask)
|
|
||||||
{
|
|
||||||
int oldmask = repeat_mask;
|
|
||||||
repeat_mask = newmask;
|
|
||||||
return oldmask;
|
|
||||||
}
|
|
||||||
|
|
||||||
int button_set_release(int newmask)
|
|
||||||
{
|
|
||||||
int oldmask = release_mask;
|
|
||||||
release_mask = newmask;
|
|
||||||
return oldmask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate X keys to Recorder keys
|
* Translate X keys to Recorder keys
|
||||||
*
|
*
|
||||||
|
|
@ -214,3 +200,12 @@ int button_get(bool block)
|
||||||
|
|
||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int button_status(void)
|
||||||
|
{
|
||||||
|
return get_raw_button();
|
||||||
|
}
|
||||||
|
|
||||||
|
void button_clear_queue(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue