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

#endif #endif


#ifdef PS2_MOUSE_ENABLE #ifdef PS2_MOUSE_ENABLE
ps2_mouse_init();
if (ps2_enabled()) {
ps2_mouse_init();
}
#endif #endif


#ifdef BOOTMAGIC_ENABLE #ifdef BOOTMAGIC_ENABLE
#endif #endif


#ifdef KEYMAP_EX_ENABLE #ifdef KEYMAP_EX_ENABLE
keymap_init();
keymap_ex_init();
#endif #endif
} }


#endif #endif


#ifdef PS2_MOUSE_ENABLE #ifdef PS2_MOUSE_ENABLE
ps2_mouse_task();
if (ps2_enabled()) {
ps2_mouse_task();
}
#endif #endif


// update LED // update LED

+ 3
- 2
keyboard/gh60/Makefile View File

COMMAND_ENABLE = yes # Commands for debug and configuration COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #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 - 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 BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
KEYMAP_EX_ENABLE = yes # External keymap in eeprom KEYMAP_EX_ENABLE = yes # External keymap in eeprom
KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor



# Optimize size but this may cause error "relocation truncated to fit" # Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax #EXTRALDFLAGS = -Wl,--relax


VPATH += $(TOP_DIR) VPATH += $(TOP_DIR)


include $(TOP_DIR)/protocol/lufa.mk include $(TOP_DIR)/protocol/lufa.mk
include $(TOP_DIR)/protocol.mk
include $(TOP_DIR)/common.mk include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk include $(TOP_DIR)/rules.mk

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

keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 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 * Feature disable options

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

#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#ifdef PS2_MOUSE_ENABLE
#include "ps2.h"
#endif




#ifndef DEBOUNCE #ifndef DEBOUNCE
static void unselect_rows(void); static void unselect_rows(void);
static void select_row(uint8_t row); 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 inline
uint8_t matrix_rows(void) uint8_t matrix_rows(void)
MCUCR = (1<<JTD); MCUCR = (1<<JTD);
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 // initialize row and col
unselect_rows(); unselect_rows();
init_cols(); init_cols();

+ 1
- 0
protocol/ps2.h View File

uint8_t ps2_host_recv_response(void); uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void); uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led); void ps2_host_set_led(uint8_t usb_led);
uint8_t ps2_enabled(void);




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