Browse Source

Add PS2 mouse support for gh60

led_matrix
Kai Ryu 10 years ago
parent
commit
8a3b663762
5 changed files with 47 additions and 6 deletions
  1. 7
    3
      common/keyboard.c
  2. 3
    2
      keyboard/gh60/Makefile
  3. 12
    1
      keyboard/gh60/config.h
  4. 24
    0
      keyboard/gh60/matrix.c
  5. 1
    0
      protocol/ps2.h

+ 7
- 3
common/keyboard.c View File

@@ -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

+ 3
- 2
keyboard/gh60/Makefile View File

@@ -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

+ 12
- 1
keyboard/gh60/config.h View File

@@ -66,7 +66,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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

+ 24
- 0
keyboard/gh60/matrix.c View File

@@ -26,6 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<<JTD);
MCUCR = (1<<JTD);

#ifdef PS2_MOUSE_ENABLE
// ps2 mouse detect
DDRF &= ~(1<<PF5 | 1<<PF4);
PORTF |= (1<<PF5 | 1<<PF4);
if (PINF & (1<<PF5 | 1 <<PF4)) {
ps2_mouse_detected = 0;
}
else {
ps2_mouse_detected = 1;
}
DDRF |= (1<<PF5 | 1<<PF4);
#endif

// initialize row and col
unselect_rows();
init_cols();

+ 1
- 0
protocol/ps2.h View File

@@ -90,6 +90,7 @@ uint8_t ps2_host_send(uint8_t data);
uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led);
uint8_t ps2_enabled(void);


/* Check port settings for clock and data line */