diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-05-26 18:32:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-26 18:32:43 -0400 |
commit | 453877422bddd7c83ae8b893e79203cb5d868cf7 (patch) | |
tree | 4a8e66adc77bb754261217ca95df5f21ae9ae96f | |
parent | 9851e6f3b156e3d77a2c9af01872e8bb550ca226 (diff) | |
parent | 6b994ecd82f660feb44bac376ae7d0147d40d818 (diff) | |
download | qmk_firmware-453877422bddd7c83ae8b893e79203cb5d868cf7.tar.gz qmk_firmware-453877422bddd7c83ae8b893e79203cb5d868cf7.zip |
Merge pull request #1327 from Dbroqua/master
Added Integration of IBM Trackpoint
-rw-r--r-- | keyboards/handwired/trackpoint/Makefile | 3 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/README.md | 10 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/config.h | 75 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/keymaps/default/keymap.c | 7 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/rules.mk | 25 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/trackpoint.c | 5 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/trackpoint.h | 13 | ||||
-rw-r--r-- | keyboards/handwired/trackpoint/wiring.png | bin | 0 -> 7217 bytes | |||
-rw-r--r-- | tmk_core/common/action.c | 34 | ||||
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 29 |
10 files changed, 183 insertions, 18 deletions
diff --git a/keyboards/handwired/trackpoint/Makefile b/keyboards/handwired/trackpoint/Makefile new file mode 100644 index 000000000..191c6bb66 --- /dev/null +++ b/keyboards/handwired/trackpoint/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | ifndef MAKEFILE_INCLUDED | ||
2 | include ../../../Makefile | ||
3 | endif \ No newline at end of file | ||
diff --git a/keyboards/handwired/trackpoint/README.md b/keyboards/handwired/trackpoint/README.md new file mode 100644 index 000000000..a22fca295 --- /dev/null +++ b/keyboards/handwired/trackpoint/README.md | |||
@@ -0,0 +1,10 @@ | |||
1 | # IBM Trackpoint demonstration | ||
2 | |||
3 | This is just a simple demo to show how to integrate IBM Trackpoint in QMK. | ||
4 | |||
5 | Wiring used in the demonstration: | ||
6 |  | ||
7 | |||
8 | Some documentation: | ||
9 | * [How to wire IBM Trackpoint](https://github.com/alonswartz/trackpoint) | ||
10 | * [QMK documentation](https://docs.qmk.fm/) | ||
diff --git a/keyboards/handwired/trackpoint/config.h b/keyboards/handwired/trackpoint/config.h new file mode 100644 index 000000000..7558c03bf --- /dev/null +++ b/keyboards/handwired/trackpoint/config.h | |||
@@ -0,0 +1,75 @@ | |||
1 | #ifndef CONFIG_H | ||
2 | #define CONFIG_H | ||
3 | |||
4 | #include "config_common.h" | ||
5 | |||
6 | #define VENDOR_ID 0x1234 | ||
7 | #define PRODUCT_ID 0x5678 | ||
8 | #define DEVICE_VER 0x0001 | ||
9 | #define MANUFACTURER QMK | ||
10 | #define PRODUCT TRACKPOINT-DEMO | ||
11 | #define DESCRIPTION Simple demonstration for IBM Trackpoint integration | ||
12 | |||
13 | #define MATRIX_ROWS 1 | ||
14 | #define MATRIX_COLS 3 | ||
15 | |||
16 | #ifdef PS2_USE_USART | ||
17 | #define PS2_CLOCK_PORT PORTD | ||
18 | #define PS2_CLOCK_PIN PIND | ||
19 | #define PS2_CLOCK_DDR DDRD | ||
20 | #define PS2_CLOCK_BIT 5 | ||
21 | #define PS2_DATA_PORT PORTD | ||
22 | #define PS2_DATA_PIN PIND | ||
23 | #define PS2_DATA_DDR DDRD | ||
24 | #define PS2_DATA_BIT 2 | ||
25 | |||
26 | /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ | ||
27 | /* set DDR of CLOCK as input to be slave */ | ||
28 | #define PS2_USART_INIT() do { \ | ||
29 | PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ | ||
30 | PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ | ||
31 | UCSR1C = ((1 << UMSEL10) | \ | ||
32 | (3 << UPM10) | \ | ||
33 | (0 << USBS1) | \ | ||
34 | (3 << UCSZ10) | \ | ||
35 | (0 << UCPOL1)); \ | ||
36 | UCSR1A = 0; \ | ||
37 | UBRR1H = 0; \ | ||
38 | UBRR1L = 0; \ | ||
39 | } while (0) | ||
40 | #define PS2_USART_RX_INT_ON() do { \ | ||
41 | UCSR1B = ((1 << RXCIE1) | \ | ||
42 | (1 << RXEN1)); \ | ||
43 | } while (0) | ||
44 | #define PS2_USART_RX_POLL_ON() do { \ | ||
45 | UCSR1B = (1 << RXEN1); \ | ||
46 | } while (0) | ||
47 | #define PS2_USART_OFF() do { \ | ||
48 | UCSR1C = 0; \ | ||
49 | UCSR1B &= ~((1 << RXEN1) | \ | ||
50 | (1 << TXEN1)); \ | ||
51 | } while (0) | ||
52 | #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1)) | ||
53 | #define PS2_USART_RX_DATA UDR1 | ||
54 | #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1))) | ||
55 | #define PS2_USART_RX_VECT USART1_RX_vect | ||
56 | #endif | ||
57 | |||
58 | #define MATRIX_COL_PINS { F1, F4, F5 } | ||
59 | #define MATRIX_ROW_PINS { F0 } | ||
60 | #define UNUSED_PINS | ||
61 | |||
62 | /* COL2ROW or ROW2COL */ | ||
63 | #define DIODE_DIRECTION COL2ROW | ||
64 | |||
65 | #define DEBOUNCING_DELAY 5 | ||
66 | |||
67 | #define LOCKING_SUPPORT_ENABLE | ||
68 | #define LOCKING_RESYNC_ENABLE | ||
69 | |||
70 | /* key combination for command */ | ||
71 | #define IS_COMMAND() ( \ | ||
72 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
73 | ) | ||
74 | |||
75 | #endif | ||
diff --git a/keyboards/handwired/trackpoint/keymaps/default/keymap.c b/keyboards/handwired/trackpoint/keymaps/default/keymap.c new file mode 100644 index 000000000..22e46d98a --- /dev/null +++ b/keyboards/handwired/trackpoint/keymaps/default/keymap.c | |||
@@ -0,0 +1,7 @@ | |||
1 | #include "trackpoint.h" | ||
2 | |||
3 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
4 | [0] = KEYMAP( | ||
5 | KC_BTN1, KC_BTN3, KC_BTN2 \ | ||
6 | ) | ||
7 | }; | ||
diff --git a/keyboards/handwired/trackpoint/rules.mk b/keyboards/handwired/trackpoint/rules.mk new file mode 100644 index 000000000..0609dd304 --- /dev/null +++ b/keyboards/handwired/trackpoint/rules.mk | |||
@@ -0,0 +1,25 @@ | |||
1 | MCU = atmega32u4 | ||
2 | F_CPU = 16000000 | ||
3 | ARCH = AVR8 | ||
4 | F_USB = $(F_CPU) | ||
5 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
6 | OPT_DEFS += -DBOOTLOADER_SIZE=512 | ||
7 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | ||
8 | MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) | ||
9 | EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) | ||
10 | CONSOLE_ENABLE ?= yes # Console for debug(+400) | ||
11 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | ||
12 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | ||
13 | NKRO_ENABLE ?= no # USB Nkey Rollover | ||
14 | BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default | ||
15 | MIDI_ENABLE ?= no # MIDI controls | ||
16 | UNICODE_ENABLE ?= no # Unicode | ||
17 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
18 | AUDIO_ENABLE ?= no # Audio output on port C6 | ||
19 | |||
20 | PS2_MOUSE_ENABLE ?= yes | ||
21 | PS2_USE_USART ?= yes | ||
22 | |||
23 | ifndef QUANTUM_DIR | ||
24 | include ../../Makefile | ||
25 | endif | ||
diff --git a/keyboards/handwired/trackpoint/trackpoint.c b/keyboards/handwired/trackpoint/trackpoint.c new file mode 100644 index 000000000..124995a64 --- /dev/null +++ b/keyboards/handwired/trackpoint/trackpoint.c | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "trackpoint.h" | ||
2 | |||
3 | void matrix_init_kb(void) { | ||
4 | |||
5 | } | ||
diff --git a/keyboards/handwired/trackpoint/trackpoint.h b/keyboards/handwired/trackpoint/trackpoint.h new file mode 100644 index 000000000..b5d73d7db --- /dev/null +++ b/keyboards/handwired/trackpoint/trackpoint.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef TRACKPOINT_H | ||
2 | #define TRACKPOINT_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | #define KEYMAP( \ | ||
7 | k00, k01, k02 \ | ||
8 | ) \ | ||
9 | { \ | ||
10 | { k00, k01, k02} \ | ||
11 | } | ||
12 | |||
13 | #endif | ||
diff --git a/keyboards/handwired/trackpoint/wiring.png b/keyboards/handwired/trackpoint/wiring.png new file mode 100644 index 000000000..45806e007 --- /dev/null +++ b/keyboards/handwired/trackpoint/wiring.png | |||
Binary files differ | |||
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index a534f818e..f73b0fe80 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
@@ -34,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
34 | #include "nodebug.h" | 34 | #include "nodebug.h" |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | int tp_buttons; | ||
38 | |||
37 | #ifdef FAUXCLICKY_ENABLE | 39 | #ifdef FAUXCLICKY_ENABLE |
38 | #include <fauxclicky.h> | 40 | #include <fauxclicky.h> |
39 | #endif | 41 | #endif |
@@ -311,11 +313,35 @@ void process_action(keyrecord_t *record, action_t action) | |||
311 | /* Mouse key */ | 313 | /* Mouse key */ |
312 | case ACT_MOUSEKEY: | 314 | case ACT_MOUSEKEY: |
313 | if (event.pressed) { | 315 | if (event.pressed) { |
314 | mousekey_on(action.key.code); | 316 | switch (action.key.code) { |
315 | mousekey_send(); | 317 | case KC_MS_BTN1: |
318 | tp_buttons |= (1<<0); | ||
319 | break; | ||
320 | case KC_MS_BTN2: | ||
321 | tp_buttons |= (1<<1); | ||
322 | break; | ||
323 | case KC_MS_BTN3: | ||
324 | tp_buttons |= (1<<2); | ||
325 | break; | ||
326 | default: | ||
327 | mousekey_on(action.key.code); | ||
328 | mousekey_send(); | ||
329 | } | ||
316 | } else { | 330 | } else { |
317 | mousekey_off(action.key.code); | 331 | switch (action.key.code) { |
318 | mousekey_send(); | 332 | case KC_MS_BTN1: |
333 | tp_buttons &= ~(1<<0); | ||
334 | break; | ||
335 | case KC_MS_BTN2: | ||
336 | tp_buttons &= ~(1<<1); | ||
337 | break; | ||
338 | case KC_MS_BTN3: | ||
339 | tp_buttons &= ~(1<<2); | ||
340 | break; | ||
341 | default: | ||
342 | mousekey_off(action.key.code); | ||
343 | mousekey_send(); | ||
344 | } | ||
319 | } | 345 | } |
320 | break; | 346 | break; |
321 | #endif | 347 | #endif |
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index d9ccbecb4..4ed3cae1f 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c | |||
@@ -72,12 +72,13 @@ void ps2_mouse_init_user(void) { | |||
72 | 72 | ||
73 | void ps2_mouse_task(void) { | 73 | void ps2_mouse_task(void) { |
74 | static uint8_t buttons_prev = 0; | 74 | static uint8_t buttons_prev = 0; |
75 | extern int tp_buttons; | ||
75 | 76 | ||
76 | /* receives packet from mouse */ | 77 | /* receives packet from mouse */ |
77 | uint8_t rcv; | 78 | uint8_t rcv; |
78 | rcv = ps2_host_send(PS2_MOUSE_READ_DATA); | 79 | rcv = ps2_host_send(PS2_MOUSE_READ_DATA); |
79 | if (rcv == PS2_ACK) { | 80 | if (rcv == PS2_ACK) { |
80 | mouse_report.buttons = ps2_host_recv_response(); | 81 | mouse_report.buttons = ps2_host_recv_response() | tp_buttons; |
81 | mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER; | 82 | mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER; |
82 | mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER; | 83 | mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER; |
83 | #ifdef PS2_MOUSE_ENABLE_SCROLLING | 84 | #ifdef PS2_MOUSE_ENABLE_SCROLLING |
@@ -106,34 +107,34 @@ void ps2_mouse_task(void) { | |||
106 | #endif | 107 | #endif |
107 | host_mouse_send(&mouse_report); | 108 | host_mouse_send(&mouse_report); |
108 | } | 109 | } |
109 | 110 | ||
110 | ps2_mouse_clear_report(&mouse_report); | 111 | ps2_mouse_clear_report(&mouse_report); |
111 | } | 112 | } |
112 | 113 | ||
113 | void ps2_mouse_disable_data_reporting(void) { | 114 | void ps2_mouse_disable_data_reporting(void) { |
114 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); | 115 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); |
115 | } | 116 | } |
116 | 117 | ||
117 | void ps2_mouse_enable_data_reporting(void) { | 118 | void ps2_mouse_enable_data_reporting(void) { |
118 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); | 119 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); |
119 | } | 120 | } |
120 | 121 | ||
121 | void ps2_mouse_set_remote_mode(void) { | 122 | void ps2_mouse_set_remote_mode(void) { |
122 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); | 123 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); |
123 | ps2_mouse_mode = PS2_MOUSE_REMOTE_MODE; | 124 | ps2_mouse_mode = PS2_MOUSE_REMOTE_MODE; |
124 | } | 125 | } |
125 | 126 | ||
126 | void ps2_mouse_set_stream_mode(void) { | 127 | void ps2_mouse_set_stream_mode(void) { |
127 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); | 128 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); |
128 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | 129 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; |
129 | } | 130 | } |
130 | 131 | ||
131 | void ps2_mouse_set_scaling_2_1(void) { | 132 | void ps2_mouse_set_scaling_2_1(void) { |
132 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); | 133 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); |
133 | } | 134 | } |
134 | 135 | ||
135 | void ps2_mouse_set_scaling_1_1(void) { | 136 | void ps2_mouse_set_scaling_1_1(void) { |
136 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); | 137 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); |
137 | } | 138 | } |
138 | 139 | ||
139 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { | 140 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { |
@@ -204,9 +205,9 @@ static inline void ps2_mouse_enable_scrolling(void) { | |||
204 | #define PRESS_SCROLL_BUTTONS mouse_report->buttons |= (PS2_MOUSE_SCROLL_BTN_MASK) | 205 | #define PRESS_SCROLL_BUTTONS mouse_report->buttons |= (PS2_MOUSE_SCROLL_BTN_MASK) |
205 | #define RELEASE_SCROLL_BUTTONS mouse_report->buttons &= ~(PS2_MOUSE_SCROLL_BTN_MASK) | 206 | #define RELEASE_SCROLL_BUTTONS mouse_report->buttons &= ~(PS2_MOUSE_SCROLL_BTN_MASK) |
206 | static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { | 207 | static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { |
207 | static enum { | 208 | static enum { |
208 | SCROLL_NONE, | 209 | SCROLL_NONE, |
209 | SCROLL_BTN, | 210 | SCROLL_BTN, |
210 | SCROLL_SENT, | 211 | SCROLL_SENT, |
211 | } scroll_state = SCROLL_NONE; | 212 | } scroll_state = SCROLL_NONE; |
212 | static uint16_t scroll_button_time = 0; | 213 | static uint16_t scroll_button_time = 0; |
@@ -228,10 +229,10 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { | |||
228 | mouse_report->y = 0; | 229 | mouse_report->y = 0; |
229 | } | 230 | } |
230 | } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { | 231 | } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { |
231 | // None of the scroll buttons are pressed | 232 | // None of the scroll buttons are pressed |
232 | 233 | ||
233 | #if PS2_MOUSE_SCROLL_BTN_SEND | 234 | #if PS2_MOUSE_SCROLL_BTN_SEND |
234 | if (scroll_state == SCROLL_BTN | 235 | if (scroll_state == SCROLL_BTN |
235 | && timer_elapsed(scroll_button_time) < PS2_MOUSE_SCROLL_BTN_SEND) { | 236 | && timer_elapsed(scroll_button_time) < PS2_MOUSE_SCROLL_BTN_SEND) { |
236 | PRESS_SCROLL_BUTTONS; | 237 | PRESS_SCROLL_BUTTONS; |
237 | host_mouse_send(mouse_report); | 238 | host_mouse_send(mouse_report); |