From 10085b9b36408b66926ede15052fcc98efb3b751 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Sat, 9 Jan 2021 23:44:48 +0100 Subject: Fix keys input: the game is now theoretically finishable --- README.md | 7 ++++--- src/KINDLE/i_video.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index feb9548..f77fc03 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,11 @@ Prerequisites: copy your `doom.wad` and `prboom.wad` to the root of your Kindle The controls are as follows: - Keypad to move - "OK" button to shoot +- "Menu" to open doors / activate switches +- "Back" to toggle the menu (mapped to Escape) +- "Keyboard" to select an entry in the menu (mapped to Enter) - "Home" button to quit -There's no "Use" key, because I haven't totally figured out how the other buttons work yet. - ## Compilation If you want to build the project for yourself, you will need an `armv7` GCC toolchain. I successfully used Bootlin's [`armv7-eabihf`](https://toolchains.bootlin.com/releases_armv7-eabihf.html) "musl" toolchain. Compiling with the glibc toolchain also works, but the `libc` on the Kindle is too old and it will refuse to start. @@ -37,7 +38,7 @@ Based on [`prboom-2.5.0`](https://sourceforge.net/projects/prboom/files/prboom%2 The main change is the addition of `src/KINDLE/`, which defines most Kindle-specific functions. I basically copied `src/SDL/` and modified everything to remove dependencies on SDL and instead work directly on the Kindle's framebuffer. -Resolution is hardcoded to 600x800 and cannot be changed. +Resolution is hardcoded to 800x600 widescreen and cannot be changed. I removed all the autoconf stuff and wrote a Makefile by hand. diff --git a/src/KINDLE/i_video.c b/src/KINDLE/i_video.c index b379f97..5672b28 100644 --- a/src/KINDLE/i_video.c +++ b/src/KINDLE/i_video.c @@ -133,6 +133,8 @@ static void init_kindle_keys() { } } +#define KINDLE_READ_AGAIN 4 + static int kindle_poll_keys(kindle_key_t *k) { int retval = read(kindleKeysFd, k, sizeof(kindle_key_t)); if (retval == -1) { @@ -152,6 +154,10 @@ static int kindle_poll_keys(kindle_key_t *k) { perror("read()"); exit(1); } + } else if (k->keyCode == KINDLE_READ_AGAIN) { + printf("Read again\n"); + read(kindleKeysFd2, k, sizeof(kindle_key_t)); + return 1; } else if (retval > 0) { return 1; } @@ -179,10 +185,11 @@ static boolean mouse_currently_grabbed; #define KINDLE_RIGHT 106 #define KINDLE_UP 103 #define KINDLE_DOWN 108 -#define KINDE_OK 194 +#define KINDLE_OK 194 #define KINDLE_HOME 102 #define KINDLE_MENU 139 #define KINDLE_BACK 158 +#define KINDLE_KEYBOARD 29 static int I_TranslateKey(unsigned short code) { @@ -193,7 +200,10 @@ static int I_TranslateKey(unsigned short code) case KINDLE_RIGHT: rc = KEYD_UPARROW; break; case KINDLE_UP: rc = KEYD_LEFTARROW; break; case KINDLE_DOWN: rc = KEYD_RIGHTARROW; break; - case KINDE_OK: rc = KEYD_RCTRL; break; + case KINDLE_OK: rc = KEYD_RCTRL; break; + case KINDLE_BACK: rc = KEYD_ESCAPE; break; + case KINDLE_MENU: rc = KEYD_ENTER; break; + case KINDLE_KEYBOARD: rc = KEYD_SPACEBAR; break; default: break; } -- cgit v1.2.3