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 "keypad-common.h" 24 #include <l4/re/event_enums.h> 25 26 enum Jz4730_keypad_gpio 27 { 28 Jz4730_keypad_gpio_inputs_count = 8, 29 Jz4730_keypad_gpio_outputs_count = 17, 30 }; 31 32 class Keypad_letux400 : public Keypad 33 { 34 /* Keycode definitions. */ 35 36 const int keycodes[Jz4730_keypad_gpio_inputs_count][Jz4730_keypad_gpio_outputs_count] = { 37 38 {L4RE_KEY_PAUSE, L4RE_KEY_Q, L4RE_KEY_W, L4RE_KEY_E, L4RE_KEY_R, L4RE_KEY_U, 39 L4RE_KEY_I, L4RE_KEY_O, 0, 0, 0, L4RE_KEY_P, 0, 0, 0, 0}, 40 41 {0, L4RE_KEY_TAB, L4RE_KEY_CAPSLOCK, L4RE_KEY_F3, L4RE_KEY_T, L4RE_KEY_Y, 42 L4RE_KEY_RIGHTBRACE, L4RE_KEY_F7, 0, L4RE_KEY_BACKSPACE, 0, 43 L4RE_KEY_LEFTBRACE, L4RE_KEY_SLEEP, 0, 0, 0, L4RE_KEY_LEFTSHIFT}, 44 45 {0, L4RE_KEY_A, L4RE_KEY_S, L4RE_KEY_D, L4RE_KEY_F, L4RE_KEY_J, L4RE_KEY_K, 46 L4RE_KEY_L, 0, 0, 0, L4RE_KEY_SEMICOLON, 0, 0, 0, L4RE_KEY_UP, 47 L4RE_KEY_RIGHTSHIFT}, 48 49 {0, L4RE_KEY_ESC, L4RE_KEY_BACKSLASH /* left */, L4RE_KEY_F4, L4RE_KEY_G, 50 L4RE_KEY_H, L4RE_KEY_F6, 0, L4RE_KEY_SPACE, 0, L4RE_KEY_LEFTALT, 51 L4RE_KEY_APOSTROPHE, 0, 0, 0, L4RE_KEY_DOWN, 0}, 52 53 {0, L4RE_KEY_Z, L4RE_KEY_X, L4RE_KEY_C, L4RE_KEY_V, L4RE_KEY_M, 54 L4RE_KEY_COMMA, L4RE_KEY_DOT, L4RE_KEY_NUMLOCK, L4RE_KEY_ENTER, 0, 55 L4RE_KEY_BACKSLASH /* right */, 0, 0, 0, L4RE_KEY_LEFT, 0}, 56 57 {0, 0, 0, 0, L4RE_KEY_B, L4RE_KEY_N, 0, L4RE_KEY_MENU, 58 0, 0, 0, L4RE_KEY_SLASH, 0, 0, 0, L4RE_KEY_RIGHT, 0}, 59 60 {L4RE_KEY_LEFTCTRL, L4RE_KEY_GRAVE, 0, 0, L4RE_KEY_5, L4RE_KEY_6, 61 L4RE_KEY_EQUAL, L4RE_KEY_F8, L4RE_KEY_DELETE, L4RE_KEY_F9, 0, 62 L4RE_KEY_MINUS, 0, L4RE_KEY_F2, L4RE_KEY_INSERT, 0, L4RE_KEY_F1}, 63 64 {L4RE_KEY_F5, L4RE_KEY_1, L4RE_KEY_2, L4RE_KEY_3, L4RE_KEY_4, L4RE_KEY_7, 65 L4RE_KEY_8, L4RE_KEY_9, 0, 0, L4RE_KEY_SYSRQ, L4RE_KEY_0, L4RE_KEY_F10, 0, 66 0, 0, L4RE_KEY_FN} 67 }; 68 69 public: 70 71 /* Number of keypad columns. */ 72 73 int columns() 74 { 75 return Jz4730_keypad_gpio_outputs_count; 76 } 77 78 /* Number of keypad rows, used by each value in the column array. */ 79 80 int rows() 81 { 82 return Jz4730_keypad_gpio_inputs_count; 83 } 84 85 /* Keycode accessors. */ 86 87 int code(int column, int row) 88 { 89 return keycodes[row][column]; 90 } 91 92 /* Common instance. */ 93 94 static Keypad_letux400 keypad; 95 }; 96 97 /* The actual definition. */ 98 99 Keypad_letux400 Keypad_letux400::keypad; 100 101 /* Definition access. */ 102 103 Keypad *Keypad::get_keypad() 104 { 105 return &Keypad_letux400::keypad; 106 }