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.pull/1700/merge
parent
bccf263cd0
commit
c70b419ec0
@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jj40.h"
|
||||
#include "action_layer.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
#define _QWERTY 0
|
||||
#define _LOWER 1
|
||||
#define _RAISE 2
|
||||
|
||||
enum custom_keycodes {
|
||||
QWERTY = SAFE_RANGE,
|
||||
LOWER,
|
||||
RAISE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Esc | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Tab | A | S | D | F | G | H | J | K | L | ; |Enter |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | ` | Z | X | C | V | B | N | M | , | . | / | ' |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Ctrl | OS | Alt |Lower |Shift |Raise | Space | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = KEYMAP( \
|
||||
KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, \
|
||||
KC_GRV, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, \
|
||||
KC_LCTL, KC_LGUI, KC_LALT, MO(_LOWER), KC_LSFT, MO(_RAISE), KC_SPC, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | | | | | Left | Down | Up |Right | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | Back | Fwd | | | | | | Mute | Vol- | Vol+ | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Prev | Stop | Play | Next |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = KEYMAP( \
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
|
||||
KC_DEL, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, \
|
||||
_______, KC_WBAK, KC_WFWD, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MSTP, KC_MPLY, KC_MNXT \
|
||||
),
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Esc | & | * | _ | ( | ) | 7 | 8 | 9 | = | Bksp | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Ins | $ | % | ^ | [ | ] | 4 | 5 | 6 | - | + | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | ` | ! | @ | # | { | } | 1 | 2 | 3 | . | \ | ' |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Ctrl | OS | Alt | |Shift | | 0 | Home | PgDn | PgUp | End |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP( \
|
||||
_______, KC_AMPR, KC_ASTR, KC_UNDS, KC_LPRN, KC_RPRN, KC_7, KC_8, KC_9, KC_EQL, KC_BSPC, KC_DEL, \
|
||||
KC_INS, KC_DLR, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_4, KC_5, KC_6, KC_MINS, KC_PLUS, KC_PIPE, \
|
||||
_______, KC_EXLM, KC_AT, KC_HASH, KC_LCBR, KC_RCBR, KC_1, KC_2, KC_3, _______, KC_BSLS, _______, \
|
||||
_______, _______, _______, _______, _______, _______, KC_0, KC_HOME, KC_PGDN, KC_PGUP, KC_END \
|
||||
)
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
# JJ40 Tools
|
||||
|
||||
## usb_detach.c
|
||||
|
||||
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.
|
||||
This program can force Linux to give up a device, so that the programming script can reset it.
|
||||
|
||||
### To compile:
|
||||
```
|
||||
gcc usb_detach.c -o usb_detach
|
||||
```
|
||||
|
||||
### To run:
|
||||
1. Use `lsusb` to discover the Bus and Device numbers for your keyboard.
|
||||
2. Run the program: `sudo ./usb_detach /dev/bus/usb/<BUS>/<DEVICE>`.
|
||||
3. Build and program the firmware as normal.
|
@ -0,0 +1,33 @@
|
||||
/* Found at https://www.linuxquestions.org/questions/linux-hardware-18/how-to-unclaim-usb-device-558138/#post3406986 */
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux/usbdevice_fs.h>
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
struct usbdevfs_ioctl command;
|
||||
int ret;
|
||||
int fd;
|
||||
int i;
|
||||
if (argc>1) {
|
||||
fd = open(argv[1],O_RDWR);
|
||||
if (fd<1){
|
||||
perror("unable to open file");
|
||||
return 1;
|
||||
}
|
||||
for (i=0;i<255;i++){ // hack: should fetch how many interface there is.
|
||||
command.ifno = i;
|
||||
command.ioctl_code = USBDEVFS_DISCONNECT;
|
||||
command.data = NULL;
|
||||
ret = ioctl(fd, USBDEVFS_IOCTL, &command);
|
||||
if(ret!=-1)
|
||||
printf("un claimed interface %d %d\n",i,ret);
|
||||
}
|
||||
} else {
|
||||
printf ("usage: %s /dev/bus/usb/BUS/DEVICE\n",argv[0]);
|
||||
printf("Release all interfaces of this usb device for usage in virtualisation\n");
|
||||
}
|
||||
}
|
Loading…
Reference in new issue