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