diff options
| author | Oscillope <jvrosenman@gmail.com> | 2017-10-14 01:04:36 -0400 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2017-10-13 19:04:36 -1000 |
| commit | c70b419ec06b22dba869f40c32e23563ee0f620f (patch) | |
| tree | 6e7db95be8015128dde5669e3568db8074dc5a87 | |
| parent | bccf263cd06a8f854caa79ae511e5c40442de491 (diff) | |
| download | qmk_firmware-c70b419ec06b22dba869f40c32e23563ee0f620f.tar.gz qmk_firmware-c70b419ec06b22dba869f40c32e23563ee0f620f.zip | |
Add multiple layout support and Linux flash utility to JJ40 (#1837)
* Adds support for multiple layouts. Adds custom keymap for "offset"
layout.
* Adds a tool to help detach the keyboard from the Linux HID driver before programming.
* Adds a tool to help detach the keyboard from the Linux HID driver before programming.
| -rw-r--r-- | keyboards/jj40/README.md | 3 | ||||
| -rw-r--r-- | keyboards/jj40/jj40.h | 32 | ||||
| -rw-r--r-- | keyboards/jj40/keymaps/oscillope/keymap.c | 86 | ||||
| -rw-r--r-- | keyboards/jj40/tools/README.md | 16 | ||||
| -rw-r--r-- | keyboards/jj40/tools/usb_detach.c | 33 |
5 files changed, 169 insertions, 1 deletions
diff --git a/keyboards/jj40/README.md b/keyboards/jj40/README.md index 6b48c1515..03b7533de 100644 --- a/keyboards/jj40/README.md +++ b/keyboards/jj40/README.md | |||
| @@ -48,3 +48,6 @@ $ bootloadHID -r jj40_default.hex | |||
| 48 | done, just reflash the board with the original firmware. | 48 | done, just reflash the board with the original firmware. |
| 49 | 2. Sometimes USB hubs can act weird, so try connecting the board directly | 49 | 2. Sometimes USB hubs can act weird, so try connecting the board directly |
| 50 | to your computer or plugging/unplugging the USB hub. | 50 | to your computer or plugging/unplugging the USB hub. |
| 51 | 3. If you get an error such as "Resource Unavailable" when attemting to flash | ||
| 52 | on Linux, you may want to compile and run `tools/usb_detach.c`. See `tools/README.md` | ||
| 53 | for more info. | ||
diff --git a/keyboards/jj40/jj40.h b/keyboards/jj40/jj40.h index 6c9cc1947..b1a7a6238 100644 --- a/keyboards/jj40/jj40.h +++ b/keyboards/jj40/jj40.h | |||
| @@ -22,7 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | #include "keycode.h" | 22 | #include "keycode.h" |
| 23 | #include "action.h" | 23 | #include "action.h" |
| 24 | 24 | ||
| 25 | #define KEYMAP( \ | 25 | #define KEYMAP_GRID( \ |
| 26 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K010, K011, K012, \ | ||
| 27 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K110, K111, K112, \ | ||
| 28 | K21, K22, K23, K24, K25, K26, K27, K28, K29, K210, K211, K212, \ | ||
| 29 | K31, K32, K33, K34, K35, K36, K37, K38, K39, K310, K311, K312 \ | ||
| 30 | ) \ | ||
| 31 | { \ | ||
| 32 | { K012, K011, K010, K09, K05, K06, K07, K08, K04, K03, K02, K01 }, \ | ||
| 33 | { K112, K111, K110, K19, K15, K16, K17, K18, K14, K13, K12, K11 }, \ | ||
| 34 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ | ||
| 35 | { K212, K211, K210, K29, K25, K26, K27, K28, K24, K23, K22, K21 }, \ | ||
| 36 | { K312, K311, K310, K39, K35, K36, K37, K38, K34, K33, K32, K31 } \ | ||
| 37 | } | ||
| 38 | |||
| 39 | #define KEYMAP_MIT( \ | ||
| 26 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K010, K011, K012, \ | 40 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K010, K011, K012, \ |
| 27 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K110, K111, K112, \ | 41 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K110, K111, K112, \ |
| 28 | K21, K22, K23, K24, K25, K26, K27, K28, K29, K210, K211, K212, \ | 42 | K21, K22, K23, K24, K25, K26, K27, K28, K29, K210, K211, K212, \ |
| @@ -36,4 +50,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 36 | { K312, K311, K310, K39, K35, K3X, KC_NO, K38, K34, K33, K32, K31 } \ | 50 | { K312, K311, K310, K39, K35, K3X, KC_NO, K38, K34, K33, K32, K31 } \ |
| 37 | } | 51 | } |
| 38 | 52 | ||
| 53 | #define KEYMAP_OFFSET( \ | ||
| 54 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K010, K011, K012, \ | ||
| 55 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K110, K111, K112, \ | ||
| 56 | K21, K22, K23, K24, K25, K26, K27, K28, K29, K210, K211, K212, \ | ||
| 57 | K31, K32, K33, K34, K35, K36, K3X, K39, K310, K311, K312 \ | ||
| 58 | ) \ | ||
| 59 | { \ | ||
| 60 | { K012, K011, K010, K09, K05, K06, K07, K08, K04, K03, K02, K01 }, \ | ||
| 61 | { K112, K111, K110, K19, K15, K16, K17, K18, K14, K13, K12, K11 }, \ | ||
| 62 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ | ||
| 63 | { K212, K211, K210, K29, K25, K26, K27, K28, K24, K23, K22, K21 }, \ | ||
| 64 | { K312, K311, K310, K39, K35, K36, K3X, KC_NO, K34, K33, K32, K31 } \ | ||
| 65 | } | ||
| 66 | |||
| 67 | #define KEYMAP KEYMAP_OFFSET | ||
| 68 | |||
| 39 | #endif | 69 | #endif |
diff --git a/keyboards/jj40/keymaps/oscillope/keymap.c b/keyboards/jj40/keymaps/oscillope/keymap.c new file mode 100644 index 000000000..2badb094a --- /dev/null +++ b/keyboards/jj40/keymaps/oscillope/keymap.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "jj40.h" | ||
| 19 | #include "action_layer.h" | ||
| 20 | #include "rgblight.h" | ||
| 21 | |||
| 22 | #define _QWERTY 0 | ||
| 23 | #define _LOWER 1 | ||
| 24 | #define _RAISE 2 | ||
| 25 | |||
| 26 | enum custom_keycodes { | ||
| 27 | QWERTY = SAFE_RANGE, | ||
| 28 | LOWER, | ||
| 29 | RAISE, | ||
| 30 | }; | ||
| 31 | |||
| 32 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 33 | /* Qwerty | ||
| 34 | * ,-----------------------------------------------------------------------------------. | ||
| 35 | * | Esc | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
| 36 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 37 | * | Tab | A | S | D | F | G | H | J | K | L | ; |Enter | | ||
| 38 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 39 | * | ` | Z | X | C | V | B | N | M | , | . | / | ' | | ||
| 40 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 41 | * | Ctrl | OS | Alt |Lower |Shift |Raise | Space | Left | Down | Up |Right | | ||
| 42 | * `-----------------------------------------------------------------------------------' | ||
| 43 | */ | ||
| 44 | [_QWERTY] = KEYMAP( \ | ||
| 45 | KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
| 46 | KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, \ | ||
| 47 | KC_GRV, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, \ | ||
| 48 | KC_LCTL, KC_LGUI, KC_LALT, MO(_LOWER), KC_LSFT, MO(_RAISE), KC_SPC, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 49 | ), | ||
| 50 | |||
| 51 | /* Lower | ||
| 52 | * ,-----------------------------------------------------------------------------------. | ||
| 53 | * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | ||
| 54 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 55 | * | | | | | | | Left | Down | Up |Right | | | | ||
| 56 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 57 | * | | Back | Fwd | | | | | | Mute | Vol- | Vol+ | | | ||
| 58 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 59 | * | | | | | | | | Prev | Stop | Play | Next | | ||
| 60 | * `-----------------------------------------------------------------------------------' | ||
| 61 | */ | ||
| 62 | [_LOWER] = KEYMAP( \ | ||
| 63 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
| 64 | KC_DEL, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, \ | ||
| 65 | _______, KC_WBAK, KC_WFWD, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, \ | ||
| 66 | _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MSTP, KC_MPLY, KC_MNXT \ | ||
| 67 | ), | ||
| 68 | |||
| 69 | /* Raise | ||
| 70 | * ,-----------------------------------------------------------------------------------. | ||
| 71 | * | Esc | & | * | _ | ( | ) | 7 | 8 | 9 | = | Bksp | Del | | ||
| 72 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
| 73 | * | Ins | $ | % | ^ | [ | ] | 4 | 5 | 6 | - | + | | | | ||
| 74 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
| 75 | * | ` | ! | @ | # | { | } | 1 | 2 | 3 | . | \ | ' | | ||
| 76 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 77 | * | Ctrl | OS | Alt | |Shift | | 0 | Home | PgDn | PgUp | End | | ||
| 78 | * `-----------------------------------------------------------------------------------' | ||
| 79 | */ | ||
| 80 | [_RAISE] = KEYMAP( \ | ||
| 81 | _______, KC_AMPR, KC_ASTR, KC_UNDS, KC_LPRN, KC_RPRN, KC_7, KC_8, KC_9, KC_EQL, KC_BSPC, KC_DEL, \ | ||
| 82 | KC_INS, KC_DLR, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_4, KC_5, KC_6, KC_MINS, KC_PLUS, KC_PIPE, \ | ||
| 83 | _______, KC_EXLM, KC_AT, KC_HASH, KC_LCBR, KC_RCBR, KC_1, KC_2, KC_3, _______, KC_BSLS, _______, \ | ||
| 84 | _______, _______, _______, _______, _______, _______, KC_0, KC_HOME, KC_PGDN, KC_PGUP, KC_END \ | ||
| 85 | ) | ||
| 86 | }; | ||
diff --git a/keyboards/jj40/tools/README.md b/keyboards/jj40/tools/README.md new file mode 100644 index 000000000..081984ed4 --- /dev/null +++ b/keyboards/jj40/tools/README.md | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | # JJ40 Tools | ||
| 2 | |||
| 3 | ## usb_detach.c | ||
| 4 | |||
| 5 | When trying to flash on Linux, you may encounter a "Resource Unavailable" error. This means that Linux's HID driver has taken exclusive control of the keyboard, and the program script can't flash it. | ||
| 6 | This program can force Linux to give up a device, so that the programming script can reset it. | ||
| 7 | |||
| 8 | ### To compile: | ||
| 9 | ``` | ||
| 10 | gcc usb_detach.c -o usb_detach | ||
| 11 | ``` | ||
| 12 | |||
| 13 | ### To run: | ||
| 14 | 1. Use `lsusb` to discover the Bus and Device numbers for your keyboard. | ||
| 15 | 2. Run the program: `sudo ./usb_detach /dev/bus/usb/<BUS>/<DEVICE>`. | ||
| 16 | 3. Build and program the firmware as normal. | ||
diff --git a/keyboards/jj40/tools/usb_detach.c b/keyboards/jj40/tools/usb_detach.c new file mode 100644 index 000000000..c21e47a7a --- /dev/null +++ b/keyboards/jj40/tools/usb_detach.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* Found at https://www.linuxquestions.org/questions/linux-hardware-18/how-to-unclaim-usb-device-558138/#post3406986 */ | ||
| 2 | #include <stdio.h> | ||
| 3 | #include <sys/types.h> | ||
| 4 | #include <sys/stat.h> | ||
| 5 | #include <fcntl.h> | ||
| 6 | #include <linux/ioctl.h> | ||
| 7 | #include <linux/usbdevice_fs.h> | ||
| 8 | |||
| 9 | int main(int argc, char**argv) | ||
| 10 | { | ||
| 11 | struct usbdevfs_ioctl command; | ||
| 12 | int ret; | ||
| 13 | int fd; | ||
| 14 | int i; | ||
| 15 | if (argc>1) { | ||
| 16 | fd = open(argv[1],O_RDWR); | ||
| 17 | if (fd<1){ | ||
| 18 | perror("unable to open file"); | ||
| 19 | return 1; | ||
| 20 | } | ||
| 21 | for (i=0;i<255;i++){ // hack: should fetch how many interface there is. | ||
| 22 | command.ifno = i; | ||
| 23 | command.ioctl_code = USBDEVFS_DISCONNECT; | ||
| 24 | command.data = NULL; | ||
| 25 | ret = ioctl(fd, USBDEVFS_IOCTL, &command); | ||
| 26 | if(ret!=-1) | ||
| 27 | printf("un claimed interface %d %d\n",i,ret); | ||
| 28 | } | ||
| 29 | } else { | ||
| 30 | printf ("usage: %s /dev/bus/usb/BUS/DEVICE\n",argv[0]); | ||
| 31 | printf("Release all interfaces of this usb device for usage in virtualisation\n"); | ||
| 32 | } | ||
| 33 | } \ No newline at end of file | ||
