diff options
52 files changed, 1924 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore index b79d72b7c7..f3f46872a0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ *.map *.sym tags +*~ build/ *.bak @@ -8,6 +8,7 @@ SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/action_util.c \ $(COMMON_DIR)/keymap.c \ $(COMMON_DIR)/print.c \ + $(COMMON_DIR)/debug.c \ $(COMMON_DIR)/util.c \ $(COMMON_DIR)/avr/suspend.c \ $(COMMON_DIR)/avr/xprintf.S \ diff --git a/common/action.c b/common/action.c index 94498fe6cb..ec8eeae7bc 100644 --- a/common/action.c +++ b/common/action.c @@ -237,6 +237,16 @@ void process_action(keyrecord_t *record) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { + case 0xe0 ... 0xef: + /* layer On/Off with modifiers(left only) */ + if (event.pressed) { + layer_on(action.layer_tap.val); + register_mods(action.layer_tap.code & 0x0f); + } else { + layer_off(action.layer_tap.val); + unregister_mods(action.layer_tap.code & 0x0f); + } + break; case OP_TAP_TOGGLE: /* tap toggle */ if (event.pressed) { diff --git a/common/action_code.h b/common/action_code.h index 50112d4d20..bc40e2c6fb 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/>. * * ACT_LAYER_TAP(101x): * 101E|LLLL| keycode On/Off with tap key - * 101E|LLLL|1110 xxxx Reserved(0xE0-EF) + * 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF) * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0) * 101E|LLLL|1111 0001 On/Off * 101E|LLLL|1111 0010 Off/On @@ -266,6 +266,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) #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 f58bca817b..59c6f25312 100644 --- a/common/avr/xprintf.h +++ b/common/avr/xprintf.h @@ -8,6 +8,10 @@ #include <inttypes.h>
#include <avr/pgmspace.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void (*xfunc_out)(uint8_t);
#define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func)
@@ -99,5 +103,9 @@ char xatoi(char **str, long *ret); Pointer to return value
*/
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/common/debug.c b/common/debug.c new file mode 100644 index 0000000000..18613fc28b --- /dev/null +++ b/common/debug.c @@ -0,0 +1,24 @@ +#include <stdbool.h> +#include "debug.h" + +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +debug_config_t debug_config = { +/* GCC Bug 10676 - Using unnamed fields in initializers + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 */ +#if GCC_VERSION >= 40600 + .enable = false, + .matrix = false, + .keyboard = false, + .mouse = false, + .reserved = 0 +#else + { + false, // .enable + false, // .matrix + false, // .keyboard + false, // .mouse + 0 // .reserved + } +#endif +}; diff --git a/common/debug.h b/common/debug.h index 26472c8fa3..472dd478c4 100644 --- a/common/debug.h +++ b/common/debug.h @@ -29,7 +29,6 @@ extern "C" { #endif typedef union { - uint8_t raw; struct { bool enable:1; bool matrix:1; @@ -37,6 +36,7 @@ typedef union { bool mouse:1; uint8_t reserved:4; }; + uint8_t raw; } debug_config_t; extern debug_config_t debug_config; diff --git a/common/debug_config.h b/common/debug_config.h new file mode 100644 index 0000000000..28bc34cd57 --- /dev/null +++ b/common/debug_config.h @@ -0,0 +1,51 @@ +/* +Copyright 2013 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef DEBUG_CONFIG_H +#define DEBUG_CONFIG_H 1 + +#include <stdbool.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +/* NOTE: Not portable. Bit field order depends on implementation */ +typedef union { + struct { + bool enable:1; + bool matrix:1; + bool keyboard:1; + bool mouse:1; + uint8_t reserved:4; + }; + uint8_t raw; +} debug_config_t; +extern debug_config_t debug_config; + +/* for backward compatibility */ +#define debug_enable (debug_config.enable) +#define debug_matrix (debug_config.matrix) +#define debug_keyboard (debug_config.keyboard) +#define debug_mouse (debug_config.mouse) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/keyboard.c b/common/keyboard.c index 9a809ff4a1..1e3fb510a4 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/>. #ifdef PS2_MOUSE_ENABLE # include "ps2_mouse.h" #endif +#ifdef SERIAL_MOUSE_ENABLE +#include "serial_mouse.h" +#endif #ifdef MATRIX_HAS_GHOST @@ -63,6 +66,10 @@ void keyboard_init(void) #ifdef PS2_MOUSE_ENABLE ps2_mouse_init(); #endif +#ifdef SERIAL_MOUSE_ENABLE + serial_mouse_init(); +#endif + #ifdef BOOTMAGIC_ENABLE bootmagic(); @@ -125,6 +132,10 @@ MATRIX_LOOP_END: ps2_mouse_task(); #endif +#ifdef SERIAL_MOUSE_ENABLE + serial_mouse_task(); +#endif + // update LED if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds(); diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile index 73cae8ab30..bbb7810eef 100644 --- a/converter/adb_usb/Makefile +++ b/converter/adb_usb/Makefile @@ -121,7 +121,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend -#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +#NKRO_ENABLE = yes # USB Nkey Rollover # Optimize size but this may cause error "relocation truncated to fit" diff --git a/converter/next_usb/Makefile b/converter/next_usb/Makefile index 51d9de6b11..fef539a147 100644 --- a/converter/next_usb/Makefile +++ b/converter/next_usb/Makefile @@ -20,6 +20,7 @@ CONFIG_H = config.h MCU = atmega32u4 # Teensy 2.0 #MCU = at90usb646 # Teensy++ 1.0 #MCU = at90usb1286 # Teensy++ 2.0 +#MCU = atmega32u2 # TMK converter # Processor frequency. @@ -30,6 +31,29 @@ MCU = atmega32u4 # Teensy 2.0 F_CPU = 16000000 +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + # Boot Section Size in *bytes* # Teensy halfKay 512 # Teensy++ halfKay 1024 @@ -58,6 +82,6 @@ VPATH += $(TOP_DIR) include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/protocol/pjrc.mk +include $(TOP_DIR)/protocol/lufa.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk diff --git a/converter/next_usb/Makefile.pjrc b/converter/next_usb/Makefile.pjrc new file mode 100644 index 0000000000..51d9de6b11 --- /dev/null +++ b/converter/next_usb/Makefile.pjrc @@ -0,0 +1,63 @@ +# Target file name (without extension). +TARGET = next_usb + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# keyboard dependent files +SRC = keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + +# MCU name, you MUST set this to match the board you are using +# type "make clean" after changing this, so all files will be rebuilt +#MCU = at90usb162 # Teensy 1.0 +MCU = atmega32u4 # Teensy 2.0 +#MCU = at90usb646 # Teensy++ 1.0 +#MCU = at90usb1286 # Teensy++ 2.0 + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU = 16000000 + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# *Comment out* to disable the options. +# +#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +#NKRO_ENABLE = yes # USB Nkey Rollover + +SRC += next_kbd.c + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + + +include $(TOP_DIR)/protocol.mk +include $(TOP_DIR)/protocol/pjrc.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk diff --git a/converter/next_usb/config.h b/converter/next_usb/config.h index b3d188b0c1..cd80b5af1b 100644 --- a/converter/next_usb/config.h +++ b/converter/next_usb/config.h @@ -60,6 +60,7 @@ POSSIBILITY OF SUCH DAMAGE. //#define TEENSY_CONFIG 1 #define PRO_MICRO_CONFIG 1 +//#define TMK_CONFIG 1 // comment out if you don't want the keyboard's LEDs to flash upon initialization #define NEXT_KBD_INIT_FLASH_LEDS @@ -143,6 +144,43 @@ POSSIBILITY OF SUCH DAMAGE. #endif //================= End of Teensy 2.0 Configuration ================== + +//================ Start of TMK converter Configuration ================= +#ifdef TMK_CONFIG + +// this is the debugging LED that flashes when a key is being pressed +// comment out in order to disable debugging LED +#define NEXT_KBD_LED1_PORT PORTD +#define NEXT_KBD_LED1_PIN PIND +#define NEXT_KBD_LED1_DDR DDRD +#define NEXT_KBD_LED1_BIT 6 + +#define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT); +#define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT); + +// corresponds to the Keyboard In wire on the NeXT connector +#define NEXT_KBD_OUT_PORT PORTD +#define NEXT_KBD_OUT_PIN PIND +#define NEXT_KBD_OUT_DDR DDRD +#define NEXT_KBD_OUT_BIT 1 + +// corresponds to the Keyboard Out wire on the NeXT connector +#define NEXT_KBD_IN_PORT PORTD +#define NEXT_KBD_IN_PIN PIND +#define NEXT_KBD_IN_DDR DDRD +#define NEXT_KBD_IN_BIT 0 + +// this pin is an input for the power key on the NeXT keyboard +// as the keyboard is powered on this should be normally high; +// if it is pulled low it means the power button is being preseed +#define NEXT_KBD_PWR_PORT PORTD +#define NEXT_KBD_PWR_PIN PIND +#define NEXT_KBD_PWR_DDR DDRD +#define NEXT_KBD_PWR_BIT 4 + +#endif +//================= End of TMK converter Configuration ================== + /* key combination for command */ #define IS_COMMAND() ( \ (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 1bb44f8875..ddf1868459 100644 --- a/converter/ps2_usb/Makefile.vusb +++ b/converter/ps2_usb/Makefile.vusb @@ -8,10 +8,16 @@ TOP_DIR = ../.. TARGET_DIR = . # keyboard dependent files -SRC = keymap.c \ +SRC = keymap_common.c \ matrix.c \ led.c +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_plain.c $(SRC) +endif + # Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful. SRC += protocol/ps2_usart.c OPT_DEFS += -DPS2_USE_USART @@ -95,7 +101,7 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) -include $(TOP_DIR)/protocol/vusb.mk include $(TOP_DIR)/protocol.mk include $(TOP_DIR)/common.mk +include $(TOP_DIR)/protocol/vusb.mk include $(TOP_DIR)/rules.mk diff --git a/converter/ps2_usb/README.md b/converter/ps2_usb/README.md index 586394b23a..8a535949d8 100644 --- a/converter/ps2_usb/README.md +++ b/converter/ps2_usb/README.md @@ -58,8 +58,7 @@ To select method edit Makefile. V-USB Support ------------- -You can also use this converter on ATmega(168/328) with V-USB instead of Teensy. -The converter on V-USB lacks some features for now: USB NKRO and System/Media control. +With V-USB you can use this converter on ATmega(168/328) but it doesn't support NKRO at this time. Circuit: diff --git a/converter/serialmouse_usb/Makefile b/converter/serialmouse_usb/Makefile new file mode 100644 index 0000000000..ea0e439bd7 --- /dev/null +++ b/converter/serialmouse_usb/Makefile @@ -0,0 +1,106 @@ +# +# Makefile for Teensy +# +# Target file name (without extension). +TARGET = serialmouse_usb + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + + +# MCU name +#MCU = at90usb1287 +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=512 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +#MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +#EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +#COMMAND_ENABLE = yes # Commands for debug and configuration +#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA + + +# Serial Mouse Options +# You can choose a mouse protocol and the implementation of +# the underlying serial connection. +# +SERIAL_MOUSE_MICROSOFT_ENABLE = yes # Enable support for Microsoft-compatible mice +#SERIAL_MOUSE_MOUSESYSTEMS_ENABLE = yes # Enable support for Mousesystems-compatible mice +#SERIAL_MOUSE_USE_UART = yes # use hardware UART for serial connection +SERIAL_MOUSE_USE_SOFT = yes # use software serial implementation + +# Optional serial mouse driver features +# Support scrolling while holding the middle mouse button +# (currently only supported for Mousesystems mice): +#OPT_DEFS += -DSERIAL_MOUSE_CENTER_SCROLL + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol.mk +include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk diff --git a/converter/serialmouse_usb/README.md b/converter/serialmouse_usb/README.md new file mode 100644 index 0000000000..ef8a006716 --- /dev/null +++ b/converter/serialmouse_usb/README.md @@ -0,0 +1,11 @@ +Serial mouse converter +====================== +See https://github.com/tmk/tmk_keyboard/pull/131 + + +Supported protocols +------------------- +### Microsoft +Not tested. + +### Mousesystems diff --git a/converter/serialmouse_usb/config.h b/converter/serialmouse_usb/config.h new file mode 100644 index 0000000000..b257d997cf --- /dev/null +++ b/converter/serialmouse_usb/config.h @@ -0,0 +1,119 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include <avr/interrupt.h> + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x2222 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT serial mouse converter +#define DESCRIPTION convert serial mouse into USB + + +/* matrix size */ +#define MATRIX_ROWS 0 +#define MATRIX_COLS 0 + + +/* key combination for command */ |