aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Garrelou <simon.garrelou@gmail.com>2021-01-09 23:44:48 +0100
committerSimon Garrelou <simon.garrelou@gmail.com>2021-01-09 23:44:48 +0100
commit10085b9b36408b66926ede15052fcc98efb3b751 (patch)
tree0d6825c0097c515612094f1263b23a521cb0cb18
parent9e9dc27233e46c691a36f979450a04b6dd769fd6 (diff)
downloadkindle-doom-10085b9b36408b66926ede15052fcc98efb3b751.tar.gz
kindle-doom-10085b9b36408b66926ede15052fcc98efb3b751.zip
Fix keys input: the game is now theoretically finishablev0.2
-rw-r--r--README.md7
-rw-r--r--src/KINDLE/i_video.c14
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
16The controls are as follows: 16The controls are as follows:
17- Keypad to move 17- Keypad to move
18- "OK" button to shoot 18- "OK" button to shoot
19- "Menu" to open doors / activate switches
20- "Back" to toggle the menu (mapped to Escape)
21- "Keyboard" to select an entry in the menu (mapped to Enter)
19- "Home" button to quit 22- "Home" button to quit
20 23
21There's no "Use" key, because I haven't totally figured out how the other buttons work yet.
22
23## Compilation 24## Compilation
24 25
25If 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. 26If 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
37 38
38The 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. 39The 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.
39 40
40Resolution is hardcoded to 600x800 and cannot be changed. 41Resolution is hardcoded to 800x600 widescreen and cannot be changed.
41 42
42I removed all the autoconf stuff and wrote a Makefile by hand. 43I removed all the autoconf stuff and wrote a Makefile by hand.
43 44
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() {
133 } 133 }
134} 134}
135 135
136#define KINDLE_READ_AGAIN 4
137
136static int kindle_poll_keys(kindle_key_t *k) { 138static int kindle_poll_keys(kindle_key_t *k) {
137 int retval = read(kindleKeysFd, k, sizeof(kindle_key_t)); 139 int retval = read(kindleKeysFd, k, sizeof(kindle_key_t));
138 if (retval == -1) { 140 if (retval == -1) {
@@ -152,6 +154,10 @@ static int kindle_poll_keys(kindle_key_t *k) {
152 perror("read()"); 154 perror("read()");
153 exit(1); 155 exit(1);
154 } 156 }
157 } else if (k->keyCode == KINDLE_READ_AGAIN) {
158 printf("Read again\n");
159 read(kindleKeysFd2, k, sizeof(kindle_key_t));
160 return 1;
155 } else if (retval > 0) { 161 } else if (retval > 0) {
156 return 1; 162 return 1;
157 } 163 }
@@ -179,10 +185,11 @@ static boolean mouse_currently_grabbed;
179#define KINDLE_RIGHT 106 185#define KINDLE_RIGHT 106
180#define KINDLE_UP 103 186#define KINDLE_UP 103
181#define KINDLE_DOWN 108 187#define KINDLE_DOWN 108
182#define KINDE_OK 194 188#define KINDLE_OK 194
183#define KINDLE_HOME 102 189#define KINDLE_HOME 102
184#define KINDLE_MENU 139 190#define KINDLE_MENU 139
185#define KINDLE_BACK 158 191#define KINDLE_BACK 158
192#define KINDLE_KEYBOARD 29
186 193
187static int I_TranslateKey(unsigned short code) 194static int I_TranslateKey(unsigned short code)
188{ 195{
@@ -193,7 +200,10 @@ static int I_TranslateKey(unsigned short code)
193 case KINDLE_RIGHT: rc = KEYD_UPARROW; break; 200 case KINDLE_RIGHT: rc = KEYD_UPARROW; break;
194 case KINDLE_UP: rc = KEYD_LEFTARROW; break; 201 case KINDLE_UP: rc = KEYD_LEFTARROW; break;
195 case KINDLE_DOWN: rc = KEYD_RIGHTARROW; break; 202 case KINDLE_DOWN: rc = KEYD_RIGHTARROW; break;
196 case KINDE_OK: rc = KEYD_RCTRL; break; 203 case KINDLE_OK: rc = KEYD_RCTRL; break;
204 case KINDLE_BACK: rc = KEYD_ESCAPE; break;
205 case KINDLE_MENU: rc = KEYD_ENTER; break;
206 case KINDLE_KEYBOARD: rc = KEYD_SPACEBAR; break;
197 default: break; 207 default: break;
198 } 208 }
199 209