aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--common.mk1
-rw-r--r--common/action.c10
-rw-r--r--common/action_code.h3
-rw-r--r--common/avr/xprintf.h8
-rw-r--r--common/debug.c24
-rw-r--r--common/debug.h2
-rw-r--r--common/debug_config.h51
-rw-r--r--common/keyboard.c11
-rw-r--r--converter/adb_usb/Makefile2
-rw-r--r--converter/next_usb/Makefile26
-rw-r--r--converter/next_usb/Makefile.pjrc63
-rw-r--r--converter/next_usb/config.h38
-rw-r--r--converter/ps2_usb/Makefile.vusb10
-rw-r--r--converter/ps2_usb/README.md3
-rw-r--r--converter/serialmouse_usb/Makefile106
-rw-r--r--converter/serialmouse_usb/README.md11
-rw-r--r--converter/serialmouse_usb/config.h119
-rw-r--r--converter/serialmouse_usb/keymap.c33
-rw-r--r--converter/serialmouse_usb/keymap_common.c30
-rw-r--r--converter/serialmouse_usb/keymap_common.h174
-rw-r--r--converter/serialmouse_usb/led.c24
-rw-r--r--converter/serialmouse_usb/matrix.c83
-rw-r--r--converter/sun_usb/Makefile1
-rw-r--r--converter/sun_usb/README20
-rw-r--r--converter/sun_usb/command_extra.c28
-rw-r--r--converter/sun_usb/matrix.c16
-rw-r--r--converter/usb_usb/README4
-rw-r--r--converter/usb_usb/config.h1
-rw-r--r--converter/usb_usb/main.cpp1
-rw-r--r--doc/keymap.md7
-rw-r--r--keyboard/lightpad/Makefile.lufa117
-rw-r--r--keyboard/lightpad/README.md24
-rw-r--r--keyboard/lightpad/backlight.c129
-rw-r--r--keyboard/lightpad/backlight.h39
-rw-r--r--keyboard/lightpad/config.h46
-rw-r--r--keyboard/lightpad/keymap.c73
-rw-r--r--keyboard/lightpad/keymap_lightpad.h29
-rw-r--r--keyboard/lightpad/led.c24
-rw-r--r--keyboard/lightpad/matrix.c205
-rw-r--r--protocol.mk20
-rw-r--r--protocol/pjrc/usb_keyboard.c2
-rw-r--r--protocol/serial_mouse.h33
-rw-r--r--protocol/serial_mouse_microsoft.c124
-rw-r--r--protocol/serial_mouse_mousesystems.c131
-rw-r--r--protocol/serial_soft.c20
-rw-r--r--protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h2
-rw-r--r--protocol/usb_hid/override_wiring.c1
-rw-r--r--protocol/usb_hid/parser.cpp2
-rw-r--r--protocol/vusb/usbdrv/usbdrv.c8
-rw-r--r--protocol/vusb/usbdrv/usbdrv.h14
-rw-r--r--protocol/vusb/vusb.c17
52 files changed, 1924 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index b79d72b7c..f3f46872a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,5 +8,6 @@
8*.map 8*.map
9*.sym 9*.sym
10tags 10tags
11*~
11build/ 12build/
12*.bak 13*.bak
diff --git a/common.mk b/common.mk
index 04f036477..b854f09cd 100644
--- a/common.mk
+++ b/common.mk
@@ -8,6 +8,7 @@ SRC += $(COMMON_DIR)/host.c \
8 $(COMMON_DIR)/action_util.c \ 8 $(COMMON_DIR)/action_util.c \
9 $(COMMON_DIR)/keymap.c \ 9 $(COMMON_DIR)/keymap.c \
10 $(COMMON_DIR)/print.c \ 10 $(COMMON_DIR)/print.c \
11 $(COMMON_DIR)/debug.c \
11 $(COMMON_DIR)/util.c \ 12 $(COMMON_DIR)/util.c \
12 $(COMMON_DIR)/avr/suspend.c \ 13 $(COMMON_DIR)/avr/suspend.c \
13 $(COMMON_DIR)/avr/xprintf.S \ 14 $(COMMON_DIR)/avr/xprintf.S \
diff --git a/common/action.c b/common/action.c
index 94498fe6c..ec8eeae7b 100644
--- a/common/action.c
+++ b/common/action.c
@@ -237,6 +237,16 @@ void process_action(keyrecord_t *record)
237 case ACT_LAYER_TAP: 237 case ACT_LAYER_TAP:
238 case ACT_LAYER_TAP_EXT: 238 case ACT_LAYER_TAP_EXT:
239 switch (action.layer_tap.code) { 239 switch (action.layer_tap.code) {
240 case 0xe0 ... 0xef:
241 /* layer On/Off with modifiers(left only) */
242 if (event.pressed) {
243 layer_on(action.layer_tap.val);
244 register_mods(action.layer_tap.code & 0x0f);
245 } else {
246 layer_off(action.layer_tap.val);
247 unregister_mods(action.layer_tap.code & 0x0f);
248 }
249 break;
240 case OP_TAP_TOGGLE: 250 case OP_TAP_TOGGLE:
241 /* tap toggle */ 251 /* tap toggle */
242 if (event.pressed) { 252 if (event.pressed) {
diff --git a/common/action_code.h b/common/action_code.h
index 50112d4d2..bc40e2c6f 100644
--- a/common/action_code.h
+++ b/common/action_code.h
@@ -71,7 +71,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
71 * 71 *
72 * ACT_LAYER_TAP(101x): 72 * ACT_LAYER_TAP(101x):
73 * 101E|LLLL| keycode On/Off with tap key 73 * 101E|LLLL| keycode On/Off with tap key
74 * 101E|LLLL|1110 xxxx Reserved(0xE0-EF) 74 * 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF)
75 * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0) 75 * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0)
76 * 101E|LLLL|1111 0001 On/Off 76 * 101E|LLLL|1111 0001 On/Off
77 * 101E|LLLL|1111 0010 Off/On 77 * 101E|LLLL|1111 0010 Off/On
@@ -266,6 +266,7 @@ enum layer_pram_tap_op {
266#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) 266#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
267#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) 267#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
268#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) 268#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
269#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f)
269/* With Tapping */ 270/* With Tapping */
270#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) 271#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
271#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) 272#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
diff --git a/common/avr/xprintf.h b/common/avr/xprintf.h
index f58bca817..59c6f2531 100644
--- a/common/avr/xprintf.h
+++ b/common/avr/xprintf.h
@@ -8,6 +8,10 @@
8#include <inttypes.h> 8#include <inttypes.h>
9#include <avr/pgmspace.h> 9#include <avr/pgmspace.h>
10 10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
11extern void (*xfunc_out)(uint8_t); 15extern void (*xfunc_out)(uint8_t);
12#define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func) 16#define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func)
13 17
@@ -99,5 +103,9 @@ char xatoi(char **str, long *ret);
99 Pointer to return value 103 Pointer to return value
100*/ 104*/
101 105
106#ifdef __cplusplus
107}
108#endif
109
102#endif 110#endif
103 111
diff --git a/common/debug.c b/common/debug.c
new file mode 100644
index 000000000..18613fc28
--- /dev/null
+++ b/common/debug.c
@@ -0,0 +1,24 @@
1#include <stdbool.h>
2#include "debug.h"
3
4#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
5
6debug_config_t debug_config = {
7/* GCC Bug 10676 - Using unnamed fields in initializers
8 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 */
9#if GCC_VERSION >= 40600
10 .enable = false,
11 .matrix = false,
12 .keyboard = false,
13 .mouse = false,
14 .reserved = 0
15#else
16 {
17 false, // .enable
18 false, // .matrix
19 false, // .keyboard
20 false, // .mouse
21 0 // .reserved
22 }
23#endif
24};
diff --git a/common/debug.h b/common/debug.h
index 26472c8fa..472dd478c 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -29,7 +29,6 @@ extern "C" {
29#endif 29#endif
30 30
31typedef union { 31typedef union {
32 uint8_t raw;
33 struct { 32 struct {
34 bool enable:1; 33 bool enable:1;
35 bool matrix:1; 34 bool matrix:1;
@@ -37,6 +36,7 @@ typedef union {
37 bool mouse:1; 36 bool mouse:1;
38 uint8_t reserved:4; 37 uint8_t reserved:4;
39 }; 38 };
39 uint8_t raw;
40} debug_config_t; 40} debug_config_t;
41 41
42extern debug_config_t debug_config; 42extern debug_config_t debug_config;
diff --git a/common/debug_config.h b/common/debug_config.h
new file mode 100644
index 000000000..28bc34cd5
--- /dev/null
+++ b/common/debug_config.h
@@ -0,0 +1,51 @@
1/*
2Copyright 2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef DEBUG_CONFIG_H
19#define DEBUG_CONFIG_H 1
20
21#include <stdbool.h>
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* NOTE: Not portable. Bit field order depends on implementation */
29typedef union {
30 struct {
31 bool enable:1;
32 bool matrix:1;
33 bool keyboard:1;
34 bool mouse:1;
35 uint8_t reserved:4;
36 };
37 uint8_t raw;
38} debug_config_t;
39extern debug_config_t debug_config;
40
41/* for backward compatibility */
42#define debug_enable (debug_config.enable)
43#define debug_matrix (debug_config.matrix)
44#define debug_keyboard (debug_config.keyboard)
45#define debug_mouse (debug_config.mouse)
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif
diff --git a/common/keyboard.c b/common/keyboard.c
index 9a809ff4a..1e3fb510a 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -36,6 +36,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36#ifdef PS2_MOUSE_ENABLE 36#ifdef PS2_MOUSE_ENABLE
37# include "ps2_mouse.h" 37# include "ps2_mouse.h"
38#endif 38#endif
39#ifdef SERIAL_MOUSE_ENABLE
40#include "serial_mouse.h"
41#endif
39 42
40 43
41#ifdef MATRIX_HAS_GHOST 44#ifdef MATRIX_HAS_GHOST
@@ -63,6 +66,10 @@ void keyboard_init(void)
63#ifdef PS2_MOUSE_ENABLE 66#ifdef PS2_MOUSE_ENABLE
64 ps2_mouse_init(); 67 ps2_mouse_init();
65#endif 68#endif
69#ifdef SERIAL_MOUSE_ENABLE
70 serial_mouse_init();
71#endif
72
66 73
67#ifdef BOOTMAGIC_ENABLE 74#ifdef BOOTMAGIC_ENABLE
68 bootmagic(); 75 bootmagic();
@@ -125,6 +132,10 @@ MATRIX_LOOP_END:
125 ps2_mouse_task(); 132 ps2_mouse_task();
126#endif 133#endif
127 134
135#ifdef SERIAL_MOUSE_ENABLE
136 serial_mouse_task();
137#endif
138
128 // update LED 139 // update LED
129 if (led_status != host_keyboard_leds()) { 140 if (led_status != host_keyboard_leds()) {
130 led_status = host_keyboard_leds(); 141 led_status = host_keyboard_leds();
diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile
index 73cae8ab3..bbb7810ee 100644
--- a/converter/adb_usb/Makefile
+++ b/converter/adb_usb/Makefile
@@ -121,7 +121,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
121CONSOLE_ENABLE = yes # Console for debug(+400) 121CONSOLE_ENABLE = yes # Console for debug(+400)
122COMMAND_ENABLE = yes # Commands for debug and configuration 122COMMAND_ENABLE = yes # Commands for debug and configuration
123#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 123#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
124#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA 124#NKRO_ENABLE = yes # USB Nkey Rollover
125 125
126 126
127# Optimize size but this may cause error "relocation truncated to fit" 127# Optimize size but this may cause error "relocation truncated to fit"
diff --git a/converter/next_usb/Makefile b/converter/next_usb/Makefile
index 51d9de6b1..fef539a14 100644
--- a/converter/next_usb/Makefile
+++ b/converter/next_usb/Makefile
@@ -20,6 +20,7 @@ CONFIG_H = config.h
20MCU = atmega32u4 # Teensy 2.0 20MCU = atmega32u4 # Teensy 2.0
21#MCU = at90usb646 # Teensy++ 1.0 21#MCU = at90usb646 # Teensy++ 1.0
22#MCU = at90usb1286 # Teensy++ 2.0 22#MCU = at90usb1286 # Teensy++ 2.0
23#MCU = atmega32u2 # TMK converter
23 24
24 25
25# Processor frequency. 26# Processor frequency.
@@ -30,6 +31,29 @@ MCU = atmega32u4 # Teensy 2.0
30F_CPU = 16000000 31F_CPU = 16000000
31 32
32 33
34#
35# LUFA specific
36#
37# Target architecture (see library "Board Types" documentation).
38ARCH = AVR8
39
40# Input clock frequency.
41# This will define a symbol, F_USB, in all source code files equal to the
42# input clock frequency (before any prescaling is performed) in Hz. This value may
43# differ from F_CPU if prescaling is used on the latter, and is required as the
44# raw input clock is fed directly to the PLL sections of the AVR for high speed
45# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
46# at the end, this will be done automatically to create a 32-bit value in your
47# source code.
48#
49# If no clock division is performed on the input clock inside the AVR (via the
50# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
51F_USB = $(F_CPU)
52
53# Interrupt driven control endpoint task(+60)
54#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
55
56
33# Boot Section Size in *bytes* 57# Boot Section Size in *bytes*
34# Teensy halfKay 512 58# Teensy halfKay 512
35# Teensy++ halfKay 1024 59# Teensy++ halfKay 1024
@@ -58,6 +82,6 @@ VPATH += $(TOP_DIR)
58 82
59 83
60include $(TOP_DIR)/protocol.mk 84include $(TOP_DIR)/protocol.mk
61include $(TOP_DIR)/protocol/pjrc.mk 85include $(TOP_DIR)/protocol/lufa.mk
62include $(TOP_DIR)/common.mk 86include $(TOP_DIR)/common.mk
63include $(TOP_DIR)/rules.mk 87include $(TOP_DIR)/rules.mk
diff --git a/converter/next_usb/Makefile.pjrc b/converter/next_usb/Makefile.pjrc
new file mode 100644
index 000000000..51d9de6b1
--- /dev/null
+++ b/converter/next_usb/Makefile.pjrc
@@ -0,0 +1,63 @@
1# Target file name (without extension).
2TARGET = next_usb
3
4# Directory common source filess exist
5TOP_DIR = ../..
6
7# Directory keyboard dependent files exist
8TARGET_DIR = .
9
10# keyboard dependent files
11SRC = keymap.c \
12 matrix.c \
13 led.c
14
15CONFIG_H = config.h
16
17# MCU name, you MUST set this to match the board you are using
18# type "make clean" after changing this, so all files will be rebuilt
19#MCU = at90usb162 # Teensy 1.0
20MCU = atmega32u4 # Teensy 2.0
21#MCU = at90usb646 # Teensy++ 1.0
22#MCU = at90usb1286 # Teensy++ 2.0
23
24
25# Processor frequency.
26# Normally the first thing your program should do is set the clock prescaler,
27# so your program will run at the correct speed. You should also set this
28# variable to same clock speed. The _delay_ms() macro uses this, and many
29# examples use this variable to calculate timings. Do not add a "UL" here.
30F_CPU = 16000000
31
32
33# Boot Section Size in *bytes*
34# Teensy halfKay 512
35# Teensy++ halfKay 1024
36# Atmel DFU loader 4096
37# LUFA bootloader 4096
38# USBaspLoader 2048
39OPT_DEFS += -DBOOTLOADER_SIZE=4096
40
41
42# Build Options
43# *Comment out* to disable the options.
44#
45#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
46MOUSEKEY_ENABLE = yes # Mouse keys
47EXTRAKEY_ENABLE = yes # Audio control and System control
48CONSOLE_ENABLE = yes # Console for debug(+400)
49COMMAND_ENABLE = yes # Commands for debug and configuration
50#NKRO_ENABLE = yes # USB Nkey Rollover
51
52SRC += next_kbd.c
53
54
55# Search Path
56VPATH += $(TARGET_DIR)
57VPATH += $(TOP_DIR)
58
59
60include $(TOP_DIR)/protocol.mk
61include $(TOP_DIR)/protocol/pjrc.mk
62include $(TOP_DIR)/common.mk
63include $(TOP_DIR)/rules.mk
diff --git a/converter/next_usb/config.h b/converter/next_usb/config.h
index b3d188b0c..cd80b5af1 100644
--- a/converter/next_usb/config.h
+++ b/converter/next_usb/config.h
@@ -60,6 +60,7 @@ POSSIBILITY OF SUCH DAMAGE.
60 60
61//#define TEENSY_CONFIG 1 61//#define TEENSY_CONFIG 1
62#define PRO_MICRO_CONFIG 1 62#define PRO_MICRO_CONFIG 1
63//#define TMK_CONFIG 1
63 64
64// comment out if you don't want the keyboard's LEDs to flash upon initialization 65// comment out if you don't want the keyboard's LEDs to flash upon initialization
65#define NEXT_KBD_INIT_FLASH_LEDS 66#define NEXT_KBD_INIT_FLASH_LEDS
@@ -143,6 +144,43 @@ POSSIBILITY OF SUCH DAMAGE.
143#endif 144#endif
144//================= End of Teensy 2.0 Configuration ================== 145//================= End of Teensy 2.0 Configuration ==================
145 146
147
148//================ Start of TMK converter Configuration =================
149#ifdef TMK_CONFIG
150
151// this is the debugging LED that flashes when a key is being pressed
152// comment out in order to disable debugging LED
153#define NEXT_KBD_LED1_PORT PORTD
154#define NEXT_KBD_LED1_PIN PIND
155#define NEXT_KBD_LED1_DDR DDRD
156#define NEXT_KBD_LED1_BIT 6
157
158#define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT);
159#define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT);
160
161// corresponds to the Keyboard In wire on the NeXT connector
162#define NEXT_KBD_OUT_PORT PORTD
163#define NEXT_KBD_OUT_PIN PIND
164#define NEXT_KBD_OUT_DDR DDRD
165#define NEXT_KBD_OUT_BIT 1
166
167// corresponds to the Keyboard Out wire on the NeXT connector
168#define NEXT_KBD_IN_PORT PORTD
169#define NEXT_KBD_IN_PIN PIND
170#define NEXT_KBD_IN_DDR DDRD
171#define NEXT_KBD_IN_BIT 0
172
173// this pin is an input for the power key on the NeXT keyboard
174// as the keyboard is powered on this should be normally high;
175// if it is pulled low it means the power button is being preseed
176#define NEXT_KBD_PWR_PORT PORTD
177#define NEXT_KBD_PWR_PIN PIND
178#define NEXT_KBD_PWR_DDR DDRD
179#define NEXT_KBD_PWR_BIT 4
180
181#endif
182//================= End of TMK converter Configuration ==================
183
146/* key combination for command */ 184/* key combination for command */
147#define IS_COMMAND() ( \ 185#define IS_COMMAND() ( \
148 (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))|| \ 186 (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))|| \
diff --git a/converter/ps2_usb/Makefile.vusb b/converter/ps2_usb/Makefile.vusb
index 1bb44f887..ddf186845 100644
--- a/converter/ps2_usb/Makefile.vusb
+++ b/converter/ps2_usb/Makefile.vusb
@@ -8,10 +8,16 @@ TOP_DIR = ../..
8TARGET_DIR = . 8TARGET_DIR = .
9 9
10# keyboard dependent files 10# keyboard dependent files
11SRC = keymap.c \ 11SRC = keymap_common.c \
12 matrix.c \ 12 matrix.c \
13 led.c 13 led.c
14 14
15ifdef KEYMAP
16 SRC := keymap_$(KEYMAP).c $(SRC)
17else
18 SRC := keymap_plain.c $(SRC)
19endif
20
15# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful. 21# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful.
16SRC += protocol/ps2_usart.c 22SRC += protocol/ps2_usart.c
17OPT_DEFS += -DPS2_USE_USART 23OPT_DEFS += -DPS2_USE_USART
@@ -95,7 +101,7 @@ VPATH += $(TARGET_DIR)
95VPATH += $(TOP_DIR) 101VPATH += $(TOP_DIR)
96 102
97 103
98include $(TOP_DIR)/protocol/vusb.mk
99include $(TOP_DIR)/protocol.mk 104include $(TOP_DIR)/protocol.mk
100include $(TOP_DIR)/common.mk 105include $(TOP_DIR)/common.mk
106include $(TOP_DIR)/protocol/vusb.mk
101include $(TOP_DIR)/rules.mk 107include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/README.md b/converter/ps2_usb/README.md
index 586394b23..8a535949d 100644
--- a/converter/ps2_usb/README.md
+++ b/converter/ps2_usb/README.md
@@ -58,8 +58,7 @@ To select method edit Makefile.
58 58
59V-USB Support 59V-USB Support
60------------- 60-------------
61You can also use this converter on ATmega(168/328) with V-USB instead of Teensy. 61With V-USB you can use this converter on ATmega(168/328) but it doesn't support NKRO at this time.
62The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
63 62
64Circuit: 63Circuit:
65 64
diff --git a/converter/serialmouse_usb/Makefile b/converter/serialmouse_usb/Makefile
new file mode 100644
index 000000000..ea0e439bd
--- /dev/null
+++ b/converter/serialmouse_usb/Makefile
@@ -0,0 +1,106 @@
1#
2# Makefile for Teensy
3#
4# Target file name (without extension).
5TARGET = serialmouse_usb
6
7# Directory common source filess exist
8TOP_DIR = ../..
9
10# Directory keyboard dependent files exist
11TARGET_DIR = .
12
13# project specific files
14SRC = keymap.c \
15 matrix.c \
16 led.c
17
18CONFIG_H = config.h
19
20
21# MCU name
22#MCU = at90usb1287
23MCU = atmega32u4
24
25# Processor frequency.
26# This will define a symbol, F_CPU, in all source code files equal to the
27# processor frequency in Hz. You can then use this symbol in your source code to
28# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
29# automatically to create a 32-bit value in your source code.
30#
31# This will be an integer division of F_USB below, as it is sourced by
32# F_USB after it has run through any CPU prescalers. Note that this value
33# does not *change* the processor frequency - it should merely be updated to
34# reflect the processor speed set externally so that the code can use accurate
35# software delays.
36F_CPU = 16000000
37
38
39#
40# LUFA specific
41#
42# Target architecture (see library "Board Types" documentation).
43ARCH = AVR8
44
45# Input clock frequency.
46# This will define a symbol, F_USB, in all source code files equal to the
47# input clock frequency (before any prescaling is performed) in Hz. This value may
48# differ from F_CPU if prescaling is used on the latter, and is required as the
49# raw input clock is fed directly to the PLL sections of the AVR for high speed
50# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
51# at the end, this will be done automatically to create a 32-bit value in your
52# source code.
53#
54# If no clock division is performed on the input clock inside the AVR (via the
55# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
56F_USB = $(F_CPU)
57
58# Interrupt driven control endpoint task(+60)
59#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
60
61
62# Boot Section Size in *bytes*
63# Teensy halfKay 512
64# Teensy++ halfKay 1024
65# Atmel DFU loader 4096
66# LUFA bootloader 4096
67# USBaspLoader 2048
68OPT_DEFS += -DBOOTLOADER_SIZE=512
69
70
71# Build Options
72# comment out to disable the options.
73#
74#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
75#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
76#EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
77CONSOLE_ENABLE = yes # Console for debug(+400)
78#COMMAND_ENABLE = yes # Commands for debug and configuration
79#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
80
81
82# Serial Mouse Options
83# You can choose a mouse protocol and the implementation of
84# the underlying serial connection.
85#
86SERIAL_MOUSE_MICROSOFT_ENABLE = yes # Enable support for Microsoft-compatible mice
87#SERIAL_MOUSE_MOUSESYSTEMS_ENABLE = yes # Enable support for Mousesystems-compatible mice
88#SERIAL_MOUSE_USE_UART = yes # use hardware UART for serial connection
89SERIAL_MOUSE_USE_SOFT = yes # use software serial implementation
90
91# Optional serial mouse driver features
92# Support scrolling while holding the middle mouse button
93# (currently only supported for Mousesystems mice):
94#OPT_DEFS += -DSERIAL_MOUSE_CENTER_SCROLL
95
96# Optimize size but this may cause error "relocation truncated to fit"
97#EXTRALDFLAGS = -Wl,--relax
98
99# Search Path
100VPATH += $(TARGET_DIR)
101VPATH += $(TOP_DIR)
102
103include $(TOP_DIR)/protocol.mk
104include $(TOP_DIR)/protocol/lufa.mk
105include $(TOP_DIR)/common.mk
106include $(TOP_DIR)/rules.mk
diff --git a/converter/serialmouse_usb/README.md b/converter/serialmouse_usb/README.md
new file mode 100644
index 000000000..ef8a00671
--- /dev/null
+++ b/converter/serialmouse_usb/README.md
@@ -0,0 +1,11 @@
1Serial mouse converter
2======================
3See https://github.com/tmk/tmk_keyboard/pull/131
4
5
6Supported protocols
7-------------------
8### Microsoft
9Not tested.
10
11### Mousesystems
diff --git a/converter/serialmouse_usb/config.h b/converter/serialmouse_usb/config.h
new file mode 100644
index 000000000..b257d997c
--- /dev/null
+++ b/converter/serialmouse_usb/config.h
@@ -0,0 +1,119 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include <avr/interrupt.h>
22
23#define VENDOR_ID 0xFEED
24#define PRODUCT_ID 0x2222
25#define DEVICE_VER 0x0001
26#define MANUFACTURER t.m.k.
27#define PRODUCT serial mouse converter
28#define DESCRIPTION convert serial mouse into USB
29
30
31/* matrix size */
32#define MATRIX_ROWS 0
33#define MATRIX_COLS 0
34
35
36/* key combination for command */
37#define IS_COMMAND() false
38
39
40
41#ifdef SERIAL_MOUSE_MICROSOFT
42 /*
43 * Serial(USART) configuration (for Microsoft serial mice)
44 * asynchronous, positive logic, 1200baud, bit order: LSB first
45 * 1-start bit, 7-data bit, no parity, 1-stop bit
46 */
47 #define SERIAL_UART_BAUD 1200
48 #define SERIAL_UART_DATA UDR1
49 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
50 #define SERIAL_UART_RXD_VECT USART1_RX_vect
51 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
52 #define SERIAL_UART_INIT() do { \
53 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
54 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
55 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
56 UCSR1C = (1<<UCSZ11) | (0<<UCSZ10); /* no parity, 1 stop bit, 7-bit characters */ \
57 sei(); \
58 } while(0)
59
60 // for Microsoft mouse protocol
61 /* Serial(USART) configuration
62 * asynchronous, negative logic, 1200baud, no flow control
63 * 1-start bit, 7-data bit, non parity, 1-stop bit
64 */
65 #define SERIAL_SOFT_BAUD 1200
66 #define SERIAL_SOFT_DATA_7BIT
67 #define SERIAL_SOFT_PARITY_NONE
68 #define SERIAL_SOFT_BIT_ORDER_LSB
69 #define SERIAL_SOFT_LOGIC_NEGATIVE
70 /* RXD Port */
71 #define SERIAL_SOFT_RXD_DDR DDRD
72 #define SERIAL_SOFT_RXD_PORT PORTD
73 #define SERIAL_SOFT_RXD_PIN PIND
74 #define SERIAL_SOFT_RXD_BIT 2
75 #define SERIAL_SOFT_RXD_VECT INT2_vect
76 /* RXD Interupt */
77 #define SERIAL_SOFT_RXD_INIT() do { \
78 /* pin configuration: input with pull-up */ \
79 SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
80 SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
81 /* enable interrupt: INT2(rising edge) */ \
82 EICRA |= ((1<<ISC21)|(1<<ISC20)); \
83 EIMSK |= (1<<INT2); \
84 sei(); \
85 } while (0)
86 #define SERIAL_SOFT_RXD_INT_ENTER()
87 #define SERIAL_SOFT_RXD_INT_EXIT() do { \
88 /* clear interrupt flag */ \
89 EIFR = (1<<INTF2); \
90 } while (0)
91 #define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
92 /* TXD Port */
93 #define SERIAL_SOFT_TXD_HI()
94 #define SERIAL_SOFT_TXD_LO()
95 #define SERIAL_SOFT_TXD_INIT()
96#elif defined(SERIAL_MOUSE_MOUSESYSTEMS)
97 /*
98 * Serial(USART) configuration (for Mousesystems serial mice)
99 * asynchronous, positive logic, 1200baud, bit order: LSB first
100 * 1-start bit, 8-data bit, no parity, 1-stop bit
101 */
102 #define SERIAL_UART_BAUD 1200
103 #define SERIAL_UART_DATA UDR1
104 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
105 #define SERIAL_UART_RXD_VECT USART1_RX_vect
106 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
107 #define SERIAL_UART_INIT() do { \
108 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
109 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
110 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
111 UCSR1C = (1<<UCSZ11) | (1<<UCSZ10); /* no parity, 1 stop bit, 8-bit characters */ \
112 sei(); \
113 } while(0)
114#endif
115
116
117
118
119#endif
diff --git a/converter/serialmouse_usb/keymap.c b/converter/serialmouse_usb/keymap.c
new file mode 100644
index 000000000..de8f75c2a
--- /dev/null
+++ b/converter/serialmouse_usb/keymap.c
@@ -0,0 +1,33 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include <stdint.h>
18#include <stdbool.h>
19#include "keymap.h"
20
21
22/* translates key to keycode */
23uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
24{
25 return KC_NO;
26}
27
28/* translates Fn keycode to action */
29action_t keymap_fn_to_action(uint8_t keycode)
30{
31 return (action_t){};
32}
33
diff --git a/converter/serialmouse_usb/keymap_common.c b/converter/serialmouse_usb/keymap_common.c
new file mode 100644
index 000000000..241d2e33b
--- /dev/null
+++ b/converter/serialmouse_usb/keymap_common.c
@@ -0,0 +1,30 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "keymap_common.h"
18
19
20/* translates key to keycode */
21uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
22{
23 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
24}
25
26/* translates Fn keycode to action */
27action_t keymap_fn_to_action(uint8_t keycode)
28{
29 return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
30}
diff --git a/converter/serialmouse_usb/keymap_common.h b/converter/serialmouse_usb/keymap_common.h
new file mode 100644
index 000000000..216a8dc02
--- /dev/null
+++ b/converter/serialmouse_usb/keymap_common.h
@@ -0,0 +1,174 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#ifndef KEYMAP_COMMON_H
18#define KEYMAP_COMMON_H
19
20#include <stdint.h>
21#include <stdbool.h>
22#include <avr/pgmspace.h>
23#include "keycode.h"
24#include "action.h"
25#include "action_macro.h"
26#include "report.h"
27#include "print.h"
28#include "debug.h"
29#include "keymap.h"
30
31
32// 32*8(256) byte array which converts PS/2 code into USB code
33extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
34extern const uint16_t fn_actions[];
35
36
37/* All keys */
38#define KEYMAP_ALL( \
39 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
40 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
41 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
42 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
43 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
44 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
45 \
46 K61, /* for European ISO */ \
47 K51, K13, K6A, K64, K67, /* for Japanese JIS */ \
48 K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \
49 KB7, KBF, KDE, /* System Power, Sleep, Wake */ \
50 KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \
51 KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \
52 KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \
53 K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \
54 KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \
55) { \
56 { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
57 { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \
58 { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
59 { KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \
60 { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
61 { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \
62 { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
63 { KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
64 { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
65 { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \
66 { KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \
67 { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \
68 { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
69 { KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \
70 { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
71 { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \
72 { KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \
73 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
74 { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \
75 { KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \
76 { KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \
77 { KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \
78 { KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \
79 { KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \
80 { KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
81 { KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \
82 { KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
83 { KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \
84 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
85 { KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \
86 { KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \
87 { KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \
88}
89
90/* US layout */
91#define KEYMAP( \
92 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
93 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
94 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
95 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
96 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
97 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
98) \
99KEYMAP_ALL( \
100 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
101 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
102 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
103 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
104 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
105 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
106 \
107 NUBS, \
108 RO, KANA, JYEN, HENK, MHEN, \
109 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
110 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
111 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
112 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
113 MAIL, CALCULATOR, MY_COMPUTER, \
114 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
115 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
116)
117
118/* ISO layout */
119#define KEYMAP_ISO( \
120 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
121 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
122 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
123 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \
124 K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
125 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
126) \
127KEYMAP_ALL( \
128 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
129 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
130 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
131 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
132 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
133 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
134 \
135 K61, \
136 RO, KANA, JYEN, HENK, MHEN, \
137 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
138 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
139 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
140 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
141 MAIL, CALCULATOR, MY_COMPUTER, \
142 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
143 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
144)
145
146/* JIS layout */
147#define KEYMAP_JIS( \
148 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
149 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
150 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
151 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
152 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
153 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
154) \
155KEYMAP_ALL( \
156 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
157 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
158 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
159 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
160 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
161 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
162 \
163 NUBS, \
164 K51, K13, K6A, K64, K67, \
165 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
166 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
167 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
168 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
169 MAIL, CALCULATOR, MY_COMPUTER, \
170 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
171 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
172)
173
174#endif
diff --git a/converter/serialmouse_usb/led.c b/converter/serialmouse_usb/led.c
new file mode 100644
index 000000000..f76545f0b
--- /dev/null
+++ b/converter/serialmouse_usb/led.c
@@ -0,0 +1,24 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "stdint.h"
19#include "led.h"
20
21
22void led_set(uint8_t usb_led)
23{
24}
diff --git a/converter/serialmouse_usb/matrix.c b/converter/serialmouse_usb/matrix.c
new file mode 100644
index 000000000..0e0d87f80
--- /dev/null
+++ b/converter/serialmouse_usb/matrix.c
@@ -0,0 +1,83 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <stdbool.h>
20#include <avr/io.h>
21#include <util/delay.h>
22#include "action.h"
23#include "print.h"
24#include "util.h"
25#include "debug.h"
26#include "matrix.h"
27
28
29inline
30uint8_t matrix_rows(void)
31{
32 return MATRIX_ROWS;
33}
34
35inline
36uint8_t matrix_cols(void)
37{
38 return MATRIX_COLS;
39}
40
41void matrix_init(void)
42{
43 debug_enable = true;
44 debug_mouse=true;
45 return;
46}
47
48uint8_t matrix_scan(void)
49{
50 return 0;
51}
52
53bool matrix_is_modified(void)
54{
55 return false;
56}
57
58inline
59bool matrix_has_ghost(void)
60{
61 return false;
62}
63
64inline
65bool matrix_is_on(uint8_t row, uint8_t col)
66{
67 return false;
68}
69
70inline
71uint8_t matrix_get_row(uint8_t row)
72{
73 return 0;
74}
75
76void matrix_print(void)
77{
78}
79
80uint8_t matrix_key_count(void)
81{
82 return 0;
83}
diff --git a/converter/sun_usb/Makefile b/converter/sun_usb/Makefile
index 35c4bb123..b32497cd9 100644
--- a/converter/sun_usb/Makefile
+++ b/converter/sun_usb/Makefile
@@ -63,6 +63,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
63MOUSEKEY_ENABLE = yes # Mouse keys 63MOUSEKEY_ENABLE = yes # Mouse keys
64EXTRAKEY_ENABLE = yes # Audio control and System control 64EXTRAKEY_ENABLE = yes # Audio control and System control
65CONSOLE_ENABLE = yes # Console for debug 65CONSOLE_ENABLE = yes # Console for debug
66COMMAND_ENABLE = yes # Commands for debug and configuration
66#NKRO_ENABLE = yes # USB Nkey Rollover 67#NKRO_ENABLE = yes # USB Nkey Rollover
67 68
68 69
diff --git a/converter/sun_usb/README b/converter/sun_usb/README
index ee59fc757..276f6bfff 100644
--- a/converter/sun_usb/README
+++ b/converter/sun_usb/README
@@ -77,3 +77,23 @@ Just use 'make'
77 $ cd sun_usb 77 $ cd sun_usb
78 $ make 78 $ make
79Then, load the binary to MCU with your favorite programmer. 79Then, load the binary to MCU with your favorite programmer.
80
81
82Sun commands
83------------
84You can send Sun protocol commands with TMK `Magic` key combo. By default `Magic` key is `LShift` + `RShift`, `LAlt` + `RAlt' or `LMeta` + `RMeta`.
85https://github.com/tmk/tmk_keyboard#magic-commands
86
87Following Sun specific commands are available. For example, to send 'Bell On' you can press `LShift` + `RShift` + `Up` keys simultaneously.
88
89```
90----- Sun converter Help -----
91Up: Bell On
92Down: Bell Off
93Left: Click On
94Right: Click Off
95PgUp: LED all On
96PgDown: LED all On
97Insert: Layout
98Delete: Reset
99```
diff --git a/converter/sun_usb/command_extra.c b/converter/sun_usb/command_extra.c
index 50389467e..aba3fe6da 100644
--- a/converter/sun_usb/command_extra.c
+++ b/converter/sun_usb/command_extra.c
@@ -11,11 +11,19 @@ bool command_extra(uint8_t code)
11 case KC_H: 11 case KC_H:
12 case KC_SLASH: /* ? */ 12 case KC_SLASH: /* ? */
13 print("\n\n----- Sun converter Help -----\n"); 13 print("\n\n----- Sun converter Help -----\n");
14 print("UP: Bell On\n"); 14 print("Up: Bell On\n");
15 print("DOWN: Bell Off\n"); 15 print("Down: Bell Off\n");
16 print("LEFT: Click On\n"); 16 print("Left: Click On\n");
17 print("RIGHT: Click Off\n"); 17 print("Right: Click Off\n");
18 print("PgUp: LED all On\n");
19 print("PgDown: LED all On\n");
20 print("Insert: Layout\n");
21 print("Delete: Reset\n");
18 return false; 22 return false;
23 case KC_DEL:
24 print("Reset\n");
25 serial_send(0x01);
26 break;
19 case KC_UP: 27 case KC_UP:
20 print("Bell On\n"); 28 print("Bell On\n");
21 serial_send(0x02); 29 serial_send(0x02);
@@ -32,7 +40,17 @@ bool command_extra(uint8_t code)
32 print("Click Off\n"); 40 print("Click Off\n");
33 serial_send(0x0B); 41 serial_send(0x0B);
34 break; 42 break;
35 case KC_NUMLOCK: 43 case KC_PGUP:
44 print("LED all on\n");
45 serial_send(0x0E);
46 serial_send(0xFF);
47 break;
48 case KC_PGDOWN:
49 print("LED all off\n");
50 serial_send(0x0E);
51 serial_send(0x00);
52 break;
53 case KC_INSERT:
36 print("layout\n"); 54 print("layout\n");
37 serial_send(0x0F); 55 serial_send(0x0F);
38 break; 56 break;
diff --git a/converter/sun_usb/matrix.c b/converter/sun_usb/matrix.c
index 988622bc3..f333f542b 100644
--- a/converter/sun_usb/matrix.c
+++ b/converter/sun_usb/matrix.c
@@ -65,7 +65,7 @@ void matrix_init(void)
65{ 65{
66 DDRD |= (1<<6); 66 DDRD |= (1<<6);
67 PORTD |= (1<<6); 67 PORTD |= (1<<6);
68 debug_enable = true; 68 //debug_enable = true;
69 69
70 serial_init(); 70 serial_init();
71 71
@@ -86,14 +86,16 @@ uint8_t matrix_scan(void)
86 debug_hex(code); debug(" "); 86 debug_hex(code); debug(" ");
87 87
88 switch (code) { 88 switch (code) {
89 case 0x7E: // reset fail
90 case 0xFE: // layout
91 case 0xFF: // reset success 89 case 0xFF: // reset success
90 case 0xFE: // layout
91 case 0x7E: // reset fail
92 if (code == 0xFF) print("reset: 0xFF ");
93 if (code == 0x7E) print("reset fail: 0x7E ");
94 if (code == 0xFE) print("layout: 0xFE ");
95 // response byte
92 _delay_ms(500); 96 _delay_ms(500);
93 // ignore response byte 97 if (code = serial_recv()) print_hex8(code);
94 debug("(response ignored:"); 98 print("\n");
95 while ((code = serial_recv())) { debug(" "); debug_hex(code); }
96 debug(") ");
97 // FALL THROUGH 99 // FALL THROUGH
98 case 0x7F: 100 case 0x7F:
99 // all keys up 101 // all keys up
diff --git a/converter/usb_usb/README b/converter/usb_usb/README
index d0547cde9..a48937110 100644
--- a/converter/usb_usb/README
+++ b/converter/usb_usb/README
@@ -14,12 +14,8 @@ Build firmware
14-------------- 14--------------
15 $ git clone git://github.com/tmk/tmk_keyboard.git 15 $ git clone git://github.com/tmk/tmk_keyboard.git
16 $ cd tmk_keyboard 16 $ cd tmk_keyboard
17 $ git checkout usb_hid
18 $ git submodule init 17 $ git submodule init
19 $ git submodule update 18 $ git submodule update
20
21and download LUFA and unzip under protocol/lufa and edit LUFA_PATH in protocol/lufa.mk. Then,
22
23 $ cd converter/usb_usb 19 $ cd converter/usb_usb
24 $ make 20 $ make
25 21
diff --git a/converter/usb_usb/config.h b/converter/usb_usb/config.h
index ecf4ed9b1..d614973f7 100644
--- a/converter/usb_usb/config.h
+++ b/converter/usb_usb/config.h
@@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33#define MATRIX_ROWS 32 33#define MATRIX_ROWS 32
34#define MATRIX_COLS 8 34#define MATRIX_COLS 8
35 35
36#define USE_LEGACY_KEYMAP
36 37
37/* key combination for command */ 38/* key combination for command */
38#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) 39#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp
index 46c728e9b..20b7af66a 100644
--- a/converter/usb_usb/main.cpp
+++ b/converter/usb_usb/main.cpp
@@ -59,7 +59,6 @@ int main(void)
59 LED_TX_INIT; 59 LED_TX_INIT;
60 LED_TX_ON; 60 LED_TX_ON;
61 61
62 print_enable = true;
63 debug_enable = true; 62 debug_enable = true;
64 debug_matrix = true; 63 debug_matrix = true;
65 debug_keyboard = true; 64 debug_keyboard = true;
diff --git a/doc/keymap.md b/doc/keymap.md
index 11feeac21..9d986a8c5 100644
--- a/doc/keymap.md
+++ b/doc/keymap.md
@@ -497,6 +497,13 @@ Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by def
497 497
498 498
499 499
500### 3.5 Momentary switching with Modifiers
501This registers modifier key(s) simultaneously with layer switching.
502
503 ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
504
505
506
500## 4. Tapping 507## 4. Tapping
501Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default. 508Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.
502 509
diff --git a/keyboard/lightpad/Makefile.lufa b/keyboard/lightpad/Makefile.lufa
new file mode 100644
index 000000000..7bce7ebff
--- /dev/null
+++ b/keyboard/lightpad/Makefile.lufa
@@ -0,0 +1,117 @@
1#----------------------------------------------------------------------------
2# On command line:
3#
4# make all = Make software.
5#
6# make clean = Clean out built project files.
7#
8# make coff = Convert ELF to AVR COFF.
9#
10# make extcoff = Convert ELF to AVR Extended COFF.
11#
12# make program = Download the hex file to the device.
13# Please customize your programmer settings(PROGRAM_CMD)
14#
15# make teensy = Download the hex file to the device, using teensy_loader_cli.
16# (must have teensy_loader_cli installed).
17#
18# make dfu = Download the hex file to the device, using dfu-programmer (must
19# have dfu-programmer installed).
20#
21# make flip = Download the hex file to the device, using Atmel FLIP (must
22# have Atmel FLIP installed).
23#
24# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
25# (must have dfu-programmer installed).
26#
27# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
28# (must have Atmel FLIP installed).
29#
30# make debug = Start either simulavr or avarice as specified for debugging,
31# with avr-gdb or avr-insight as the front end for debugging.
32#
33# make filename.s = Just compile filename.c into the assembler code only.
34#
35# make filename.i = Create a preprocessed source file for use in submitting
36# bug reports to the GCC project.
37#
38# To rebuild project do "make clean" then "make all".
39#----------------------------------------------------------------------------
40
41# Target file name (without extension).
42TARGET = lightpad_lufa
43
44# Directory common source filess exist
45TOP_DIR = ../..
46
47# Directory keyboard dependent files exist
48TARGET_DIR = .
49
50# List C source files here. (C dependencies are automatically generated.)
51SRC = keymap.c \
52 matrix.c \
53 led.c \
54 backlight.c
55
56CONFIG_H = config.h
57
58# MCU name
59MCU = atmega32u4
60
61# Processor frequency.
62# This will define a symbol, F_CPU, in all source code files equal to the
63# processor frequency in Hz. You can then use this symbol in your source code to
64# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
65# automatically to create a 32-bit value in your source code.
66#
67# This will be an integer division of F_USB below, as it is sourced by
68# F_USB after it has run through any CPU prescalers. Note that this value
69# does not *change* the processor frequency - it should merely be updated to
70# reflect the processor speed set externally so that the code can use accurate
71# software delays.
72F_CPU = 8000000
73
74#
75# LUFA specific
76#
77# Target architecture (see library "Board Types" documentation).
78ARCH = AVR8
79
80# Input clock frequency.
81# This will define a symbol, F_USB, in all source code files equal to the
82# input clock frequency (before any prescaling is performed) in Hz. This value may
83# differ from F_CPU if prescaling is used on the latter, and is required as the
84# raw input clock is fed directly to the PLL sections of the AVR for high speed
85# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
86# at the end, this will be done automatically to create a 32-bit value in your
87# source code.
88#
89# If no clock division is performed on the input clock inside the AVR (via the
90# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
91F_USB = $(F_CPU)
92
93# Build Options
94# comment out to disable the options.
95#
96BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
97#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
98EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
99#CONSOLE_ENABLE = yes # Console for debug(+400)
100#COMMAND_ENABLE = yes # Commands for debug and configuration
101#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
102#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
103BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
104
105# Boot Section Size in bytes
106# Teensy halfKay 512
107# Atmel DFU loader 4096
108# LUFA bootloader 4096
109OPT_DEFS += -DBOOTLOADER_SIZE=4096
110
111# Search Path
112VPATH += $(TARGET_DIR)
113VPATH += $(TOP_DIR)
114
115include $(TOP_DIR)/protocol/lufa.mk
116include $(TOP_DIR)/common.mk
117include $(TOP_DIR)/rules.mk
diff --git a/keyboard/lightpad/README.md b/keyboard/lightpad/README.md
new file mode 100644
index 000000000..b21cccc6a
--- /dev/null
+++ b/keyboard/lightpad/README.md
@@ -0,0 +1,24 @@
1Lightpad keypad firmware
2======================
3Korean custom keypad designed by Duck.
4
5*Note that this is not the official firmware*
6
7
8Supported models
9----------------
10All pcb options are supported.
11
12
13Build
14-----
15Move to this directory then just run `make` like:
16
17 $ make -f Makefile.lufa
18
19
20Bootloader
21---------
22The PCB is hardwired to run the bootloader if the key at the `top left` position is held down when connecting the keyboard.
23
24It is still possible to use Boot Magic and Command to access the bootloader though.
diff --git a/keyboard/lightpad/backlight.c b/keyboard/lightpad/backlight.c
new file mode 100644
index 000000000..693c566fc
--- /dev/null
+++ b/keyboard/lightpad/backlight.c
@@ -0,0 +1,129 @@
1/*
2Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <avr/io.h>
19#include "backlight.h"
20
21/* Backlight pin configuration
22 *
23 * FN1 PB0 (low)
24 * FN2 PB5 (low)
25 * FN3 PB4 (low)
26 * FN4 PD7 (low)
27 * REAR PD6 (high)
28 * NUMPAD PB2 (high)
29 * NUMLOCK PB1 (low)
30 */
31void backlight_init_ports() {
32 DDRB |= (1<<0) | (1<<1) | (1<<2) | (1<<4) | (1<<5);
33 DDRD |= (1<<6) | (1<<7);
34
35 backlight_disable_numlock();
36}
37
38void backlight_set(uint8_t level) {
39 (level & BACKLIGHT_FN1) ? backlight_enable_fn1() : backlight_disable_fn1();
40 (level & BACKLIGHT_FN2) ? backlight_enable_fn2() : backlight_disable_fn2();
41 (level & BACKLIGHT_FN3) ? backlight_enable_fn3() : backlight_disable_fn3();
42 (level & BACKLIGHT_FN4) ? backlight_enable_fn4() : backlight_disable_fn4();
43 (level & BACKLIGHT_NUMPAD) ? backlight_enable_numpad() : backlight_disable_numpad();
44 (level & BACKLIGHT_REAR) ? backlight_enable_rear() : backlight_disable_rear();
45}
46
47void backlight_enable_fn1() {
48 PORTB &= ~(1<<0);
49}
50
51void backlight_disable_fn1() {
52 PORTB |= (1<<0);
53}
54
55void backlight_invert_fn1() {
56 PORTB ^= (1<<0);
57}
58
59void backlight_enable_fn2() {
60 PORTB &= ~(1<<5);
61}
62
63void backlight_disable_fn2() {
64 PORTB |= (1<<5);
65}
66
67void backlight_invert_fn2() {
68 PORTB ^= (1<<5);
69}
70
71void backlight_enable_fn3() {
72 PORTB &= ~(1<<4);
73}
74
75void backlight_disable_fn3() {
76 PORTB |= (1<<4);
77}
78
79void backlight_invert_fn3() {
80 PORTB ^= (1<<4);
81}
82
83void backlight_enable_fn4() {
84 PORTD &= ~(1<<7);
85}
86
87void backlight_disable_fn4() {
88 PORTD |= (1<<7);
89}
90
91void backlight_invert_fn4() {
92 PORTD ^= (1<<7);
93}
94
95void backlight_enable_numpad() {
96 PORTB |= (1<<2);
97}
98
99void backlight_disable_numpad() {
100 PORTB &= ~(1<<2);
101}
102
103void backlight_invert_numpad() {
104 PORTB ^= (1<<2);
105}
106
107void backlight_enable_numlock() {
108 PORTB &= ~(1<<1);
109}
110
111void backlight_disable_numlock() {
112 PORTB |= (1<<1);
113}
114
115void backlight_invert_numlock() {
116 PORTB ^= (1<<1);
117}
118
119void backlight_enable_rear() {
120 PORTD |= (1<<6);
121}
122
123void backlight_disable_rear() {
124 PORTD &= ~(1<<6);
125}
126
127void backlight_invert_rear() {
128 PORTD ^= (1<<6);
129}
diff --git a/keyboard/lightpad/backlight.h b/keyboard/lightpad/backlight.h
new file mode 100644
index 000000000..3b3cfd9ae
--- /dev/null
+++ b/keyboard/lightpad/backlight.h
@@ -0,0 +1,39 @@
1
2enum backlight_level {
3 BACKLIGHT_FN1 = 0b0000001,
4 BACKLIGHT_FN2 = 0b0000010,
5 BACKLIGHT_FN3 = 0b0000100,
6 BACKLIGHT_FN4 = 0b0001000,
7 BACKLIGHT_NUMPAD = 0b0010000,
8 BACKLIGHT_REAR = 0b0100000,
9};
10
11void backlight_init_ports(void);
12
13void backlight_invert_fn1(void);
14void backlight_enable_fn1(void);
15void backlight_disable_fn1(void);
16
17void backlight_invert_fn2(void);
18void backlight_enable_fn2(void);
19void backlight_disable_fn2(void);
20
21void backlight_invert_fn3(void);
22void backlight_enable_fn3(void);
23void backlight_disable_fn3(void);
24
25void backlight_invert_fn4(void);
26void backlight_enable_fn4(void);
27void backlight_disable_fn4(void);
28
29void backlight_invert_numlock(void);
30void backlight_enable_numlock(void);
31void backlight_disable_numlock(void);
32
33void backlight_enable_numpad(void);
34void backlight_disable_numpad(void);
35void backlight_invert_numpad(void);
36
37void backlight_enable_rear(void);
38void backlight_disable_rear(void);
39void backlight_invert_rear(void);
diff --git a/keyboard/lightpad/config.h b/keyboard/lightpad/config.h
new file mode 100644
index 000000000..7f5a596c0
--- /dev/null
+++ b/keyboard/lightpad/config.h
@@ -0,0 +1,46 @@
1/*
2Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x6050
24#define DEVICE_VER 0x0104
25#define MANUFACTURER Duck
26#define PRODUCT Lightpad
27
28/* message strings */
29#define DESCRIPTION t.m.k. keyboard firmware for Lightpad
30
31/* matrix size */
32#define MATRIX_ROWS 6
33#define MATRIX_COLS 4
34
35/* number of backlight levels */
36#define BACKLIGHT_LEVELS 1
37
38/* Set 0 if need no debouncing */
39#define DEBOUNCE 5
40
41/* key combination for command */
42#define IS_COMMAND() ( \
43 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
44)
45
46#endif
diff --git a/keyboard/lightpad/keymap.c b/keyboard/lightpad/keymap.c
new file mode 100644
index 000000000..6d078230b
--- /dev/null
+++ b/keyboard/lightpad/keymap.c
@@ -0,0 +1,73 @@
1/*
2Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <stdbool.h>
20#include <avr/pgmspace.h>
21#include "keycode.h"
22#include "action.h"
23#include "action_macro.h"
24#include "report.h"
25#include "host.h"
26#include "debug.h"
27#include "keymap.h"
28
29/* Map physical keyboard layout to matrix array */
30#define KEYMAP( \
31 K5A, K5B, K5C, K5D, \
32 K4A, K4B, K4C, K4D, \
33 K3A, K3B, K3C, K3D, \
34 K2A, K2B, K2C, \
35 K1A, K1B, K1C, K1D, \
36 K0A, K0B, K0C \
37) { \
38/* 0 1 2 3 */ \
39/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D}, \
40/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D}, \
41/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D}, \
42/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_NO}, \
43/* 1 */ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D}, \
44/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, } \
45}
46
47#include "keymap_lightpad.h"
48
49#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
50#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
51
52/* translates key to keycode */
53uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
54{
55 if (layer < KEYMAPS_SIZE) {
56 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
57 } else {
58 // fall back to layer 0
59 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
60 }
61}
62
63/* translates Fn keycode to action */
64action_t keymap_fn_to_action(uint8_t keycode)
65{
66 action_t action;
67 if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
68 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
69 } else {
70 action.code = ACTION_NO;
71 }
72 return action;
73}
diff --git a/keyboard/lightpad/keymap_lightpad.h b/keyboard/lightpad/keymap_lightpad.h
new file mode 100644
index 000000000..9333964e3
--- /dev/null
+++ b/keyboard/lightpad/keymap_lightpad.h
@@ -0,0 +1,29 @@
1#include "backlight.h"
2
3static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
4 KEYMAP(\
5 FN0, F1, DEL, BSPC, \
6 NLCK,PSLS,PAST,PMNS, \
7 P7, P8, P9, PPLS, \
8 P4, P5, P6, \
9 P1, P2, P3, PENT, \
10 P0, NO, PDOT), \
11 KEYMAP(\
12 TRNS,PGDN,PGUP,MUTE, \
13 MSEL,MPRV,MNXT,VOLD, \
14 P7, P8, P9, VOLU, \
15 FN4, FN5, FN6, \
16 FN1, FN2, FN3, MPLY, \
17 FN7, NO, MSTP)
18};
19
20static const uint16_t PROGMEM fn_actions[] = {
21 [0] = ACTION_LAYER_MOMENTARY(1),
22 [1] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN1),
23 [2] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN2),
24 [3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN3),
25 [4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN4),
26 [5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_NUMPAD),
27 [6] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_REAR),
28 [7] = ACTION_BACKLIGHT_TOGGLE()
29};
diff --git a/keyboard/lightpad/led.c b/keyboard/lightpad/led.c
new file mode 100644
index 000000000..ebfac3af8
--- /dev/null
+++ b/keyboard/lightpad/led.c
@@ -0,0 +1,24 @@
1/*
2Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <avr/io.h>
19#include "stdint.h"
20#include "led.h"
21
22void led_set(uint8_t usb_led) {
23 (usb_led & (1<<USB_LED_NUM_LOCK)) ? backlight_enable_numlock() : backlight_disable_numlock();
24}
diff --git a/keyboard/lightpad/matrix.c b/keyboard/lightpad/matrix.c
new file mode 100644
index 000000000..87d338395
--- /dev/null
+++ b/keyboard/lightpad/matrix.c
@@ -0,0 +1,205 @@
1/*
2Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <stdbool.h>
20#include <avr/io.h>
21#include <util/delay.h>
22#include "print.h"
23#include "debug.h"
24#include "util.h"
25#include "matrix.h"
26#include "eeconfig.h"
27#include "action_layer.h"
28#include "backlight.h"
29
30#ifndef DEBOUNCE
31# define DEBOUNCE 0
32#endif
33static uint8_t debouncing = DEBOUNCE;
34
35static matrix_row_t matrix[MATRIX_ROWS];
36static matrix_row_t matrix_debouncing[MATRIX_ROWS];
37
38static uint8_t read_rows(void);
39static uint8_t read_fwkey(void);
40static void init_rows(void);
41static void unselect_cols(void);
42static void select_col(uint8_t col);
43
44inline
45uint8_t matrix_rows(void)
46{
47 return MATRIX_ROWS;
48}
49
50inline
51uint8_t matrix_cols(void)
52{
53 return MATRIX_COLS;
54}
55
56void misc_init(void) {
57}
58
59void matrix_init(void)
60{
61 backlight_init_ports();
62 unselect_cols();
63 init_rows();
64 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
65 matrix[i] = 0;
66 matrix_debouncing[i] = 0;
67 }
68}
69
70uint8_t matrix_scan(void)
71{
72 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
73 select_col(col);
74 _delay_us(3);
75 uint8_t rows = read_rows();
76 // Use the otherwise unused col: 0 row: 0 for firmware key
77 if(col == 0) {
78 rows |= read_fwkey();
79 }
80 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
81 bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
82 bool curr_bit = rows & (1<<row);
83 if (prev_bit != curr_bit) {
84 matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
85 if (debouncing) {
86 dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
87 }
88 debouncing = DEBOUNCE;
89 }
90 }
91 unselect_cols();
92 }
93
94 if (debouncing) {
95 if (--debouncing) {
96 _delay_ms(1);
97 } else {
98 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
99 matrix[i] = matrix_debouncing[i];
100 }
101 }
102 }
103
104 return 1;
105}
106
107bool matrix_is_modified(void)
108{
109 if (debouncing) return false;
110 return true;
111}
112
113inline
114bool matrix_is_on(uint8_t row, uint8_t col)
115{
116 return (matrix[row] & ((matrix_row_t)1<<col));
117}
118
119inline
120matrix_row_t matrix_get_row(uint8_t row)
121{
122 return matrix[row];
123}
124
125void matrix_print(void)
126{
127 print("\nr/c 0123456789ABCDEF\n");
128 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
129 xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
130 }
131}
132
133uint8_t matrix_key_count(void)
134{
135 uint8_t count = 0;
136 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
137 count += bitpop32(matrix[i]);
138 }
139 return count;
140}
141
142/* Row configuration
143 *
144 * row: 0 1 2 3 4 5
145 * pin: PD0 PD1 PD2 PD3 PD5 PB7
146 *
147 * Firmware uses pin PE2
148 */
149static void init_rows(void)
150{
151 DDRD &= ~0b00101111;
152 PORTD |= 0b00101111;
153
154 DDRB &= ~0b10000000;
155 PORTB |= 0b10000000;
156
157 DDRE &= ~0b00000100;
158 PORTE |= 0b00000100;
159}
160
161static uint8_t read_rows(void)
162{
163 return (PIND&(1<<0) ? (1<<0) : 0) |
164 (PIND&(1<<1) ? (1<<1) : 0) |
165 (PIND&(1<<2) ? (1<<2) : 0) |
166 (PIND&(1<<3) ? (1<<3) : 0) |
167 (PIND&(1<<5) ? (1<<4) : 0) |
168 (PINB&(1<<7) ? (1<<5) : 0);
169}
170
171static uint8_t read_fwkey(void)
172{
173 return PINE&(1<<2) ? 0 : (1<<0);
174}
175
176/* Column configuration
177 *
178 * col: 0 1 2 3
179 * pin: PF0 PF1 PC7 PC6
180 */
181static void unselect_cols(void)
182{
183 DDRF |= 0b00000011;
184 PORTF &= ~0b00000011;
185 DDRC |= 0b11000000;
186 PORTC &= ~0b11000000;
187}
188
189static void select_col(uint8_t col)
190{
191 switch (col) {
192 case 0:
193 PORTF |= (1<<0);
194 break;
195 case 1:
196 PORTF |= (1<<1);
197 break;
198 case 2:
199 PORTC |= (1<<7);
200 break;
201 case 3:
202 PORTC |= (1<<6);
203 break;
204 }
205}
diff --git a/protocol.mk b/protocol.mk
index ca435ba43..e057d1d60 100644
--- a/protocol.mk
+++ b/protocol.mk
@@ -24,5 +24,25 @@ ifdef PS2_USE_USART
24endif 24endif
25 25
26 26
27ifdef SERIAL_MOUSE_MICROSOFT_ENABLE
28 SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
29 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
30 -DMOUSE_ENABLE
31endif
32
33ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE
34 SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
35 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
36 -DMOUSE_ENABLE
37endif
38
39ifdef SERIAL_MOUSE_USE_SOFT
40 SRC += $(PROTOCOL_DIR)/serial_soft.c
41endif
42
43ifdef SERIAL_MOUSE_USE_UART
44 SRC += $(PROTOCOL_DIR)/serial_uart.c
45endif
46
27# Search Path 47# Search Path
28VPATH += $(TOP_DIR)/protocol 48VPATH += $(TOP_DIR)/protocol
diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c
index d16833187..758a4edc6 100644
--- a/protocol/pjrc/usb_keyboard.c
+++ b/protocol/pjrc/usb_keyboard.c
@@ -39,7 +39,7 @@ uint8_t keyboard_protocol=1;
39// the idle configuration, how often we send the report to the 39// the idle configuration, how often we send the report to the
40// host (ms * 4) even when it hasn't changed 40// host (ms * 4) even when it hasn't changed
41// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request. 41// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request.
42uint8_t keyobard_idle=125; 42uint8_t keyboard_idle=125;
43 43
44// count until idle timeout 44// count until idle timeout
45uint8_t usb_keyboard_idle_count=0; 45uint8_t usb_keyboard_idle_count=0;
diff --git a/protocol/serial_mouse.h b/protocol/serial_mouse.h
new file mode 100644
index 000000000..226314fc0
--- /dev/null
+++ b/protocol/serial_mouse.h
@@ -0,0 +1,33 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef SERIAL_MOUSE_H
19#define SERIAL_MOUSE_H
20
21#include <stdint.h>
22
23#include "serial.h"
24
25static inline uint8_t serial_mouse_init(void)
26{
27 serial_init();
28 return 0;
29}
30
31void serial_mouse_task(void);
32
33#endif
diff --git a/protocol/serial_mouse_microsoft.c b/protocol/serial_mouse_microsoft.c
new file mode 100644
index 000000000..ab74b7cdd
--- /dev/null
+++ b/protocol/serial_mouse_microsoft.c
@@ -0,0 +1,124 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <avr/io.h>
20#include <util/delay.h>
21
22#include "serial.h"
23#include "serial_mouse.h"
24#include "report.h"
25#include "host.h"
26#include "timer.h"
27#include "print.h"
28#include "debug.h"
29
30#ifdef MAX
31#undef MAX
32#endif
33#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
34
35static void print_usb_data(const report_mouse_t *report);
36
37void serial_mouse_task(void)
38{
39 /* 3 byte ring buffer */
40 static uint8_t buffer[3];
41 static int buffer_cur = 0;
42
43 static report_mouse_t report = {};
44
45 int16_t rcv;
46
47 rcv = serial_recv2();
48 if (rcv < 0)
49 /* no new data */
50 return;
51
52 if (debug_mouse)
53 xprintf("serial_mouse: byte: %04X\n", rcv);
54
55 /*
56 * If bit 6 is one, this signals the beginning
57 * of a 3 byte sequence/packet.
58 */
59 if (rcv & (1 << 6))
60 buffer_cur = 0;
61
62 buffer[buffer_cur] = (uint8_t)rcv;
63
64 if (buffer_cur == 0 && buffer[buffer_cur] == 0x20) {
65 /*
66 * Logitech extension: This must be a follow-up on
67 * the last 3-byte packet signaling a middle button click
68 */
69 report.buttons |= MOUSE_BTN3;
70 report.x = report.y = 0;
71
72 print_usb_data(&report);
73 host_mouse_send(&report);
74 return;
75 }
76
77 buffer_cur++;
78
79 if (buffer_cur < 3)
80 return;
81 buffer_cur = 0;
82
83 /*
84 * parse 3 byte packet.
85 * NOTE: We only get a complete packet
86 * if the mouse moved or the button states
87 * change.
88 */
89 report.buttons = 0;
90 if (buffer[0] & (1 << 5))
91 report.buttons |= MOUSE_BTN1;
92 if (buffer[0] & (1 << 4))
93 report.buttons |= MOUSE_BTN2;
94
95 report.x = (buffer[0] << 6) | buffer[1];
96 report.y = ((buffer[0] << 4) & 0xC0) | buffer[2];
97
98 /* USB HID uses values from -127 to 127 only */
99 report.x = MAX(report.x, -127);
100 report.y = MAX(report.y, -127);
101
102#if 0
103 if (!report.buttons && !report.x && !report.y) {
104 /*
105 * Microsoft extension: Middle mouse button pressed
106 * FIXME: I don't know how exactly this extension works.
107 */
108 report.buttons |= MOUSE_BTN3;
109 }
110#endif
111
112 print_usb_data(&report);
113 host_mouse_send(&report);
114}
115
116static void print_usb_data(const report_mouse_t *report)
117{
118 if (!debug_mouse)
119 return;
120
121 xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n",
122 report->buttons, report->x, report->y,
123 report->v, report->h);
124}
diff --git a/protocol/serial_mouse_mousesystems.c b/protocol/serial_mouse_mousesystems.c
new file mode 100644
index 000000000..cfe899621
--- /dev/null
+++ b/protocol/serial_mouse_mousesystems.c
@@ -0,0 +1,131 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <avr/io.h>
20#include <util/delay.h>
21
22#include "serial.h"
23#include "serial_mouse.h"
24#include "report.h"
25#include "host.h"
26#include "timer.h"
27#include "print.h"
28#include "debug.h"
29
30#ifdef MAX
31#undef MAX
32#endif
33#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
34
35//#define SERIAL_MOUSE_CENTER_SCROLL
36
37static void print_usb_data(const report_mouse_t *report);
38
39void serial_mouse_task(void)
40{
41 /* 5 byte ring buffer */
42 static uint8_t buffer[5];
43 static int buffer_cur = 0;
44
45 int16_t rcv;
46
47 report_mouse_t report = {0, 0, 0, 0, 0};
48
49 rcv = serial_recv2();
50 if (rcv < 0)
51 /* no new data */
52 return;
53
54 if (debug_mouse)
55 xprintf("serial_mouse: byte: %04X\n", rcv);
56
57 /*
58 * Synchronization: mouse(4) says that all
59 * bytes but the first one in the packet have
60 * bit 7 == 0, but this is untrue.
61 * Therefore we discard all bytes up to the
62 * first one with the characteristic bit pattern.
63 */
64 if (buffer_cur == 0 && (rcv >> 3) != 0x10)
65 return;
66
67 buffer[buffer_cur++] = (uint8_t)rcv;
68
69 if (buffer_cur < 5)
70 return;
71 buffer_cur = 0;
72
73#ifdef SERIAL_MOUSE_CENTER_SCROLL
74 if ((buffer[0] & 0x7) == 0x5 && (buffer[1] || buffer[2])) {
75 /* USB HID uses only values from -127 to 127 */
76 report.h = MAX((int8_t)buffer[1], -127);
77 report.v = MAX((int8_t)buffer[2], -127);
78
79 print_usb_data(&report);
80 host_mouse_send(&report);
81
82 if (buffer[3] || buffer[4]) {
83 report.h = MAX((int8_t)buffer[3], -127);
84 report.v = MAX((int8_t)buffer[4], -127);
85
86 print_usb_data(&report);
87 host_mouse_send(&report);
88 }
89
90 return;
91 }
92#endif
93
94 /*
95 * parse 5 byte packet.
96 * NOTE: We only get a complete packet
97 * if the mouse moved or the button states
98 * change.
99 */
100 if (!(buffer[0] & (1 << 2)))
101 report.buttons |= MOUSE_BTN1;
102 if (!(buffer[0] & (1 << 1)))
103 report.buttons |= MOUSE_BTN3;
104 if (!(buffer[0] & (1 << 0)))
105 report.buttons |= MOUSE_BTN2;
106
107 /* USB HID uses only values from -127 to 127 */
108 report.x = MAX((int8_t)buffer[1], -127);
109 report.y = MAX(-(int8_t)buffer[2], -127);
110
111 print_usb_data(&report);
112 host_mouse_send(&report);
113
114 if (buffer[3] || buffer[4]) {
115 report.x = MAX((int8_t)buffer[3], -127);
116 report.y = MAX(-(int8_t)buffer[4], -127);
117
118 print_usb_data(&report);
119 host_mouse_send(&report);
120 }
121}
122
123static void print_usb_data(const report_mouse_t *report)
124{
125 if (!debug_mouse)
126 return;
127
128 xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n",
129 report->buttons, report->x, report->y,
130 report->v, report->h);
131}
diff --git a/protocol/serial_soft.c b/protocol/serial_soft.c
index e8870bcd7..44822b7e4 100644
--- a/protocol/serial_soft.c
+++ b/protocol/serial_soft.c
@@ -122,7 +122,11 @@ void serial_send(uint8_t data)
122 /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */ 122 /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */
123 123
124#ifdef SERIAL_SOFT_BIT_ORDER_MSB 124#ifdef SERIAL_SOFT_BIT_ORDER_MSB
125 #ifdef SERIAL_SOFT_DATA_7BIT
126 uint8_t mask = 0x40;
127 #else
125 uint8_t mask = 0x80; 128 uint8_t mask = 0x80;
129 #endif
126#else 130#else
127 uint8_t mask = 0x01; 131 uint8_t mask = 0x01;
128#endif 132#endif
@@ -133,7 +137,11 @@ void serial_send(uint8_t data)
133 SERIAL_SOFT_TXD_OFF(); 137 SERIAL_SOFT_TXD_OFF();
134 _delay_us(WAIT_US); 138 _delay_us(WAIT_US);
135 139
136 while (mask) { 140#ifdef SERIAL_SOFT_DATA_7BIT
141 while (mask&0x7F) {
142#else
143 while (mask&0xFF) {
144#endif
137 if (data&mask) { 145 if (data&mask) {
138 SERIAL_SOFT_TXD_ON(); 146 SERIAL_SOFT_TXD_ON();
139 parity ^= 1; 147 parity ^= 1;
@@ -173,7 +181,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
173 uint8_t data = 0; 181 uint8_t data = 0;
174 182
175#ifdef SERIAL_SOFT_BIT_ORDER_MSB 183#ifdef SERIAL_SOFT_BIT_ORDER_MSB
184 #ifdef SERIAL_SOFT_DATA_7BIT
185 uint8_t mask = 0x40;
186 #else
176 uint8_t mask = 0x80; 187 uint8_t mask = 0x80;
188 #endif
177#else 189#else
178 uint8_t mask = 0x01; 190 uint8_t mask = 0x01;
179#endif 191#endif
@@ -197,7 +209,11 @@ ISR(SERIAL_SOFT_RXD_VECT)
197#else 209#else
198 mask <<= 1; 210 mask <<= 1;
199#endif 211#endif
200 } while (mask); 212#ifdef SERIAL_SOFT_DATA_7BIT
213 } while (mask&0x7F);
214#else
215 } while (mask&0xFF);
216#endif
201 217
202#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) 218#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD)
203 /* to center of parity bit */ 219 /* to center of parity bit */
diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h
index d76d2a33d..947325e5f 100644
--- a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h
+++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h
@@ -35,7 +35,7 @@
35// -std=c++0x 35// -std=c++0x
36 36
37class __FlashStringHelper; 37class __FlashStringHelper;
38#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal))) 38#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
39 39
40// An inherited class for holding the result of a concatenation. These 40// An inherited class for holding the result of a concatenation. These
41// result objects are assumed to be writable by subsequent concatenations. 41// result objects are assumed to be writable by subsequent concatenations.
diff --git a/protocol/usb_hid/override_wiring.c b/protocol/usb_hid/override_wiring.c
index 3b3f5e302..1e9a94ce2 100644
--- a/protocol/usb_hid/override_wiring.c
+++ b/protocol/usb_hid/override_wiring.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * To keep Timer0 for common/timer.c override arduino/wiring.c. 2 * To keep Timer0 for common/timer.c override arduino/wiring.c.
3 */ 3 */
4#define __DELAY_BACKWARD_COMPATIBLE__
4#include <util/delay.h> 5#include <util/delay.h>
5#include "common/timer.h" 6#include "common/timer.h"
6#include "Arduino.h" 7#include "Arduino.h"
diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp
index 66e949518..28151f9d5 100644
--- a/protocol/usb_hid/parser.cpp
+++ b/protocol/usb_hid/parser.cpp
@@ -1,5 +1,3 @@
1#include <cstring.h>
2
3#include "parser.h" 1#include "parser.h"
4#include "usb_hid.h" 2#include "usb_hid.h"
5 3
diff --git a/protocol/vusb/usbdrv/usbdrv.c b/protocol/vusb/usbdrv/usbdrv.c
index 21ed554f8..2e8dd8756 100644
--- a/protocol/vusb/usbdrv/usbdrv.c
+++ b/protocol/vusb/usbdrv/usbdrv.c
@@ -67,7 +67,7 @@ optimizing hints:
67#if USB_CFG_DESCR_PROPS_STRING_0 == 0 67#if USB_CFG_DESCR_PROPS_STRING_0 == 0
68#undef USB_CFG_DESCR_PROPS_STRING_0 68#undef USB_CFG_DESCR_PROPS_STRING_0
69#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0) 69#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
70PROGMEM char usbDescriptorString0[] = { /* language descriptor */ 70const PROGMEM char usbDescriptorString0[] = { /* language descriptor */
71 4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */ 71 4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
72 3, /* descriptor type */ 72 3, /* descriptor type */
73 0x09, 0x04, /* language index (0x0409 = US-English) */ 73 0x09, 0x04, /* language index (0x0409 = US-English) */
@@ -77,7 +77,7 @@ PROGMEM char usbDescriptorString0[] = { /* language descriptor */
77#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN 77#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
78#undef USB_CFG_DESCR_PROPS_STRING_VENDOR 78#undef USB_CFG_DESCR_PROPS_STRING_VENDOR
79#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor) 79#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
80PROGMEM int usbDescriptorStringVendor[] = { 80const PROGMEM int usbDescriptorStringVendor[] = {
81 USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN), 81 USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
82 USB_CFG_VENDOR_NAME 82 USB_CFG_VENDOR_NAME
83}; 83};
@@ -86,7 +86,7 @@ PROGMEM int usbDescriptorStringVendor[] = {
86#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN 86#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN
87#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT 87#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT
88#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice) 88#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice)
89PROGMEM int usbDescriptorStringDevice[] = { 89const PROGMEM int usbDescriptorStringDevice[] = {
90 USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN), 90 USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
91 USB_CFG_DEVICE_NAME 91 USB_CFG_DEVICE_NAME
92}; 92};
@@ -108,7 +108,7 @@ PROGMEM int usbDescriptorStringSerialNumber[] = {
108#if USB_CFG_DESCR_PROPS_DEVICE == 0 108#if USB_CFG_DESCR_PROPS_DEVICE == 0
109#undef USB_CFG_DESCR_PROPS_DEVICE 109#undef USB_CFG_DESCR_PROPS_DEVICE
110#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice) 110#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
111PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */ 111const PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
112 18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */ 112 18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
113 USBDESCR_DEVICE, /* descriptor type */ 113 USBDESCR_DEVICE, /* descriptor type */
114 0x10, 0x01, /* USB version supported */ 114 0x10, 0x01, /* USB version supported */
diff --git a/protocol/vusb/usbdrv/usbdrv.h b/protocol/vusb/usbdrv/usbdrv.h
index 3a78f307b..42fe16372 100644
--- a/protocol/vusb/usbdrv/usbdrv.h
+++ b/protocol/vusb/usbdrv/usbdrv.h
@@ -452,43 +452,43 @@ extern
452#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM) 452#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
453PROGMEM 453PROGMEM
454#endif 454#endif
455char usbDescriptorDevice[]; 455const char usbDescriptorDevice[];
456 456
457extern 457extern
458#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM) 458#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
459PROGMEM 459PROGMEM
460#endif 460#endif
461char usbDescriptorConfiguration[]; 461const char usbDescriptorConfiguration[];
462 462
463extern 463extern
464#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM) 464#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
465PROGMEM 465PROGMEM
466#endif 466#endif
467char usbDescriptorHidReport[]; 467const char usbDescriptorHidReport[];
468 468
469extern 469extern
470#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM) 470#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
471PROGMEM 471PROGMEM
472#endif 472#endif
473char usbDescriptorString0[]; 473const char usbDescriptorString0[];
474 474
475extern 475extern
476#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM) 476#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
477PROGMEM 477PROGMEM
478#endif 478#endif
479int usbDescriptorStringVendor[]; 479const int usbDescriptorStringVendor[];
480 480
481extern 481extern
482#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM) 482#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
483PROGMEM 483PROGMEM
484#endif 484#endif
485int usbDescriptorStringDevice[]; 485const int usbDescriptorStringDevice[];
486 486
487extern 487extern
488#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM) 488#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
489PROGMEM 489PROGMEM
490#endif 490#endif
491int usbDescriptorStringSerialNumber[]; 491const int usbDescriptorStringSerialNumber[];
492 492
493#endif /* __ASSEMBLER__ */ 493#endif /* __ASSEMBLER__ */
494 494
diff --git a/protocol/vusb/vusb.c b/protocol/vusb/vusb.c
index 328885a9b..7d0292ed1 100644
--- a/protocol/vusb/vusb.c
+++ b/protocol/vusb/vusb.c
@@ -35,6 +35,13 @@ static report_keyboard_t kbuf[KBUF_SIZE];
35static uint8_t kbuf_head = 0; 35static uint8_t kbuf_head = 0;
36static uint8_t kbuf_tail = 0; 36static uint8_t kbuf_tail = 0;
37 37
38typedef struct {
39 uint8_t modifier;
40 uint8_t reserved;
41 uint8_t keycode[6];
42} keyboard_report_t;
43
44static keyboard_report_t keyboard_report; // sent to PC
38 45
39/* transfer keyboard report from buffer */ 46/* transfer keyboard report from buffer */
40void vusb_transfer_keyboard(void) 47void vusb_transfer_keyboard(void)
@@ -168,8 +175,8 @@ usbRequest_t *rq = (void *)data;
168 if(rq->bRequest == USBRQ_HID_GET_REPORT){ 175 if(rq->bRequest == USBRQ_HID_GET_REPORT){
169 debug("GET_REPORT:"); 176 debug("GET_REPORT:");
170 /* we only have one report type, so don't look at wValue */ 177 /* we only have one report type, so don't look at wValue */
171 usbMsgPtr = (void *)keyboard_report; 178 usbMsgPtr = (void *)&keyboard_report;
172 return sizeof(*keyboard_report); 179 return sizeof(keyboard_report);
173 }else if(rq->bRequest == USBRQ_HID_GET_IDLE){ 180 }else if(rq->bRequest == USBRQ_HID_GET_IDLE){
174 debug("GET_IDLE: "); 181 debug("GET_IDLE: ");
175 //debug_hex(vusb_idle_rate); 182 //debug_hex(vusb_idle_rate);
@@ -232,7 +239,7 @@ uchar usbFunctionWrite(uchar *data, uchar len)
232 * 239 *
233 * from an example in HID spec appendix 240 * from an example in HID spec appendix
234 */ 241 */
235PROGMEM uchar keyboard_hid_report[] = { 242const PROGMEM uchar keyboard_hid_report[] = {
236 0x05, 0x01, // Usage Page (Generic Desktop), 243 0x05, 0x01, // Usage Page (Generic Desktop),
237 0x09, 0x06, // Usage (Keyboard), 244 0x09, 0x06, // Usage (Keyboard),
238 0xA1, 0x01, // Collection (Application), 245 0xA1, 0x01, // Collection (Application),
@@ -275,7 +282,7 @@ PROGMEM uchar keyboard_hid_report[] = {
275 * http://www.keil.com/forum/15671/ 282 * http://www.keil.com/forum/15671/
276 * http://www.microsoft.com/whdc/device/input/wheel.mspx 283 * http://www.microsoft.com/whdc/device/input/wheel.mspx
277 */ 284 */
278PROGMEM uchar mouse_hid_report[] = { 285const PROGMEM uchar mouse_hid_report[] = {
279 /* mouse */ 286 /* mouse */
280 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 287 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
281 0x09, 0x02, // USAGE (Mouse) 288 0x09, 0x02, // USAGE (Mouse)
@@ -358,7 +365,7 @@ PROGMEM uchar mouse_hid_report[] = {
358 * contains: device, interface, HID and endpoint descriptors 365 * contains: device, interface, HID and endpoint descriptors
359 */ 366 */
360#if USB_CFG_DESCR_PROPS_CONFIGURATION 367#if USB_CFG_DESCR_PROPS_CONFIGURATION
361PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */ 368const PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
362 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ 369 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
363 USBDESCR_CONFIG, /* descriptor type */ 370 USBDESCR_CONFIG, /* descriptor type */
364 9 + (9 + 9 + 7) + (9 + 9 + 7), 0, 371 9 + (9 + 9 + 7) + (9 + 9 + 7), 0,