mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Add a request_keys() function with a midend wrapper.
This function gives the front end a way to find out what keys the back end requires; and as such it is mostly useful for ports without a keyboard. It is based on changes originally found in Chris Boyle's Android port, though some modifications were needed to make it more flexible.
This commit is contained in:

committed by
Simon Tatham

parent
3d04dd3335
commit
60a929a250
21
midend.c
21
midend.c
@ -1104,6 +1104,27 @@ int midend_process_key(midend *me, int x, int y, int button)
|
||||
return ret;
|
||||
}
|
||||
|
||||
key_label *midend_request_keys(midend *me, int *n)
|
||||
{
|
||||
key_label *keys = NULL;
|
||||
int nkeys = 0, i;
|
||||
|
||||
if(me->ourgame->request_keys)
|
||||
{
|
||||
keys = me->ourgame->request_keys(midend_get_params(me), &nkeys);
|
||||
for(i = 0; i < nkeys; ++i)
|
||||
{
|
||||
if(!keys[i].label)
|
||||
keys[i].label = button2label(keys[i].button);
|
||||
}
|
||||
}
|
||||
|
||||
if(n)
|
||||
*n = nkeys;
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
void midend_redraw(midend *me)
|
||||
{
|
||||
assert(me->drawing);
|
||||
|
Reference in New Issue
Block a user