aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-04-17 16:18:16 -0400
committerSimon Tatham <anakin@pobox.com>2018-04-22 17:04:50 +0100
commit60a929a250cf4f7f87ac082e5705f9a838a7f8c8 (patch)
tree33a8a715f6320d2a2d58532b04e33ef111f31507 /midend.c
parent3d04dd3335a2c4c6007ff4e2a58a2855c7a9c52a (diff)
downloadpuzzles-60a929a250cf4f7f87ac082e5705f9a838a7f8c8.zip
puzzles-60a929a250cf4f7f87ac082e5705f9a838a7f8c8.tar.gz
puzzles-60a929a250cf4f7f87ac082e5705f9a838a7f8c8.tar.bz2
puzzles-60a929a250cf4f7f87ac082e5705f9a838a7f8c8.tar.xz
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.
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/midend.c b/midend.c
index 99112fa..1a08ef6 100644
--- a/midend.c
+++ b/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);