1 /* 2 * Ben NanoNote 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 Jz4740_keypad_gpio 27 { 28 Jz4740_keypad_gpio_inputs_count = 8, 29 Jz4740_keypad_gpio_outputs_count = 8, 30 }; 31 32 class Keypad_qi_lb60 : public Keypad 33 { 34 /* Keycode definitions. */ 35 36 const int keycodes[Jz4740_keypad_gpio_inputs_count][Jz4740_keypad_gpio_outputs_count] = { 37 38 {L4RE_KEY_F1, L4RE_KEY_F2, L4RE_KEY_F3, L4RE_KEY_F4, L4RE_KEY_F5, 39 L4RE_KEY_F6, L4RE_KEY_F7, 0}, 40 41 {L4RE_KEY_Q, L4RE_KEY_W, L4RE_KEY_E, L4RE_KEY_R, L4RE_KEY_T, L4RE_KEY_Y, 42 L4RE_KEY_U, L4RE_KEY_I}, 43 44 {L4RE_KEY_A, L4RE_KEY_S, L4RE_KEY_D, L4RE_KEY_F, L4RE_KEY_G, L4RE_KEY_H, 45 L4RE_KEY_J, L4RE_KEY_K}, 46 47 {L4RE_KEY_ESC, L4RE_KEY_Z, L4RE_KEY_X, L4RE_KEY_C, L4RE_KEY_V, L4RE_KEY_B, 48 L4RE_KEY_N, L4RE_KEY_M}, 49 50 {L4RE_KEY_TAB, L4RE_KEY_CAPSLOCK /* D-Sh */, L4RE_KEY_BACKSLASH, 51 L4RE_KEY_APOSTROPHE, L4RE_KEY_COMMA, L4RE_KEY_DOT, L4RE_KEY_SLASH, 52 L4RE_KEY_UP}, 53 54 {L4RE_KEY_O, L4RE_KEY_L, L4RE_KEY_EQUAL, L4RE_KEY_RIGHTALT /* Sym */, 55 L4RE_KEY_SPACE, L4RE_KEY_F13 /* Qi */, L4RE_KEY_RIGHTCTRL, L4RE_KEY_LEFT}, 56 57 {L4RE_KEY_F8, L4RE_KEY_P, L4RE_KEY_BACKSPACE, L4RE_KEY_ENTER, 58 L4RE_KEY_VOLUMEUP, L4RE_KEY_VOLUMEDOWN, L4RE_KEY_DOWN, L4RE_KEY_RIGHT}, 59 60 {L4RE_KEY_LEFTSHIFT, L4RE_KEY_LEFTALT, L4RE_KEY_FN, 0, 0, 0, 0, 0} 61 }; 62 63 public: 64 65 /* Number of keypad columns. */ 66 67 int columns() 68 { 69 return Jz4740_keypad_gpio_outputs_count; 70 } 71 72 /* Number of keypad rows, used by each value in the column array. */ 73 74 int rows() 75 { 76 return Jz4740_keypad_gpio_inputs_count; 77 } 78 79 /* Keycode accessors. */ 80 81 int code(int column, int row) 82 { 83 return keycodes[row][column]; 84 } 85 86 /* Common instance. */ 87 88 static Keypad_qi_lb60 keypad; 89 }; 90 91 /* The actual definition. */ 92 93 Keypad_qi_lb60 Keypad_qi_lb60::keypad; 94 95 /* Definition access. */ 96 97 Keypad *Keypad::get_keypad() 98 { 99 return &Keypad_qi_lb60::keypad; 100 }