aboutsummaryrefslogtreecommitdiff
path: root/keen.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 /keen.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 'keen.c')
-rw-r--r--keen.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/keen.c b/keen.c
index ec7af12..1e531d9 100644
--- a/keen.c
+++ b/keen.c
@@ -1251,6 +1251,27 @@ static const char *validate_desc(const game_params *params, const char *desc)
return NULL;
}
+static key_label *game_request_keys(const game_params *params, int *nkeys)
+{
+ int i;
+ int w = params->w;
+
+ key_label *keys = snewn(w+1, key_label);
+ *nkeys = w + 1;
+
+ for (i = 0; i < w; i++) {
+ if (i<9) keys[i].button = '1' + i;
+ else keys[i].button = 'a' + i - 9;
+
+ keys[i].label = NULL;
+ }
+ keys[w].button = '\b';
+ keys[w].label = NULL;
+
+
+ return keys;
+}
+
static game_state *new_game(midend *me, const game_params *params,
const char *desc)
{
@@ -2354,6 +2375,7 @@ const struct game thegame = {
free_ui,
encode_ui,
decode_ui,
+ game_request_keys,
game_changed_state,
interpret_move,
execute_move,