From 3cf9f3ebcb5a3a825c14312ef42376cef8649bc9 Mon Sep 17 00:00:00 2001 From: Felix Raimundo Date: Mon, 21 Mar 2016 12:10:19 +0100 Subject: [PATCH] Small hack to get keys on the simulator. NOTE: this is really hacky and should be improved as soon as possible, but working zithout it is just to big a pain. Change-Id: I01e322fa5f653f04e9fdf6b16b4b9fe023a4fe93 --- ion/src/shared/keyboard.c | 2 +- ion/src/simulator/keyboard/fltkkbd.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ion/src/shared/keyboard.c b/ion/src/shared/keyboard.c index ebecb25cf..23490fd36 100644 --- a/ion/src/shared/keyboard.c +++ b/ion/src/shared/keyboard.c @@ -1,7 +1,7 @@ #include #include -char charForKey[ION_NUMBER_OF_KEYS] = { +static const char charForKey[ION_NUMBER_OF_KEYS] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', diff --git a/ion/src/simulator/keyboard/fltkkbd.cpp b/ion/src/simulator/keyboard/fltkkbd.cpp index a9cf4d81e..d8eb2969f 100644 --- a/ion/src/simulator/keyboard/fltkkbd.cpp +++ b/ion/src/simulator/keyboard/fltkkbd.cpp @@ -4,12 +4,28 @@ #define KEYBOARD_ROWS 7 #define KEYBOARD_COLUMNS 5 +// TODO(raimundo): do this in a clean way with no duplication. +// A bit ugly but we need a null terminated string from a single char. +static const char* charForKey[KEYBOARD_ROWS * KEYBOARD_COLUMNS] = { + "A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", + "K", "L", "M", "N", "O", + "7", "8", "9", "(", ")", + "4", "5", "6", "*", "/", + "1", "2", "3", "+", "-", + "0", ".", "x", "7", "X" +}; + FltkKbd::FltkKbd(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { assert(KEYBOARD_ROWS*KEYBOARD_COLUMNS == ION_NUMBER_OF_KEYS); int key_width = w/KEYBOARD_COLUMNS; int key_height = h/KEYBOARD_ROWS; for (int k=0; k