aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-23 20:42:54 +0200
committerBad Diode <bd@badd10de.dev>2021-05-23 20:42:54 +0200
commit596ef772d75b6ec50f196c1f9288d3dc5391b8d6 (patch)
tree473e1223a46086a1b99e3f77b42158da4d410d1f
parent8d601a590bd0f920423ca217d6f1473952edd4eb (diff)
downloaduxngba-596ef772d75b6ec50f196c1f9288d3dc5391b8d6.tar.gz
uxngba-596ef772d75b6ec50f196c1f9288d3dc5391b8d6.zip
Fix control keys on keyboard mode
-rw-r--r--src/filesystem.c4
-rw-r--r--src/main.c31
-rw-r--r--src/uxn/devices/ppu.c4
3 files changed, 34 insertions, 5 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 69e23f7..5732e40 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -3,11 +3,11 @@
3// Note that the filename should include the null terminator if we want to use 3// Note that the filename should include the null terminator if we want to use
4// strcmp. 4// strcmp.
5#define FILE_NAME_SIZE 27 5#define FILE_NAME_SIZE 27
6#define FILE_CAPACITY 63 6#define FILE_CAPACITY 4
7#define FILE_HEADER_OFFSET 2 7#define FILE_HEADER_OFFSET 2
8#define FILE_INDEX_OFFSET 32 8#define FILE_INDEX_OFFSET 32
9#define FILE_DATA_OFFSET KB(2) 9#define FILE_DATA_OFFSET KB(2)
10#define FILE_MAX_SIZE KB(1) 10#define FILE_MAX_SIZE KB(16)
11#define SRAM ((vu8*)(MEM_CART)) 11#define SRAM ((vu8*)(MEM_CART))
12 12
13typedef struct File { 13typedef struct File {
diff --git a/src/main.c b/src/main.c
index 17e0127..b075f4a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,7 +288,36 @@ handle_input(Uxn *u) {
288 update_cursor(cursor_position + KEYBOARD_ROW_SIZE); 288 update_cursor(cursor_position + KEYBOARD_ROW_SIZE);
289 } 289 }
290 if (key_tap(KEY_B)) { 290 if (key_tap(KEY_B)) {
291 devctrl->dat[3] = keyboard[cursor_position].symbol; 291 u8 symbol = keyboard[cursor_position].symbol;
292 switch (symbol) {
293 case 0x7f: {
294 // Backspace.
295 devctrl->dat[3] = 0x08;
296 } break;
297 case 0x14: {
298 // New line.
299 devctrl->dat[3] = 0x0d;
300 } break;
301 case 0x18: {
302 // Arrow up.
303 devctrl->dat[2] = 0x10;
304 } break;
305 case 0x19: {
306 // Arrow down.
307 devctrl->dat[2] = 0x20;
308 } break;
309 case 0x1b: {
310 // Arrow left.
311 devctrl->dat[2] = 0x40;
312 } break;
313 case 0x1a: {
314 // Arrow right.
315 devctrl->dat[2] = 0x80;
316 } break;
317 default: {
318 devctrl->dat[3] = symbol;
319 } break;
320 }
292 evaluxn(u, mempeek16(devctrl->dat, 0)); 321 evaluxn(u, mempeek16(devctrl->dat, 0));
293 devctrl->dat[3] = 0; 322 devctrl->dat[3] = 0;
294 } 323 }
diff --git a/src/uxn/devices/ppu.c b/src/uxn/devices/ppu.c
index 4a5a13d..e453726 100644
--- a/src/uxn/devices/ppu.c
+++ b/src/uxn/devices/ppu.c
@@ -316,8 +316,8 @@ KeyboardChar keyboard[] = {
316 {0, 0, '('}, {0, 0, ')'}, {0, 0, '['}, {0, 0, ']'}, {0, 0, '{'}, {0, 0, '}'}, {0, 0, '<'}, {0, 0, '>'}, {0, 0, '+'}, {0, 0, '-'}, {0, 0, '='}, {0, 0, 0x14}, 316 {0, 0, '('}, {0, 0, ')'}, {0, 0, '['}, {0, 0, ']'}, {0, 0, '{'}, {0, 0, '}'}, {0, 0, '<'}, {0, 0, '>'}, {0, 0, '+'}, {0, 0, '-'}, {0, 0, '='}, {0, 0, 0x14},
317 {0, 0, '0'}, {0, 0, '1'}, {0, 0, '2'}, {0, 0, '3'}, {0, 0, '4'}, {0, 0, '5'}, {0, 0, '6'}, {0, 0, '7'}, {0, 0, '8'}, {0, 0, '9'}, {0, 0, '~'}, {0, 0, 0x18}, 317 {0, 0, '0'}, {0, 0, '1'}, {0, 0, '2'}, {0, 0, '3'}, {0, 0, '4'}, {0, 0, '5'}, {0, 0, '6'}, {0, 0, '7'}, {0, 0, '8'}, {0, 0, '9'}, {0, 0, '~'}, {0, 0, 0x18},
318 {0, 0, 'a'}, {0, 0, 'b'}, {0, 0, 'c'}, {0, 0, 'd'}, {0, 0, 'e'}, {0, 0, 'f'}, {0, 0, 'g'}, {0, 0, 'h'}, {0, 0, 'i'}, {0, 0, 'j'}, {0, 0, '/'}, {0, 0, 0x19}, 318 {0, 0, 'a'}, {0, 0, 'b'}, {0, 0, 'c'}, {0, 0, 'd'}, {0, 0, 'e'}, {0, 0, 'f'}, {0, 0, 'g'}, {0, 0, 'h'}, {0, 0, 'i'}, {0, 0, 'j'}, {0, 0, '/'}, {0, 0, 0x19},
319 {0, 0, 'k'}, {0, 0, 'l'}, {0, 0, 'm'}, {0, 0, 'n'}, {0, 0, 'o'}, {0, 0, 'p'}, {0, 0, 'q'}, {0, 0, 'r'}, {0, 0, 's'}, {0, 0, 't'}, {0, 0, '\\'}, {0, 0, 0x1a}, 319 {0, 0, 'k'}, {0, 0, 'l'}, {0, 0, 'm'}, {0, 0, 'n'}, {0, 0, 'o'}, {0, 0, 'p'}, {0, 0, 'q'}, {0, 0, 'r'}, {0, 0, 's'}, {0, 0, 't'}, {0, 0, '\\'}, {0, 0, 0x1b},
320 {0, 0, 'u'}, {0, 0, 'v'}, {0, 0, 'w'}, {0, 0, 'x'}, {0, 0, 'y'}, {0, 0, 'z'}, {0, 0, ','}, {0, 0, '.'}, {0, 0, ';'}, {0, 0, ':'}, {0, 0, '_'}, {0, 0, 0x1b}, 320 {0, 0, 'u'}, {0, 0, 'v'}, {0, 0, 'w'}, {0, 0, 'x'}, {0, 0, 'y'}, {0, 0, 'z'}, {0, 0, ','}, {0, 0, '.'}, {0, 0, ';'}, {0, 0, ':'}, {0, 0, '_'}, {0, 0, 0x1a},
321}; 321};
322 322
323void 323void