1 /* 2 * Letux 400 key mapping. 3 * 4 * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "keypad.h" 23 #include <l4/re/event_enums.h> 24 25 enum Jz4730_keypad_gpio 26 { 27 Jz4730_keypad_gpio_inputs_count = 8, 28 Jz4730_keypad_gpio_outputs_count = 17, 29 }; 30 31 class Keypad_letux400 : public Keypad 32 { 33 /* Keycode definitions. */ 34 35 const int keycodes[Jz4730_keypad_gpio_inputs_count][Jz4730_keypad_gpio_outputs_count] = { 36 37 {L4RE_KEY_PAUSE, L4RE_KEY_Q, L4RE_KEY_W, L4RE_KEY_E, L4RE_KEY_R, L4RE_KEY_U, 38 L4RE_KEY_I, L4RE_KEY_O, 0, 0, 0, L4RE_KEY_P, 0, 0, 0, 0}, 39 40 {0, L4RE_KEY_TAB, L4RE_KEY_CAPSLOCK, L4RE_KEY_F3, L4RE_KEY_T, L4RE_KEY_Y, 41 L4RE_KEY_RIGHTBRACE, L4RE_KEY_F7, 0, L4RE_KEY_BACKSPACE, 0, 42 L4RE_KEY_LEFTBRACE, L4RE_KEY_SLEEP, 0, 0, 0, L4RE_KEY_LEFTSHIFT}, 43 44 {0, L4RE_KEY_A, L4RE_KEY_S, L4RE_KEY_D, L4RE_KEY_F, L4RE_KEY_J, L4RE_KEY_K, 45 L4RE_KEY_L, 0, 0, 0, L4RE_KEY_SEMICOLON, 0, 0, 0, L4RE_KEY_UP, 46 L4RE_KEY_RIGHTSHIFT}, 47 48 {0, L4RE_KEY_ESC, L4RE_KEY_BACKSLASH /* left */, L4RE_KEY_F4, L4RE_KEY_G, 49 L4RE_KEY_H, L4RE_KEY_F6, 0, L4RE_KEY_SPACE, 0, L4RE_KEY_LEFTALT, 50 L4RE_KEY_APOSTROPHE, 0, 0, 0, L4RE_KEY_DOWN, 0}, 51 52 {0, L4RE_KEY_Z, L4RE_KEY_X, L4RE_KEY_C, L4RE_KEY_V, L4RE_KEY_M, 53 L4RE_KEY_COMMA, L4RE_KEY_DOT, L4RE_KEY_NUMLOCK, L4RE_KEY_ENTER, 0, 54 L4RE_KEY_BACKSLASH /* right */, 0, 0, 0, L4RE_KEY_LEFT, 0}, 55 56 {0, 0, 0, 0, L4RE_KEY_B, L4RE_KEY_N, 0, L4RE_KEY_MENU, 57 0, 0, 0, L4RE_KEY_SLASH, 0, 0, 0, L4RE_KEY_RIGHT, 0}, 58 59 {L4RE_KEY_LEFTCTRL, L4RE_KEY_GRAVE, 0, 0, L4RE_KEY_5, L4RE_KEY_6, 60 L4RE_KEY_EQUAL, L4RE_KEY_F8, L4RE_KEY_DELETE, L4RE_KEY_F9, 0, 61 L4RE_KEY_MINUS, 0, L4RE_KEY_F2, L4RE_KEY_INSERT, 0, L4RE_KEY_F1}, 62 63 {L4RE_KEY_F5, L4RE_KEY_1, L4RE_KEY_2, L4RE_KEY_3, L4RE_KEY_4, L4RE_KEY_7, 64 L4RE_KEY_8, L4RE_KEY_9, 0, 0, L4RE_KEY_SYSRQ, L4RE_KEY_0, L4RE_KEY_F10, 0, 65 0, 0, L4RE_KEY_FN} 66 }; 67 68 public: 69 70 /* Number of keypad columns. */ 71 72 int columns() 73 { 74 return Jz4730_keypad_gpio_outputs_count; 75 } 76 77 /* Number of keypad rows, used by each value in the column array. */ 78 79 int rows() 80 { 81 return Jz4730_keypad_gpio_inputs_count; 82 } 83 84 /* Keycode accessors. */ 85 86 int code(int column, int row) 87 { 88 return keycodes[row][column]; 89 } 90 91 /* Common instance. */ 92 93 static Keypad_letux400 keypad; 94 }; 95 96 /* The actual definition. */ 97 98 Keypad_letux400 Keypad_letux400::keypad; 99 100 /* Definition access. */ 101 102 Keypad *Keypad::get_keypad() 103 { 104 return &Keypad_letux400::keypad; 105 }