diff options
-rw-r--r-- | Makefile.common | 58 | ||||
-rw-r--r-- | README | 41 | ||||
-rw-r--r-- | USB_NKRO.txt | 14 | ||||
-rw-r--r-- | hhkb/Makefile | 17 | ||||
-rw-r--r-- | hhkb/config.h | 40 | ||||
-rw-r--r-- | hhkb/controller.h | 12 | ||||
-rw-r--r-- | hhkb/keymap.c | 3 | ||||
-rw-r--r-- | hhkb/matrix.c | 5 | ||||
-rw-r--r-- | jump_bootloader.c | 31 | ||||
-rw-r--r-- | key_process.c | 110 | ||||
-rw-r--r-- | macway/Makefile | 13 | ||||
-rw-r--r-- | macway/config.h | 38 | ||||
-rw-r--r-- | macway/controller.h | 12 | ||||
-rw-r--r-- | macway/keymap.c | 62 | ||||
-rw-r--r-- | macway/matrix.c | 100 | ||||
-rw-r--r-- | mousekey.c | 74 | ||||
-rw-r--r-- | mousekey.h | 11 | ||||
-rw-r--r-- | ps2.c | 248 | ||||
-rw-r--r-- | ps2.h | 72 | ||||
-rw-r--r-- | ps2_mouse.c | 161 | ||||
-rw-r--r-- | ps2_mouse.h | 26 | ||||
-rw-r--r-- | tmk.c | 11 | ||||
-rwxr-xr-x | usb.c | 16 | ||||
-rw-r--r-- | usb_keyboard.c | 10 | ||||
-rw-r--r-- | usb_keyboard.h | 2 | ||||
-rw-r--r-- | usb_mouse.c | 57 | ||||
-rw-r--r-- | usb_mouse.h | 20 |
27 files changed, 952 insertions, 312 deletions
diff --git a/Makefile.common b/Makefile.common index d212424360..9e995c908b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -62,6 +62,13 @@ SRC = tmk.c \ timer.c \ util.c SRC += $(TARGET_SRC) +ifdef MOUSEKEY_ENABLE + SRC += mousekey.c +endif +ifdef PS2_MOUSE_ENABLE + SRC += ps2.c \ + ps2_mouse.c +endif # C source file search path VPATH = $(TARGET_DIR):$(COMMON_DIR) @@ -119,45 +126,32 @@ EXTRAINCDIRS = $(TARGET_DIR) $(COMMON_DIR) CSTANDARD = -std=gnu99 -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL -CDEFS += -DDESCRIPTION=$(DESCRIPTION) -CDEFS += -DVENDOR_ID=$(VENDOR_ID) -CDEFS += -DPRODUCT_ID=$(PRODUCT_ID) -CDEFS += -DMANUFACTURER=$(MANUFACTURER) -CDEFS += -DPRODUCT=$(PRODUCT) -ifdef MOUSE_DELAY_TIME -CDEFS += -DMOUSE_DELAY_TIME=$(MOUSE_DELAY_TIME) +OPT_DEFS = +ifdef USB_NKRO_ENABLE + OPT_DEFS += -DUSB_NKRO_ENABLE +endif +ifdef MOUSEKEY_ENABLE + OPT_DEFS += -DMOUSEKEY_ENABLE endif -ifdef NKRO_ENABLE -CDEFS += -DNKRO_ENABLE +ifdef PS2_MOUSE_ENABLE + OPT_DEFS += -DPS2_MOUSE_ENABLE endif +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += $(OPT_DEFS) + # Place -D or -U options here for ASM sources ADEFS = -DF_CPU=$(F_CPU) -ADEFS += -DDESCRIPTION=$(DESCRIPTION) -ADEFS += -DVENDOR_ID=$(VENDOR_ID) -ADEFS += -DPRODUCT_ID=$(PRODUCT_ID) -ADEFS += -DMANUFACTURER=$(MANUFACTURER) -ADEFS += -DPRODUCT=$(PRODUCT) -ifdef MOUSE_DELAY_TIME -ADEFS += -DMOUSE_DELAY_TIME=$(MOUSE_DELAY_TIME) -endif +ADEFS += $(OPT_DEFS) # Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -DDESCRIPTION=$(DESCRIPTION) -DVENDOR_ID=$(VENDOR_ID) -DPRODUCT_ID=$(PRODUCT_ID) +CPPDEFS = -DF_CPU=$(F_CPU)UL #CPPDEFS += -D__STDC_LIMIT_MACROS #CPPDEFS += -D__STDC_CONSTANT_MACROS -CPPDEFS += -DDESCRIPTION=$(DESCRIPTION) -CPPDEFS += -DVENDOR_ID=$(VENDOR_ID) -CPPDEFS += -DPRODUCT_ID=$(PRODUCT_ID) -CPPDEFS += -DMANUFACTURER=$(MANUFACTURER) -CPPDEFS += -DPRODUCT=$(PRODUCT) -ifdef MOUSE_DELAY_TIME -CPPDEFS += -DMOUSE_DELAY_TIME=$(MOUSE_DELAY_TIME) -endif +CPPDEFS += $(OPT_DEFS) @@ -186,6 +180,7 @@ CFLAGS += -Wstrict-prototypes CFLAGS += -Wa,-adhlns=$(@:%.o=$(OBJDIR)/%.lst) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) CFLAGS += $(CSTANDARD) +CFLAGS += -include config.h #---------------- Compiler Options C++ ---------------- @@ -213,6 +208,7 @@ CPPFLAGS += -Wundef CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) #CPPFLAGS += $(CSTANDARD) +CPPFLAGS += -include config.h #---------------- Assembler Options ---------------- @@ -225,6 +221,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 +ASFLAGS += -include config.h #---------------- Library Options ---------------- @@ -421,6 +418,11 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) # Default target. all: begin gccversion sizebefore build sizeafter end +depend: tmk.c + @echo $< + @echo $(<F) +# $(CC) -E $(ALL_CFLAGS) $< + # Change the build target to build a HEX file or a library. build: elf hex eep lss sym #build: lib @@ -31,6 +31,47 @@ $ make http://winavr.sourceforge.net/ +Build Options +------------- +Makefile: +Comment out to disable the option + # USB NKey Rollover + USB_NKRO_ENABLE = yes + + # mouse keys + MOUSEKEY_ENABLE = yes + + # PS/2 mouse support + PS2_MOUSE_ENABLE = yes + +config.h: + /* USB ID */ + #define VENDOR_ID 0xFEED + #define PRODUCT_ID 0xBEEF + /* device description */ + #define MANUFACTURER t.m.k. + #define PRODUCT Macway mod + #define DESCRIPTION t.m.k. keyboard firmware for Macway mod + /* matrix size */ + #define MATRIX_ROWS 8 + #define MATRIX_COLS 8 + /* mouse keys repeat delay */ + #define MOUSEKEY_DELAY_TIME 192 + /* PS/2 lines */ + #define PS2_CLOCK_PORT PORTF + #define PS2_CLOCK_PIN PINF + #define PS2_CLOCK_DDR DDRF + #define PS2_CLOCK_BIT 0 + #define PS2_DATA_PORT PORTF + #define PS2_DATA_PIN PINF + #define PS2_DATA_DDR DDRF + #define PS2_DATA_BIT 1 + + +Configuration +------------- + + Debuging & Rescue ----------------- Use PJRC's hid_listen.exe to see debug messages. diff --git a/USB_NKRO.txt b/USB_NKRO.txt index b681d85dc5..4751bca868 100644 --- a/USB_NKRO.txt +++ b/USB_NKRO.txt @@ -143,4 +143,18 @@ This problem will be reportedly fixed soon.(2010/12/05) http://forums.anandtech.com/showpost.php?p=30873364&postcount=17 +Tools for testing NKRO +---------------------- +Browser App: +http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx +http://random.xem.us/rollover.html + +Windows: +AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643 + +Linux: +xkeycaps +xev +showkeys + EOF diff --git a/hhkb/Makefile b/hhkb/Makefile index bf5d75ee9f..943785fef8 100644 --- a/hhkb/Makefile +++ b/hhkb/Makefile @@ -39,16 +39,6 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- -# TODO: use config.h for build options? -VENDOR_ID = 0xFEED -PRODUCT_ID = 0xCAFE -MANUFACTURER = 't.m.k.' -PRODUCT = 'HHKB Mod' -DESCRIPTION = 't.m.k. firmware for HHKB pro' - -MOUSE_DELAY_TIME = 127 -NKRO_ENABLE = true - # Target file name (without extension). TARGET = tmk_hhkb @@ -78,4 +68,11 @@ MCU = at90usb1286 # Teensy++ 2.0 # examples use this variable to calculate timings. Do not add a "UL" here. F_CPU = 16000000 + +# Options +# comment out to disable +USB_NKRO_ENABLE = yes +MOUSEKEY_ENABLE = yes +#PS2_MOUSE_ENABLE = yes + include $(COMMON_DIR)/Makefile.common diff --git a/hhkb/config.h b/hhkb/config.h new file mode 100644 index 0000000000..7722ed46a8 --- /dev/null +++ b/hhkb/config.h @@ -0,0 +1,40 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xCAFE +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + +/* controller */ +#include "controller_teensy.h" + +/* matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + +/* USB NKey Rollover */ +#ifdef USB_NKRO_ENABLE +#endif + +/* mouse keys */ +#ifdef MOUSEKEY_ENABLE +# define MOUSEKEY_DELAY_TIME 192 +#endif + +/* PS/2 mouse */ +#ifdef PS2_MOUSE_ENABLE +/* +# define PS2_CLOCK_PORT PORTF +# define PS2_CLOCK_PIN PINF +# define PS2_CLOCK_DDR DDRF +# define PS2_CLOCK_BIT 0 +# define PS2_DATA_PORT PORTF +# define PS2_DATA_PIN PINF +# define PS2_DATA_DDR DDRF +# define PS2_DATA_BIT 1 +*/ +#endif + +#endif diff --git a/hhkb/controller.h b/hhkb/controller.h deleted file mode 100644 index 32a10b7cd1..0000000000 --- a/hhkb/controller.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CONTROLLER_H -#define CONTROLLER_H 1 - -#include "controller_teensy.h" - - -/* matrix row size */ -#define MATRIX_ROWS 8 -/* matrix column size */ -#define MATRIX_COLS 8 - -#endif diff --git a/hhkb/keymap.c b/hhkb/keymap.c index fd9bcce8a2..4273835e98 100644 --- a/hhkb/keymap.c +++ b/hhkb/keymap.c @@ -9,7 +9,6 @@ #include "print.h" #include "debug.h" #include "util.h" -#include "controller.h" #include "keymap_skel.h" @@ -75,7 +74,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| * |-----------------------------------------------------------| - * |Contro| | | | | | *| /|Hom|PgU|Lef|Rig|Enter | + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | * |-----------------------------------------------------------| * |Shift | | | | | | +| -|End|PgD|Dow|Shift |xxx| * `-----------------------------------------------------------' diff --git a/hhkb/matrix.c b/hhkb/matrix.c index a6e0bf633f..dd4440d9e3 100644 --- a/hhkb/matrix.c +++ b/hhkb/matrix.c @@ -7,7 +7,6 @@ #include <util/delay.h> #include "print.h" #include "util.h" -#include "controller.h" #include "matrix_skel.h" // matrix is active low. (key on: 0/key off: 1) @@ -22,7 +21,7 @@ // KEY_PREV: (on: 1/ off: 0) // PE6,PE7(KEY, KEY_PREV) #define COL_ENABLE (1<<6) -#define KEY_SELELCT(ROW, COL) (PORTB = COL_ENABLE|(((COL)&0x07)<<3)|((ROW)&0x07)) +#define KEY_SELELCT(ROW, COL) (PORTB = (PORTB&(1<<7))|COL_ENABLE|(((COL)&0x07)<<3)|((ROW)&0x07)) #define KEY_ENABLE (PORTB &= ~COL_ENABLE) #define KEY_UNABLE (PORTB |= COL_ENABLE) #define KEY_STATE (PINE&(1<<6)) @@ -53,7 +52,7 @@ void matrix_init(void) { // row & col output(PB0-6) DDRB = 0xFF; - PORTB = KEY_SELELCT(0, 0); + KEY_SELELCT(0, 0); // KEY: input with pullup(PE6) // KEY_PREV: output(PE7) DDRE = 0xBF; diff --git a/jump_bootloader.c b/jump_bootloader.c index e4c0b967f4..5710e052f5 100644 --- a/jump_bootloader.c +++ b/jump_bootloader.c @@ -13,23 +13,28 @@ void jump_bootloader(void) { UCSR1B = 0; _delay_ms(5); #if defined(__AVR_AT90USB162__) // Teensy 1.0 + EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; + TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; DDRB = 0; DDRC = 0; DDRD = 0; - TIMSK0 = 0; TIMSK1 = 0; - asm volatile("jmp 0x1F00"); + PORTB = 0; PORTC = 0; PORTD = 0; + asm volatile("jmp 0x3E00"); #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 - DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; - TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; - ADCSRA = 0; - asm volatile("jmp 0x3F00"); + EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; + TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0; + DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0; + PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; + asm volatile("jmp 0x7E00"); #elif defined(__AVR_AT90USB646__) // Teensy++ 1.0 + EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; + TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; - TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; - ADCSRA = 0; - asm volatile("jmp 0x7E00"); + PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; + asm volatile("jmp 0xFC00"); #elif defined(__AVR_AT90USB1286__) // Teensy++ 2.0 + EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; + TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; - TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; - ADCSRA = 0; - asm volatile("jmp 0xFE00"); -#endif + PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; + asm volatile("jmp 0x1FC00"); +#endif } diff --git a/key_process.c b/key_process.c index bb1bca02d7..f3b65d1014 100644 --- a/key_process.c +++ b/key_process.c @@ -15,29 +15,18 @@ #include "layer.h" #include "matrix_skel.h" #include "keymap_skel.h" -#include "controller.h" #include "key_process.h" - - -#define MOUSE_MOVE_UNIT 10 -#define MOUSE_MOVE_ACCEL (mouse_repeat < 50 ? mouse_repeat/5 : 10) - -#ifndef MOUSE_DELAY_TIME -# define MOUSE_DELAY_TIME 255 +#ifdef MOUSEKEY_ENABLE +# include "mousekey.h" +#endif +#ifdef PS2_MOUSE_ENABLE +# include "ps2_mouse.h" #endif -#define MOUSE_DELAY_MS (MOUSE_DELAY_TIME >> (mouse_repeat < 5 ? mouse_repeat : 4)) // TODO: refactoring void proc_matrix(void) { - static int mouse_repeat = 0; - bool modified = false; - uint8_t mouse_btn = 0; - int8_t mouse_x = 0; - int8_t mouse_y = 0; - int8_t mouse_vwheel = 0; - int8_t mouse_hwheel = 0; uint8_t fn_bits = 0; matrix_scan(); @@ -73,19 +62,9 @@ void proc_matrix(void) { } else if (IS_FN(code)) { fn_bits |= FN_BIT(code); } else if (IS_MOUSE(code)) { - if (code == MS_UP) mouse_y -= MOUSE_MOVE_UNIT + MOUSE_MOVE_ACCEL; - if (code == MS_DOWN) mouse_y += MOUSE_MOVE_UNIT + MOUSE_MOVE_ACCEL; - if (code == MS_LEFT) mouse_x -= MOUSE_MOVE_UNIT + MOUSE_MOVE_ACCEL; - if (code == MS_RGHT) mouse_x += MOUSE_MOVE_UNIT + MOUSE_MOVE_ACCEL; - if (code == MS_BTN1) mouse_btn |= BIT_BTN1; - if (code == MS_BTN2) mouse_btn |= BIT_BTN2; - if (code == MS_BTN3) mouse_btn |= BIT_BTN3; - if (code == MS_BTN4) mouse_btn |= BIT_BTN4; - if (code == MS_BTN5) mouse_btn |= BIT_BTN5; - if (code == MS_WH_U) mouse_vwheel += 1; - if (code == MS_WH_D) mouse_vwheel -= 1; - if (code == MS_WH_L) mouse_hwheel -= 1; - if (code == MS_WH_R) mouse_hwheel += 1; +#ifdef MOUSEKEY_ENABLE + mousekey_decode(code); +#endif } // audio control & system control @@ -143,13 +122,39 @@ void proc_matrix(void) { print("t: print timer count\n"); print("s: print status\n"); print("`: toggle protcol(boot/report)\n"); -#ifdef NKRO_ENABLE - print("n: toggle NKRO\n"); +#ifdef USB_NKRO_ENABLE + print("n: toggle USB_NKRO\n"); #endif print("ESC: power down/wake up\n"); +#ifdef PS2_MOUSE_ENABLE + print("1: ps2_mouse_init \n"); + print("2: ps2_mouse_read \n"); +#endif _delay_ms(500); print_enable = false; break; +#ifdef PS2_MOUSE_ENABLE + case KB_1: + usb_keyboard_clear_report(); + usb_keyboard_send(); + print_enable = true; + print("ps2_mouse_init...\n"); + _delay_ms(500); + ps2_mouse_init(); + break; + case KB_2: + usb_keyboard_clear_report(); + usb_keyboard_send(); + print_enable = true; + print("ps2_mouse_read[btn x y]: "); + _delay_ms(100); + ps2_mouse_read(); + phex(ps2_mouse_btn); print(" "); + phex(ps2_mouse_x); print(" "); + phex(ps2_mouse_y); print("\n"); + print("ps2_mouse_error_count: "); phex(ps2_mouse_error_count); print("\n"); + break; +#endif case KB_B: // bootloader usb_keyboard_clear_report(); usb_keyboard_send(); @@ -243,29 +248,29 @@ void proc_matrix(void) { print("usb_keyboard_protocol:"); phex(usb_keyboard_protocol); print("\n"); print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n"); print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n"); - print("mouse_protocol:"); phex(mouse_protocol); print("\n"); - if (usb_keyboard_nkro) print("NKRO: enabled\n"); else print("NKRO: disabled\n"); + print("usb_mouse_protocol:"); phex(usb_mouse_protocol); print("\n"); + if (usb_keyboard_nkro) print("USB_NKRO: enabled\n"); else print("USB_NKRO: disabled\n"); _delay_ms(500); break; case KB_GRV: usb_keyboard_clear_report(); usb_keyboard_send(); usb_keyboard_protocol = !usb_keyboard_protocol; - mouse_protocol = !mouse_protocol; + usb_mouse_protocol = !usb_mouse_protocol; print("keyboard protcol: "); if (usb_keyboard_protocol) print("report"); else print("boot"); print("\n"); print("mouse protcol: "); - if (mouse_protocol) print("report"); else print("boot"); + if (usb_mouse_protocol) print("report"); else print("boot"); print("\n"); _delay_ms(1000); break; -#ifdef NKRO_ENABLE +#ifdef USB_NKRO_ENABLE case KB_N: usb_keyboard_clear_report(); usb_keyboard_send(); usb_keyboard_nkro = !usb_keyboard_nkro; - if (usb_keyboard_nkro) print("NKRO: enabled\n"); else print("NKRO: disabled\n"); + if (usb_keyboard_nkro) print("USB_NKRO: enabled\n"); else print("USB_NKRO: disabled\n"); _delay_ms(1000); break; #endif @@ -283,25 +288,20 @@ void proc_matrix(void) { } - // send mouse packet to host - if (mouse_x || mouse_y || mouse_vwheel || mouse_hwheel || mouse_btn != mouse_buttons) { - mouse_buttons = mouse_btn; - if (mouse_x && mouse_y) - usb_mouse_move(mouse_x*0.7, mouse_y*0.7, mouse_vwheel, mouse_hwheel); - else - usb_mouse_move(mouse_x, mouse_y, mouse_vwheel, mouse_hwheel); - usb_mouse_print(mouse_x, mouse_y, mouse_vwheel, mouse_hwheel); - - // acceleration - _delay_ms(MOUSE_DELAY_MS); - mouse_repeat++; - } else { - mouse_repeat = 0; - } - - - // send key packet to host if (modified) { usb_keyboard_send(); } + +#ifdef MOUSEKEY_ENABLE + // mouse keys + mousekey_usb_send(); +#endif + +#ifdef PS2_MOUSE_ENABLE + // ps2 mouse + //if (ps2_mouse_error_count > 10) { + ps2_mouse_read(); + ps2_mouse_usb_send(); + //} +#endif } diff --git a/macway/Makefile b/macway/Makefile index b69b2d2e4f..fffe1ad544 100644 --- a/macway/Makefile +++ b/macway/Makefile @@ -39,12 +39,6 @@ # To rebuild project do "make clean" then "make all". #---------------------------------------------------------------------------- -VENDOR_ID = 0xFEED -PRODUCT_ID = 0xBEEF -MANUFACTURER = 't.m.k.' -PRODUCT = 't.m.k. Macway mod' -DESCRIPTION = 't.m.k. firmware for Macway mod' - # Target file name (without extension). TARGET = tmk_macway @@ -74,4 +68,11 @@ MCU = atmega32u4 # Teensy 2.0 # examples use this variable to calculate timings. Do not add a "UL" here. F_CPU = 16000000 + +# Options +# comment out to disable +#USB_NKRO_ENABLE = yes +MOUSEKEY_ENABLE = yes +PS2_MOUSE_ENABLE = yes + include $(COMMON_DIR)/Makefile.common diff --git a/macway/config.h b/macway/config.h new file mode 100644 index 0000000000..de9fc78b10 --- /dev/null +++ b/macway/config.h @@ -0,0 +1,38 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xBEEF +#define MANUFACTURER t.m.k. +#define PRODUCT Macway mod +#define DESCRIPTION t.m.k. keyboard firmware for Macway mod + +/* controller */ +#include "controller_teensy.h" + +/* matrix size */ +#define MATRIX_ROWS 9 +#define MATRIX_COLS 8 + +/* USB NKey Rollover */ +#ifdef USB_NKRO_ENABLE +#endif + +/* mouse keys */ +#ifdef MOUSEKEY_ENABLE +# define MOUSEKEY_DELAY_TIME 192 +#endif + +/* PS/2 mouse */ +#ifdef PS2_MOUSE_ENABLE +# define PS2_CLOCK_PORT PORTF +# define PS2_CLOCK_PIN PINF +# define PS2_CLOCK_DDR DDRF +# define PS2_CLOCK_BIT 0 +# define PS2_DATA_PORT PORTF +# define PS2_DATA_PIN PINF +# define PS2_DATA_DDR DDRF +# define PS2_DATA_BIT 1 +#endif + +#endif diff --git a/macway/controller.h b/macway/controller.h deleted file mode 100644 index 22fd694ff8..0000000000 --- a/macway/controller.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CONTROLLER_H -#define CONTROLLER_H 1 - -#include "controller_teensy.h" - - -/* matrix row size */ -#define MATRIX_ROWS 9 -/* matrix column size */ -#define MATRIX_COLS 8 - -#endif diff --git a/macway/keymap.c b/macway/keymap.c index e78d6b7d12..0e71e3f76e 100644 --- a/macway/keymap.c +++ b/macway/keymap.c @@ -10,7 +10,6 @@ #include "print.h" #include "debug.h" #include "util.h" -#include "controller.h" #include "keymap_skel.h" @@ -40,9 +39,9 @@ static const uint8_t PROGMEM fn_layer[] = { 0, 1, 2, 3, 4, 0, 2, 3 }; static const uint8_t PROGMEM fn_keycode[] = { KB_NO, // FN_0 [NOT USED] KB_NO, // FN_1 layer 1 - KB_QUOTE, // FN_2 layer 2 - KB_SCOLON, // FN_3 layer 3 - KB_SPACE, // FN_4 layer 4 + KB_SLSH, // FN_2 layer 2 + KB_SCLN, // FN_3 layer 3 + KB_SPC, // FN_4 layer 4 KB_NO, // FN_5 [NOT USED] KB_NO, // FN_6 layer 2 KB_NO // FN_7 layer 3 @@ -55,38 +54,38 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | * |-----------------------------------------------------' | - * |Contro| A| S| D| F| G| H| J| K| L|Fn3|Fn2|Return | + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | * |-----------------------------------------------------------| * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn1| * |-----------------------------------------------------------| - * |Fn7|Gui |Alt |Fn4 |Fn6 |\ |` | | | + * |Fn7|Gui |Alt |Fn4 |Alt |Gui|Fn6|Fn6|Ctr| * `-----------------------------------------------------------' */ KEYMAP(KB_ESC, KB_1, KB_2, KB_3, KB_4, KB_5, KB_6, KB_7, KB_8, KB_9, KB_0, KB_MINS,KB_EQL, KB_BSPC, \ KB_TAB, KB_Q, KB_W, KB_E, KB_R, KB_T, KB_Y, KB_U, KB_I, KB_O, KB_P, KB_LBRC,KB_RBRC, \ - KB_LCTL,KB_A, KB_S, KB_D, KB_F, KB_G, KB_H, KB_J, KB_K, KB_L, FN_3, FN_2, KB_ENT, \ - KB_LSFT,KB_Z, KB_X, KB_C, KB_V, KB_B, KB_N, KB_M, KB_COMM,KB_DOT, KB_SLSH,KB_RSFT,FN_1, \ - FN_7, KB_LGUI,KB_LALT,FN_4, FN_6, KB_BSLS,KB_GRV, KB_NO, KB_NO), + KB_LCTL,KB_A, KB_S, KB_D, KB_F, KB_G, KB_H, KB_J, KB_K, KB_L, FN_3, KB_QUOT,KB_ENT, \ + KB_LSFT,KB_Z, KB_X, KB_C, KB_V, KB_B, KB_N, KB_M, KB_COMM,KB_DOT, FN_2, KB_RSFT,FN_1, \ + FN_7, KB_LGUI,KB_LALT,FN_4, KB_RALT,KB_RGUI,FN_6, FN_6, KB_RCTL), /* Layer 1: HHKB mode (HHKB Fn) * ,-----------------------------------------------------------. - * |Pow| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | * |-----------------------------------------------------------| * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | * |-----------------------------------------------------' | - * |Contro| | | | | | *| /|Hom|PgU|Lef|Rig|Enter | + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | * |-----------------------------------------------------------| * |Shift | | | | | | +| -|End|PgD|Dow|Shift |xxx| * |-----------------------------------------------------------| - * | |Gui |Alt | |Alt | | | | | + * | |Gui |Alt | |Alt |Gui| | |Ctr| * `-----------------------------------------------------------' */ - KEYMAP(KB_PWR, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_DEL, \ + KEYMAP(KB_ESC, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_DEL, \ KB_CAPS,KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_PSCR,KB_SLCK,KB_BRK, KB_UP, KB_NO, \ - KB_LCTL,KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KP_ASTR,KP_SLSH,KB_HOME,KB_PGUP,KB_LEFT,KB_RGHT,KB_ENT, \ + KB_LCTL,KB_VOLD,KB_VOLU,KB_MUTE,KB_NO, KB_NO, KP_ASTR,KP_SLSH,KB_HOME,KB_PGUP,KB_LEFT,KB_RGHT,KB_ENT, \ KB_LSFT,KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KP_PLUS,KP_MINS,KB_END, KB_PGDN,KB_DOWN,KB_RSFT,FN_1, \ - KB_NO, KB_LGUI,KB_LALT,KB_SPC, KB_RALT,KB_NO, KB_NO, KB_NO, KB_NO), + KB_NO, KB_LGUI,KB_LALT,KB_SPC, KB_RALT,KB_NO, KB_NO, KB_NO, KB_RCTL), /* Layer 2: Vi mode (Quote/Rmeta) @@ -95,27 +94,27 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | * |-----------------------------------------------------' | - * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| |xxx| \ | + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | \ | * |-----------------------------------------------------------| - * |Shift | | | | | |Hom|PgD|PgU|End| |Shift | | + * |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | | * |-----------------------------------------------------------| - * | |Gui |Alt |Space |xxxxx| | | | | + * | |Gui |Alt |Space |Alt |Gui|Fn6|Fn6|Ctr| * `-----------------------------------------------------------' */ KEYMAP(KB_GRV, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_GRV, \ KB_BSLS,KB_HOME,KB_PGDN,KB_UP, KB_PGUP,KB_END, KB_HOME,KB_PGDN,KB_PGUP,KB_END, KB_NO, KB_NO, KB_NO, \ - KB_LCTL,KB_NO, KB_LEFT,KB_DOWN,KB_RGHT,KB_NO, KB_LEFT,KB_DOWN,KB_UP, KB_RGHT,KB_NO, FN_2, KB_BSLS, \ - KB_LSFT,KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_RSFT,KB_NO, \ - KB_NO, KB_LGUI,KB_LALT,KB_SPC, FN_6, KB_NO, KB_NO, KB_NO, KB_NO), + KB_LCTL,KB_NO, KB_LEFT,KB_DOWN,KB_RGHT,KB_NO, KB_LEFT,KB_DOWN,KB_UP, KB_RGHT,KB_NO, KB_NO, KB_BSLS, \ + KB_LSFT,KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, FN_2, KB_RSFT,KB_NO, \ + KB_NO, KB_LGUI,KB_LALT,KB_SPC, KB_RALT,KB_RGUI,FN_6, FN_6, KB_RCTL), /* Layer 3: Mouse mode (Semicolon) - * ,-------------------------------------------------------- --. - * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * ,-----------------------------------------------------------. + * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | * |-----------------------------------------------------------| - * |Tab |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | + * | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | * |-----------------------------------------------------' | - * |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| |Return | + * |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | \ | * |-----------------------------------------------------------| * |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | | * |-----------------------------------------------------------| @@ -123,9 +122,9 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `-----------------------------------------------------------' * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ - KEYMAP(KB_ESC, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_DEL, \ - KB_TAB, MS_WH_L,MS_WH_D,MS_UP, MS_WH_U,MS_WH_R,MS_WH_L,MS_WH_D,MS_WH_U,MS_WH_R,KB_NO, KB_NO, KB_NO, \ - KB_LCTL,KB_NO, MS_LEFT,MS_DOWN,MS_RGHT,KB_NO, MS_LEFT,MS_DOWN,MS_UP, MS_RGHT,FN_3, KB_NO, KB_ENT, \ + KEYMAP(KB_GRV, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12, KB_GRV, \ + KB_BSLS,MS_WH_L,MS_WH_D,MS_UP, MS_WH_U,MS_WH_R,MS_WH_L,MS_WH_D,MS_WH_U,MS_WH_R,KB_NO, KB_NO, KB_NO, \ + KB_LCTL,KB_NO, MS_LEFT,MS_DOWN,MS_RGHT,KB_NO, MS_LEFT,MS_DOWN,MS_UP, MS_RGHT,FN_3, KB_NO, KB_BSLS, \ KB_LSFT,KB_NO, KB_NO, MS_BTN1,MS_BTN2,MS_BTN3,MS_BTN2,MS_BTN1,KB_NO, KB_NO, KB_NO, KB_RSFT,KB_NO, \ FN_7, KB_LGUI,KB_LALT,MS_BTN1,KB_RALT,KB_NO, KB_NO, KB_NO, KB_NO), @@ -140,14 +139,14 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | | * |-----------------------------------------------------------| - * | |Gui |Alt |xxxxxxxxxxxxxxxxxxxxxx|Alt | | | | | + * | |Gui |Alt |xxxxxxxxxxxxxxxxxxxxxx|Alt |Gui| | |Ctr| * `-----------------------------------------------------------' */ KEYMAP(KB_MINS,KB_0, KB_9, KB_8, KB_7, KB_6, KB_5, KB_4, KB_3, KB_2, KB_1, KB_NO, KB_NO, KB_ESC, \ KB_BSPC,KB_P, KB_O, KB_I, KB_U, KB_Y, KB_T, KB_R, KB_E, KB_W, KB_Q, KB_TAB, KB_TAB, \ KB_LCTL,KB_SCLN,KB_L, KB_K, KB_J, KB_H, KB_G, KB_F, KB_D, KB_S, KB_A, KB_RCTL,KB_RCTL, \ KB_LSFT,KB_SLSH,KB_DOT, KB_COMM,KB_M, KB_N, KB_B, KB_V, KB_C, KB_X, KB_Z, KB_RSFT,KB_NO, \ - KB_NO, KB_LGUI,KB_LALT,FN_4, KB_RALT,KB_NO, KB_NO, KB_NO, KB_NO), + KB_NO, KB_LGUI,KB_LALT,FN_4, KB_RALT,KB_RGUI,KB_NO, KB_NO, KB_RCTL), }; @@ -168,5 +167,6 @@ uint8_t keymap_fn_keycode(uint8_t fn_bits) bool keymap_is_special_mode(uint8_t fn_bits) { - return (usb_keyboard_mods == (BIT_LCTRL | BIT_LSHIFT | BIT_LALT | BIT_LGUI)); + //return (usb_keyboard_mods == (BIT_LCTRL | BIT_LSHIFT | BIT_LALT | BIT_LGUI)); + return (usb_keyboard_mods == (BIT_RSHIFT)); } diff --git a/macway/matrix.c b/macway/matrix.c index c2b3fb8b2a..7c2a421059 100644 --- a/macway/matrix.c +++ b/macway/matrix.c @@ -7,16 +7,10 @@ #include <util/delay.h> #include "print.h" #include "util.h" -#include "controller.h" #include "matrix_skel.h" -// matrix is active low. (key on: 0/key off: 1) -// row: Hi-Z(unselected)/low output(selected) -// PD0, PC7, PD7, PF6, PD6, PD1, PD2, PC6, PF7 -// col: input w/pullup -// PB0-PB7 -// matrix state buffer +// matrix state buffer (key on: 1/key off: 0) |