aboutsummaryrefslogtreecommitdiff
path: root/keyboard/onekey
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-11-19 03:39:15 +0900
committertmk <nobody@nowhere>2013-11-19 03:39:15 +0900
commit755e4d8b00a4f9be0c50c2b005d063b94c528f8c (patch)
tree5c8f33d7204868571370774e5ddb4d5c8e6ba469 /keyboard/onekey
parent44d2d5f5fda3fbdf73e311067807026bb53798c0 (diff)
downloadqmk_firmware-755e4d8b00a4f9be0c50c2b005d063b94c528f8c.tar.gz
qmk_firmware-755e4d8b00a4f9be0c50c2b005d063b94c528f8c.zip
Add PS/2 mouse configure to onekey
Diffstat (limited to 'keyboard/onekey')
-rw-r--r--keyboard/onekey/Makefile.lufa31
-rw-r--r--keyboard/onekey/Makefile.pjrc31
-rw-r--r--keyboard/onekey/config.h85
-rw-r--r--keyboard/onekey/matrix.c1
4 files changed, 109 insertions, 39 deletions
diff --git a/keyboard/onekey/Makefile.lufa b/keyboard/onekey/Makefile.lufa
index 03cfd83a5..2a97aa63a 100644
--- a/keyboard/onekey/Makefile.lufa
+++ b/keyboard/onekey/Makefile.lufa
@@ -108,34 +108,25 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
108# Build Options 108# Build Options
109# comment out to disable the options. 109# comment out to disable the options.
110# 110#
111BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) 111#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
112MOUSEKEY_ENABLE = yes # Mouse keys(+4700) 112#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
113EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 113#EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
114CONSOLE_ENABLE = yes # Console for debug(+400) 114CONSOLE_ENABLE = yes # Console for debug(+400)
115COMMAND_ENABLE = yes # Commands for debug and configuration 115#COMMAND_ENABLE = yes # Commands for debug and configuration
116SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 116#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
117#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA 117#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
118 118
119PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
120PS2_USE_BUSYWAIT = yes # uses primitive reference code
121#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
122#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
119 123
120# Optimize size but this may cause error "relocation truncated to fit"
121#EXTRALDFLAGS = -Wl,--relax
122 124
123# Search Path 125# Search Path
124VPATH += $(TARGET_DIR) 126VPATH += $(TARGET_DIR)
125VPATH += $(TOP_DIR) 127VPATH += $(TOP_DIR)
126 128
127include $(TOP_DIR)/protocol/lufa.mk
128include $(TOP_DIR)/common.mk 129include $(TOP_DIR)/common.mk
130include $(TOP_DIR)/protocol.mk
131include $(TOP_DIR)/protocol/lufa.mk
129include $(TOP_DIR)/rules.mk 132include $(TOP_DIR)/rules.mk
130
131plain: OPT_DEFS += -DKEYMAP_PLAIN
132plain: all
133
134poker: OPT_DEFS += -DKEYMAP_POKER
135poker: all
136
137poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
138poker_set: all
139
140poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
141poker_bit: all
diff --git a/keyboard/onekey/Makefile.pjrc b/keyboard/onekey/Makefile.pjrc
index 194a2b975..0f0f70972 100644
--- a/keyboard/onekey/Makefile.pjrc
+++ b/keyboard/onekey/Makefile.pjrc
@@ -79,32 +79,25 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
79# Build Options 79# Build Options
80# comment out to disable the options. 80# comment out to disable the options.
81# 81#
82BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) 82#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
83MOUSEKEY_ENABLE = yes # Mouse keys(+5000) 83#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
84EXTRAKEY_ENABLE = yes # Audio control and System control(+600) 84#EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
85CONSOLE_ENABLE = yes # Console for debug 85CONSOLE_ENABLE = yes # Console for debug
86COMMAND_ENABLE = yes # Commands for debug and configuration 86#COMMAND_ENABLE = yes # Commands for debug and configuration
87SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 87#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
88NKRO_ENABLE = yes # USB Nkey Rollover(+500) 88#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
89
89#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support 90#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
91#PS2_USE_BUSYWAIT = yes # uses primitive reference code
92#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
93#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
90 94
91 95
92# Search Path 96# Search Path
93VPATH += $(TARGET_DIR) 97VPATH += $(TARGET_DIR)
94VPATH += $(TOP_DIR) 98VPATH += $(TOP_DIR)
95 99
96include $(TOP_DIR)/protocol/pjrc.mk
97include $(TOP_DIR)/common.mk 100include $(TOP_DIR)/common.mk
101include $(TOP_DIR)/protocol.mk
102include $(TOP_DIR)/protocol/pjrc.mk
98include $(TOP_DIR)/rules.mk 103include $(TOP_DIR)/rules.mk
99
100plain: OPT_DEFS += -DKEYMAP_PLAIN
101plain: all
102
103poker: OPT_DEFS += -DKEYMAP_POKER
104poker: all
105
106poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
107poker_set: all
108
109poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
110poker_bit: all
diff --git a/keyboard/onekey/config.h b/keyboard/onekey/config.h
index c5bc64de9..8403c9b65 100644
--- a/keyboard/onekey/config.h
+++ b/keyboard/onekey/config.h
@@ -67,4 +67,89 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67//#define NO_ACTION_MACRO 67//#define NO_ACTION_MACRO
68//#define NO_ACTION_FUNCTION 68//#define NO_ACTION_FUNCTION
69 69
70
71/* PS/2 mouse */
72#define PS2_MOUSE_DEBUG
73#ifdef PS2_USE_BUSYWAIT
74# define PS2_CLOCK_PORT PORTD
75# define PS2_CLOCK_PIN PIND
76# define PS2_CLOCK_DDR DDRD
77# define PS2_CLOCK_BIT 1
78# define PS2_DATA_PORT PORTD
79# define PS2_DATA_PIN PIND
80# define PS2_DATA_DDR DDRD
81# define PS2_DATA_BIT 2
82#endif
83
84
85#ifdef PS2_USE_INT
86/* uses INT1 for clock line(ATMega32U4) */
87#define PS2_CLOCK_PORT PORTD
88#define PS2_CLOCK_PIN PIND
89#define PS2_CLOCK_DDR DDRD
90#define PS2_CLOCK_BIT 1
91#define PS2_DATA_PORT PORTD
92#define PS2_DATA_PIN PIND
93#define PS2_DATA_DDR DDRD
94#define PS2_DATA_BIT 2
95
96#define PS2_INT_INIT() do { \
97 EICRA |= ((1<<ISC11) | \
98 (0<<ISC10)); \
99} while (0)
100#define PS2_INT_ON() do { \
101 EIMSK |= (1<<INT1); \
102} while (0)
103#define PS2_INT_OFF() do { \
104 EIMSK &= ~(1<<INT1); \
105} while (0)
106#define PS2_INT_VECT INT1_vect
107#endif
108
109
110#ifdef PS2_USE_USART
111#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
112/* XCK for clock line and RXD for data line */
113#define PS2_CLOCK_PORT PORTD
114#define PS2_CLOCK_PIN PIND
115#define PS2_CLOCK_DDR DDRD
116#define PS2_CLOCK_BIT 5
117#define PS2_DATA_PORT PORTD
118#define PS2_DATA_PIN PIND
119#define PS2_DATA_DDR DDRD
120#define PS2_DATA_BIT 2
121
122/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
123/* set DDR of CLOCK as input to be slave */
124#define PS2_USART_INIT() do { \
125 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
126 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
127 UCSR1C = ((1 << UMSEL10) | \
128 (3 << UPM10) | \
129 (0 << USBS1) | \
130 (3 << UCSZ10) | \
131 (0 << UCPOL1)); \
132 UCSR1A = 0; \
133 UBRR1H = 0; \
134 UBRR1L = 0; \
135} while (0)
136#define PS2_USART_RX_INT_ON() do { \
137 UCSR1B = ((1 << RXCIE1) | \
138 (1 << RXEN1)); \
139} while (0)
140#define PS2_USART_RX_POLL_ON() do { \
141 UCSR1B = (1 << RXEN1); \
142} while (0)
143#define PS2_USART_OFF() do { \
144 UCSR1C = 0; \
145 UCSR1B &= ~((1 << RXEN1) | \
146 (1 << TXEN1)); \
147} while (0)
148#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
149#define PS2_USART_RX_DATA UDR1
150#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
151#define PS2_USART_RX_VECT USART1_RX_vect
152#endif
153#endif
154
70#endif 155#endif
diff --git a/keyboard/onekey/matrix.c b/keyboard/onekey/matrix.c
index cd0789c60..a0a14ff82 100644
--- a/keyboard/onekey/matrix.c
+++ b/keyboard/onekey/matrix.c
@@ -59,6 +59,7 @@ void matrix_init(void)
59{ 59{
60 debug_enable = true; 60 debug_enable = true;
61 debug_matrix = true; 61 debug_matrix = true;
62 debug_mouse = true;
62 // initialize row and col 63 // initialize row and col
63 unselect_rows(); 64 unselect_rows();
64 init_cols(); 65 init_cols();