From 8a3b6637621595912da4db0aa849fd9d3a861522 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 8 Apr 2014 18:05:39 +0900 Subject: [PATCH] Add PS2 mouse support for gh60 --- common/keyboard.c | 10 +++++++--- keyboard/gh60/Makefile | 5 +++-- keyboard/gh60/config.h | 11 +++++++++++ keyboard/gh60/matrix.c | 24 ++++++++++++++++++++++++ protocol/ps2.h | 1 + 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index c5de65ef..933eb780 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -68,7 +68,9 @@ void keyboard_init(void) #endif #ifdef PS2_MOUSE_ENABLE - ps2_mouse_init(); + if (ps2_enabled()) { + ps2_mouse_init(); + } #endif #ifdef BOOTMAGIC_ENABLE @@ -80,7 +82,7 @@ void keyboard_init(void) #endif #ifdef KEYMAP_EX_ENABLE - keymap_init(); + keymap_ex_init(); #endif } @@ -133,7 +135,9 @@ MATRIX_LOOP_END: #endif #ifdef PS2_MOUSE_ENABLE - ps2_mouse_task(); + if (ps2_enabled()) { + ps2_mouse_task(); + } #endif // update LED diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index 8da7908d..33b6cc01 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -133,12 +133,12 @@ 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 -#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support +PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support +PS2_USE_BUSYWAIT = yes BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality KEYMAP_EX_ENABLE = yes # External keymap in eeprom KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax @@ -147,5 +147,6 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/protocol.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index dd9d21ae..f46c7413 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h @@ -66,7 +66,18 @@ along with this program. If not, see . keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ ) +/* PS2 mouse support */ +#ifdef PS2_MOUSE_ENABLE +#define PS2_CLOCK_PORT PORTF +#define PS2_CLOCK_PIN PINF +#define PS2_CLOCK_DDR DDRF +#define PS2_CLOCK_BIT PF7 +#define PS2_DATA_PORT PORTF +#define PS2_DATA_PIN PINF +#define PS2_DATA_DDR DDRF +#define PS2_DATA_BIT PF6 +#endif /* * Feature disable options diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c index bb61f6ed..94cab02b 100644 --- a/keyboard/gh60/matrix.c +++ b/keyboard/gh60/matrix.c @@ -26,6 +26,9 @@ along with this program. If not, see . #include "debug.h" #include "util.h" #include "matrix.h" +#ifdef PS2_MOUSE_ENABLE +#include "ps2.h" +#endif #ifndef DEBOUNCE @@ -42,6 +45,14 @@ static void init_cols(void); static void unselect_rows(void); static void select_row(uint8_t row); +#ifdef PS2_MOUSE_ENABLE +static uint8_t ps2_mouse_detected; + +uint8_t ps2_enabled(void) +{ + return ps2_mouse_detected; +} +#endif inline uint8_t matrix_rows(void) @@ -61,6 +72,19 @@ void matrix_init(void) MCUCR = (1<