+ Keymap in eeprom support + Ledmap support + Ledmap in eeprom support + Mouse support + Composite device support + Macro to modify number of supported keyboards + Reduce binary sizemaster
@@ -41,7 +41,7 @@ | |||
# Target file name (without extension). | |||
TARGET = usb_usb | |||
TMK_DIR = ../../tmk_core | |||
TMK_DIR = ../../tmk_core_custom | |||
# Directory keyboard dependent files exist | |||
TARGET_DIR = . | |||
@@ -91,10 +91,13 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | |||
# comment out to disable the options. | |||
# | |||
MOUSEKEY_ENABLE = yes # Mouse keys | |||
EXTRAKEY_ENABLE = yes # Media control and System control | |||
CONSOLE_ENABLE = yes # Console for debug | |||
#EXTRAKEY_ENABLE = yes # Media control and System control | |||
#CONSOLE_ENABLE = yes # Console for debug | |||
#COMMAND_ENABLE = yes # Commands for debug and configuration | |||
#NKRO_ENABLE = yes # USB Nkey Rollover | |||
KEYMAP_IN_EEPROM_ENABLE = yes # External keymap in eeprom | |||
LEDMAP_ENABLE = yes # Enable LED mapping | |||
LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom | |||
# Boot Section Size in bytes | |||
# Teensy halfKay 512 | |||
@@ -110,6 +113,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
SRC = \ | |||
keymap_common.c \ | |||
ledmap.c \ | |||
usb_usb.cpp \ | |||
main.cpp | |||
@@ -33,7 +33,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
#define MATRIX_ROWS 16 | |||
#define MATRIX_COLS 16 | |||
/* keymap in eeprom */ | |||
#define FN_ACTIONS_COUNT 32 | |||
#define KEYMAPS_COUNT 3 | |||
/* number of leds */ | |||
#define LED_COUNT 3 | |||
#define EECONFIG_LEDMAP_IN_EEPROM 8 | |||
/* key combination for command */ | |||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | |||
/* | |||
* Feature disable options | |||
* These options are also useful to firmware size reduction. | |||
*/ | |||
/* disable debug print */ | |||
//#define NO_DEBUG | |||
/* disable print */ | |||
//#define NO_PRINT | |||
/* disable action features */ | |||
//#define NO_ACTION_LAYER | |||
//#define NO_ACTION_TAPPING | |||
#define NO_ACTION_ONESHOT | |||
#define NO_ACTION_MACRO | |||
//#define NO_ACTION_FUNCTION | |||
#endif |
@@ -21,11 +21,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
/* translates key to keycode */ | |||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) | |||
{ | |||
#ifndef KEYMAP_IN_EEPROM_ENABLE | |||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | |||
#else | |||
return eeconfig_read_keymap_key(layer, key.row, key.col); | |||
#endif | |||
} | |||
/* translates Fn keycode to action */ | |||
action_t keymap_fn_to_action(uint8_t keycode) | |||
{ | |||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; | |||
return (action_t) { | |||
#ifndef KEYMAP_IN_EEPROM_ENABLE | |||
.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) | |||
#else | |||
.code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode)) | |||
#endif | |||
}; | |||
} | |||
#ifdef KEYMAP_IN_EEPROM_ENABLE | |||
const uint8_t* keymaps_pointer(void) { | |||
return (const uint8_t*)keymaps; | |||
} | |||
const uint16_t* fn_actions_pointer(void) { | |||
return fn_actions; | |||
} | |||
#endif |
@@ -0,0 +1,144 @@ | |||
/* | |||
Copyright 2012 Jun Wako <[email protected]> | |||
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 "keymap_common.h" | |||
#include "keymap_in_eeprom.h" | |||
#ifdef KEYMAP_SECTION_ENABLE | |||
const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { | |||
#else | |||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | |||
#endif | |||
#if 0 | |||
/* 0: plain Qwerty without layer switching | |||
* ,---------------. ,---------------. ,---------------. | |||
* |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24| | |||
* ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------. | |||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help | | |||
* `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------' | |||
* ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------. | |||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn| | |||
* |-----------------------------------------------------------| |-----------| |---------------| |-------| | |||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und| | |||
* |-----------------------------------------------------------| `-----------' |---------------| |-------| | |||
* |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy| | |||
* |-----------------------------------------------------------| ,---. |---------------| |-------| | |||
* |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst| | |||
* |-----------------------------------------------------------| ,-----------. |---------------| |-------| | |||
* |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut| | |||
* `-----------------------------------------------------------' `-----------' `---------------' `-------' | |||
*/ | |||
KEYMAP_ALL( | |||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, | |||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, | |||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, | |||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, | |||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, | |||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, | |||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT | |||
), | |||
#endif | |||
#if 0 | |||
/* Colemak http://colemak.com | |||
* ,-----------------------------------------------------------. | |||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| | |||
* |-----------------------------------------------------------| | |||
* |Tab | Q| W| F| P| G| J| L| U| Y| ;| [| ]| \| | |||
* |-----------------------------------------------------------| | |||
* |BackSp| A| R| S| T| D| H| N| E| I| O| '|Return | | |||
* |-----------------------------------------------------------| | |||
* |Shift | Z| X| C| V| B| K| M| ,| ,| /|Shift | | |||
* |-----------------------------------------------------------| | |||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| | |||
* `----------------------------------------------------------' | |||
*/ | |||
KEYMAP_ALL( | |||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, | |||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, | |||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, | |||
TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, | |||
BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, | |||
LSFT,NUBS,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, | |||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT | |||
), | |||
/* Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard | |||
* ,-----------------------------------------------------------. | |||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa| | |||
* |-----------------------------------------------------------| | |||
* |Tab | '| ,| .| P| Y| F| G| C| R| L| /| =| \| | |||
* |-----------------------------------------------------------| | |||
* |BackSp| A| O| E| U| I| D| H| T| N| S| -|Return | | |||
* |-----------------------------------------------------------| | |||
* |Shift | ;| Q| J| K| X| B| M| Wl V| Z|Shift | | |||
* |-----------------------------------------------------------| | |||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| | |||
* `-----------------------------------------------------------' | |||
*/ | |||
KEYMAP_ALL( | |||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, | |||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, | |||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, | |||
TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, | |||
CAPS,A, O, E, U, I, D, H, T, N, S, MINS, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, | |||
LSFT,NUBS,SCLN,Q, J, K, X, B, M, W, V, Z, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, | |||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT | |||
), | |||
/* Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/ | |||
* ,-----------------------------------------------------------. | |||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| | |||
* |-----------------------------------------------------------| | |||
* |Tab | Q| D| R| W| B| J| F| U| P| ;| [| ]| \| | |||
* |-----------------------------------------------------------| | |||
* |CapsLo| A| S| H| T| G| Y| N| E| O| I| '|Return | | |||
* |-----------------------------------------------------------| | |||
* |Shift | Z| X| M| C| V| K| L| ,| ,| /|Shift | | |||
* |-----------------------------------------------------------| | |||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| | |||
* `-----------------------------------------------------------' | |||
*/ | |||
KEYMAP_ALL( | |||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, | |||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, | |||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, | |||
TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, | |||
CAPS,A, S, H, T, G, Y, N, E, O, I, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, | |||
LSFT,NUBS,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, | |||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT | |||
), | |||
#endif | |||
}; | |||
#ifdef KEYMAP_SECTION_ENABLE | |||
const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = { | |||
#else | |||
const uint16_t fn_actions[] PROGMEM = { | |||
#endif | |||
}; | |||
#ifdef KEYMAP_IN_EEPROM_ENABLE | |||
uint16_t keys_count(void) { | |||
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS; | |||
} | |||
uint16_t fn_actions_count(void) { | |||
return sizeof(fn_actions) / sizeof(fn_actions[0]); | |||
} | |||
#endif |
@@ -0,0 +1,38 @@ | |||
#include <avr/pgmspace.h> | |||
#include "ledmap.h" | |||
#include "debug.h" | |||
#ifdef LEDMAP_ENABLE | |||
static const uint16_t ledmaps[LED_COUNT] PROGMEM = { | |||
[0] = LEDMAP_NUM_LOCK, | |||
[1] = LEDMAP_CAPS_LOCK, | |||
[2] = LEDMAP_SCROLL_LOCK | |||
}; | |||
static uint8_t usb_led; | |||
void kbd_led_set(uint8_t usb_led); | |||
ledmap_t ledmap_get_code(uint8_t index) | |||
{ | |||
return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) }; | |||
} | |||
void ledmap_led_init(void) | |||
{ | |||
usb_led = 0; | |||
} | |||
void ledmap_led_on(uint8_t index) | |||
{ | |||
usb_led |= (1<<index); | |||
kbd_led_set(usb_led); | |||
} | |||
void ledmap_led_off(uint8_t index) | |||
{ | |||
usb_led &= ~(1<<index); | |||
kbd_led_set(usb_led); | |||
} | |||
#endif |
@@ -9,11 +9,10 @@ | |||
#include "sendchar.h" | |||
#include "debug.h" | |||
#include "keyboard.h" | |||
#include "led.h" | |||
/* LED ping configuration */ | |||
#define TMK_LED | |||
//#define TMK_LED | |||
//#define LEONARDO_LED | |||
#if defined(TMK_LED) | |||
// For TMK converter and Teensy | |||
@@ -54,7 +53,7 @@ static void LUFA_setup(void) | |||
print_set_sendchar(sendchar); | |||
} | |||
bool kbd_init = false; | |||
int main(void) | |||
{ | |||
@@ -81,6 +80,7 @@ int main(void) | |||
_delay_ms(1000); | |||
} | |||
kbd_init = true; | |||
debug("init: done\n"); | |||
for (;;) { |
@@ -32,7 +32,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
#include "timer.h" | |||
#include "matrix.h" | |||
#include "led.h" | |||
#include "action.h" | |||
#include "host.h" | |||
#define HID_MOUSE_ENABLE | |||
#define HID_COMPOSITE_ENABLE | |||
#define HID_KEYBOARD_COUNT 2 | |||
#define USB_HUB_COUNT 1 | |||
/* KEY CODE to Matrix | |||
* | |||
@@ -61,24 +67,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
// Integrated key state of all keyboards | |||
static report_keyboard_t keyboard_report; | |||
#ifdef HID_MOUSE_ENABLE | |||
extern report_mouse_t mouse_report; | |||
static uint8_t mouse_button; | |||
#endif | |||
static bool matrix_is_mod =false; | |||
static bool matrix_is_mod = false; | |||
/* | |||
* USB Host Shield HID keyboards | |||
* This supports two cascaded hubs and four keyboards | |||
*/ | |||
USB usb_host; | |||
#ifdef USB_HUB_COUNT > 0 | |||
USBHub hub1(&usb_host); | |||
#ifdef USB_HUB_COUNT > 1 | |||
USBHub hub2(&usb_host); | |||
#endif | |||
#endif | |||
#ifdef HID_COMPOSITE_ENABLE | |||
HIDBoot<HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE> composite(&usb_host); | |||
#else | |||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd1(&usb_host); | |||
#endif | |||
#if HID_KEYBOARD_COUNT > 1 | |||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd2(&usb_host); | |||
#if HID_KEYBOARD_COUNT > 2 | |||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd3(&usb_host); | |||
#if HID_KEYBOARD_COUNT > 3 | |||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd4(&usb_host); | |||
#endif | |||
#endif | |||
#endif | |||
KBDReportParser kbd_parser1; | |||
#if HID_KEYBOARD_COUNT > 1 | |||
KBDReportParser kbd_parser2; | |||
#if HID_KEYBOARD_COUNT > 1 | |||
KBDReportParser kbd_parser3; | |||
#if HID_KEYBOARD_COUNT > 1 | |||
KBDReportParser kbd_parser4; | |||
#endif | |||
#endif | |||
#endif | |||
#ifdef HID_MOUSE_ENABLE | |||
HIDBoot<HID_PROTOCOL_MOUSE> mouse1(&usb_host); | |||
MOUSEReportParser mouse_parser1; | |||
#endif | |||
uint8_t matrix_rows(void) { return MATRIX_ROWS; } | |||
@@ -87,10 +125,24 @@ bool matrix_has_ghost(void) { return false; } | |||
void matrix_init(void) { | |||
// USB Host Shield setup | |||
usb_host.Init(); | |||
#ifdef HID_COMPOSITE_ENABLE | |||
composite.SetReportParser(0, (HIDReportParser*)&kbd_parser1); | |||
composite.SetReportParser(1, (HIDReportParser*)&mouse_parser1); | |||
#else | |||
kbd1.SetReportParser(0, (HIDReportParser*)&kbd_parser1); | |||
#endif | |||
#if HID_KEYBOARD_COUNT > 1 | |||
kbd2.SetReportParser(0, (HIDReportParser*)&kbd_parser2); | |||
#if HID_KEYBOARD_COUNT > 2 | |||
kbd3.SetReportParser(0, (HIDReportParser*)&kbd_parser3); | |||
#if HID_KEYBOARD_COUNT > 3 | |||
kbd4.SetReportParser(0, (HIDReportParser*)&kbd_parser4); | |||
#endif | |||
#endif | |||
#endif | |||
#ifdef HID_MOUSE_ENABLE | |||
mouse1.SetReportParser(0, (HIDReportParser*)&mouse_parser1); | |||
#endif | |||
} | |||
static void or_report(report_keyboard_t report) { | |||
@@ -110,27 +162,52 @@ static void or_report(report_keyboard_t report) { | |||
uint8_t matrix_scan(void) { | |||
static uint16_t last_time_stamp1 = 0; | |||
#if HID_KEYBOARD_COUNT > 1 | |||
static uint16_t last_time_stamp2 = 0; | |||
#if HID_KEYBOARD_COUNT > 2 | |||
static uint16_t last_time_stamp3 = 0; | |||
#if HID_KEYBOARD_COUNT > 3 | |||
static uint16_t last_time_stamp4 = 0; | |||
#endif | |||
#endif | |||
#endif | |||
// check report came from keyboards | |||
if (kbd_parser1.time_stamp != last_time_stamp1 || | |||
kbd_parser2.time_stamp != last_time_stamp2 || | |||
kbd_parser3.time_stamp != last_time_stamp3 || | |||
kbd_parser4.time_stamp != last_time_stamp4) { | |||
if (kbd_parser1.time_stamp != last_time_stamp1 | |||
#if HID_KEYBOARD_COUNT > 1 | |||
|| kbd_parser2.time_stamp != last_time_stamp2 | |||
#if HID_KEYBOARD_COUNT > 2 | |||
|| kbd_parser3.time_stamp != last_time_stamp3 | |||
#if HID_KEYBOARD_COUNT > 3 | |||
|| kbd_parser4.time_stamp != last_time_stamp4 | |||
#endif | |||
#endif | |||
#endif | |||
) { | |||
last_time_stamp1 = kbd_parser1.time_stamp; | |||
#if HID_KEYBOARD_COUNT > 1 | |||
last_time_stamp2 = kbd_parser2.time_stamp; | |||
#if HID_KEYBOARD_COUNT > 2 | |||
last_time_stamp3 = kbd_parser3.time_stamp; | |||
#if HID_KEYBOARD_COUNT > 3 | |||
last_time_stamp4 = kbd_parser4.time_stamp; | |||
#endif | |||
#endif | |||
#endif | |||
// clear and integrate all reports | |||
keyboard_report = {}; | |||
or_report(kbd_parser1.report); | |||
#if HID_KEYBOARD_COUNT > 1 | |||
or_report(kbd_parser2.report); | |||
#if HID_KEYBOARD_COUNT > 2 | |||
or_report(kbd_parser3.report); | |||
#if HID_KEYBOARD_COUNT > 3 | |||
or_report(kbd_parser4.report); | |||
#endif | |||
#endif | |||
#endif | |||
matrix_is_mod = true; | |||
@@ -143,6 +220,42 @@ uint8_t matrix_scan(void) { | |||
matrix_is_mod = false; | |||
} | |||
#ifdef HID_MOUSE_ENABLE | |||
static uint16_t last_mouse_time_stamp = 0; | |||
if (last_mouse_time_stamp != mouse_parser1.time_stamp) { | |||
last_mouse_time_stamp = mouse_parser1.time_stamp; | |||
if (mouse_parser1.report.x || mouse_parser1.report.y) { | |||
int8_t x = mouse_report.x; | |||
int8_t y = mouse_report.y; | |||
mouse_report.x = mouse_parser1.report.x; | |||
mouse_report.y = mouse_parser1.report.y; | |||
host_mouse_send(&mouse_report); | |||
mouse_report.x = x; | |||
mouse_report.y = y; | |||
} | |||
if (mouse_parser1.report.v) { | |||
uint8_t code = 0; | |||
if (mouse_parser1.report.v == 1) code = KC_MS_WH_UP; | |||
else if (mouse_parser1.report.v == -1) code = KC_MS_WH_DOWN; | |||
if (code) { | |||
keyevent_t e; | |||
e.key.row = ROW(code); | |||
e.key.col = COL(code); | |||
e.pressed = 1; | |||
e.time = (timer_read() | 1); /* time should not be 0 */ | |||
action_exec(e); | |||
e.pressed = 0; | |||
e.time = (timer_read() | 1); /* time should not be 0 */ | |||
action_exec(e); | |||
} | |||
} | |||
if (mouse_button != mouse_parser1.report.buttons) { | |||
mouse_button = mouse_parser1.report.buttons; | |||
matrix_is_mod |= true; | |||
} | |||
} | |||
#endif | |||
uint16_t timer; | |||
timer = timer_read(); | |||
usb_host.Task(); | |||
@@ -181,6 +294,16 @@ matrix_row_t matrix_get_row(uint8_t row) { | |||
row_bits |= keyboard_report.mods; | |||
} | |||
#ifdef HID_MOUSE_ENABLE | |||
if (IS_MOUSEKEY(CODE(row, 0)) && mouse_button) { | |||
if (mouse_button & (1<<0)) row_bits |= (1<<(KC_MS_BTN1 - KC_MS_UP)); | |||
if (mouse_button & (1<<1)) row_bits |= (1<<(KC_MS_BTN2 - KC_MS_UP)); | |||
if (mouse_button & (1<<2)) row_bits |= (1<<(KC_MS_BTN3 - KC_MS_UP)); | |||
if (mouse_button & (1<<3)) row_bits |= (1<<(KC_MS_BTN4 - KC_MS_UP)); | |||
if (mouse_button & (1<<4)) row_bits |= (1<<(KC_MS_BTN5 - KC_MS_UP)); | |||
} | |||
#endif | |||
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | |||
if (IS_ANY(keyboard_report.keys[i])) { | |||
if (row == ROW(keyboard_report.keys[i])) { | |||
@@ -214,8 +337,32 @@ void matrix_print(void) { | |||
void led_set(uint8_t usb_led) | |||
{ | |||
#ifdef HID_COMPOSITE_ENABLE | |||
composite.SetReport(0, 0, 2, 0, 1, &usb_led); | |||
#else | |||
kbd1.SetReport(0, 0, 2, 0, 1, &usb_led); | |||
#endif | |||
#if HID_KEYBOARD_COUNT > 1 | |||
kbd2.SetReport(0, 0, 2, 0, 1, &usb_led); | |||
#if HID_KEYBOARD_COUNT > 2 | |||
kbd3.SetReport(0, 0, 2, 0, 1, &usb_led); | |||
#if HID_KEYBOARD_COUNT > 3 | |||
kbd4.SetReport(0, 0, 2, 0, 1, &usb_led); | |||
#endif | |||
#endif | |||
#endif | |||
} | |||
extern bool kbd_init; | |||
#ifdef __cplusplus | |||
extern "C" { | |||
void kbd_led_set(uint8_t usb_led) | |||
{ | |||
if (kbd_init) { | |||
dprintf("USB LED: %d\n", usb_led); | |||
led_set(usb_led); | |||
} | |||
} | |||
} | |||
#endif |
@@ -1 +1 @@ | |||
Subproject commit fe527f1c8a660a46a0bacb12d9be90903b9bb5b1 | |||
Subproject commit 85bb7f9de8452c1a4e718ae686f80249a490bc26 |