aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-10-28 02:43:51 +0100
committerGitHub <noreply@github.com>2021-10-28 02:43:51 +0100
commit780e763c13052138e4d9ad379c4138c3b2c344a7 (patch)
tree529979df4d2e44a1c6c57cde14b8ec2e58cb41d6 /tmk_core
parentb780c797beb726839e99e3f4054f9b4c33331cdc (diff)
downloadqmk_firmware-780e763c13052138e4d9ad379c4138c3b2c344a7.tar.gz
qmk_firmware-780e763c13052138e4d9ad379c4138c3b2c344a7.zip
Remove SERIAL_MOUSE (#14969)
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol.mk20
-rw-r--r--tmk_core/protocol/serial_mouse.h29
-rw-r--r--tmk_core/protocol/serial_mouse_microsoft.c113
-rw-r--r--tmk_core/protocol/serial_mouse_mousesystems.c119
4 files changed, 0 insertions, 281 deletions
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 8aa063c91..d4ad50db6 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -1,25 +1,5 @@
1PROTOCOL_DIR = protocol 1PROTOCOL_DIR = protocol
2 2
3ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes)
4 SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
5 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
6 -DMOUSE_ENABLE
7endif
8
9ifeq ($(strip $(SERIAL_MOUSE_MOUSESYSTEMS_ENABLE)), yes)
10 SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
11 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
12 -DMOUSE_ENABLE
13endif
14
15ifeq ($(strip $(SERIAL_MOUSE_USE_SOFT)), yes)
16 SRC += $(PROTOCOL_DIR)/serial_soft.c
17endif
18
19ifeq ($(strip $(SERIAL_MOUSE_USE_UART)), yes)
20 SRC += $(PROTOCOL_DIR)/serial_uart.c
21endif
22
23ifeq ($(strip $(USB_HID_ENABLE)), yes) 3ifeq ($(strip $(USB_HID_ENABLE)), yes)
24 include $(TMK_DIR)/protocol/usb_hid.mk 4 include $(TMK_DIR)/protocol/usb_hid.mk
25endif 5endif
diff --git a/tmk_core/protocol/serial_mouse.h b/tmk_core/protocol/serial_mouse.h
deleted file mode 100644
index cb83cf4f6..000000000
--- a/tmk_core/protocol/serial_mouse.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include <stdint.h>
21
22#include "serial.h"
23
24static inline uint8_t serial_mouse_init(void) {
25 serial_init();
26 return 0;
27}
28
29void serial_mouse_task(void);
diff --git a/tmk_core/protocol/serial_mouse_microsoft.c b/tmk_core/protocol/serial_mouse_microsoft.c
deleted file mode 100644
index eff0bf6e4..000000000
--- a/tmk_core/protocol/serial_mouse_microsoft.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <avr/io.h>
20#include <util/delay.h>
21
22#include "serial.h"
23#include "serial_mouse.h"
24#include "report.h"
25#include "host.h"
26#include "timer.h"
27#include "print.h"
28#include "debug.h"
29
30#ifdef MAX
31# undef MAX
32#endif
33#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
34
35static void print_usb_data(const report_mouse_t *report);
36
37void serial_mouse_task(void) {
38 /* 3 byte ring buffer */
39 static uint8_t buffer[3];
40 static int buffer_cur = 0;
41
42 static report_mouse_t report = {};
43
44 int16_t rcv;
45
46 rcv = serial_recv2();
47 if (rcv < 0) /* no new data */
48 return;
49
50 if (debug_mouse) xprintf("serial_mouse: byte: %04X\n", rcv);
51
52 /*
53 * If bit 6 is one, this signals the beginning
54 * of a 3 byte sequence/packet.
55 */
56 if (rcv & (1 << 6)) buffer_cur = 0;
57
58 buffer[buffer_cur] = (uint8_t)rcv;
59
60 if (buffer_cur == 0 && buffer[buffer_cur] == 0x20) {
61 /*
62 * Logitech extension: This must be a follow-up on
63 * the last 3-byte packet signaling a middle button click
64 */
65 report.buttons |= MOUSE_BTN3;
66 report.x = report.y = 0;
67
68 print_usb_data(&report);
69 host_mouse_send(&report);
70 return;
71 }
72
73 buffer_cur++;
74
75 if (buffer_cur < 3) return;
76 buffer_cur = 0;
77
78 /*
79 * parse 3 byte packet.
80 * NOTE: We only get a complete packet
81 * if the mouse moved or the button states
82 * change.
83 */
84 report.buttons = 0;
85 if (buffer[0] & (1 << 5)) report.buttons |= MOUSE_BTN1;
86 if (buffer[0] & (1 << 4)) report.buttons |= MOUSE_BTN2;
87
88 report.x = (buffer[0] << 6) | buffer[1];
89 report.y = ((buffer[0] << 4) & 0xC0) | buffer[2];
90
91 /* USB HID uses values from -127 to 127 only */
92 report.x = MAX(report.x, -127);
93 report.y = MAX(report.y, -127);
94
95#if 0
96 if (!report.buttons && !report.x && !report.y) {
97 /*
98 * Microsoft extension: Middle mouse button pressed
99 * FIXME: I don't know how exactly this extension works.
100 */
101 report.buttons |= MOUSE_BTN3;
102 }
103#endif
104
105 print_usb_data(&report);
106 host_mouse_send(&report);
107}
108
109static void print_usb_data(const report_mouse_t *report) {
110 if (!debug_mouse) return;
111
112 xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n", report->buttons, report->x, report->y, report->v, report->h);
113}
diff --git a/tmk_core/protocol/serial_mouse_mousesystems.c b/tmk_core/protocol/serial_mouse_mousesystems.c
deleted file mode 100644
index 0ec2b0399..000000000
--- a/tmk_core/protocol/serial_mouse_mousesystems.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19#include <avr/io.h>
20#include <util/delay.h>
21
22#include "serial.h"
23#include "serial_mouse.h"
24#include "report.h"
25#include "host.h"
26#include "timer.h"
27#include "print.h"
28#include "debug.h"
29
30#ifdef MAX
31# undef MAX
32#endif
33#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
34
35//#define SERIAL_MOUSE_CENTER_SCROLL
36
37static void print_usb_data(const report_mouse_t *report);
38
39void serial_mouse_task(void) {
40 /* 5 byte ring buffer */
41 static uint8_t buffer[5];
42 static int buffer_cur = 0;
43
44 int16_t rcv;
45
46 report_mouse_t report = {0, 0, 0, 0, 0};
47
48 rcv = serial_recv2();
49 if (rcv < 0) /* no new data */
50 return;
51
52 if (debug_mouse) xprintf("serial_mouse: byte: %04X\n", rcv);
53
54 /*
55 * Synchronization: mouse(4) says that all
56 * bytes but the first one in the packet have
57 * bit 7 == 0, but this is untrue.
58 * Therefore we discard all bytes up to the
59 * first one with the characteristic bit pattern.
60 */
61 if (buffer_cur == 0 && (rcv >> 3) != 0x10) return;
62
63 buffer[buffer_cur++] = (uint8_t)rcv;
64
65 if (buffer_cur < 5) return;
66 buffer_cur = 0;
67
68#ifdef SERIAL_MOUSE_CENTER_SCROLL
69 if ((buffer[0] & 0x7) == 0x5 && (buffer[1] || buffer[2])) {
70 /* USB HID uses only values from -127 to 127 */
71 report.h = MAX((int8_t)buffer[1], -127);
72 report.v = MAX((int8_t)buffer[2], -127);
73
74 print_usb_data(&report);
75 host_mouse_send(&report);
76
77 if (buffer[3] || buffer[4]) {
78 report.h = MAX((int8_t)buffer[3], -127);
79 report.v = MAX((int8_t)buffer[4], -127);
80
81 print_usb_data(&report);
82 host_mouse_send(&report);
83 }
84
85 return;
86 }
87#endif
88
89 /*
90 * parse 5 byte packet.
91 * NOTE: We only get a complete packet
92 * if the mouse moved or the button states
93 * change.
94 */
95 if (!(buffer[0] & (1 << 2))) report.buttons |= MOUSE_BTN1;
96 if (!(buffer[0] & (1 << 1))) report.buttons |= MOUSE_BTN3;
97 if (!(buffer[0] & (1 << 0))) report.buttons |= MOUSE_BTN2;
98
99 /* USB HID uses only values from -127 to 127 */
100 report.x = MAX((int8_t)buffer[1], -127);
101 report.y = MAX(-(int8_t)buffer[2], -127);
102
103 print_usb_data(&report);
104 host_mouse_send(&report);
105
106 if (buffer[3] || buffer[4]) {
107 report.x = MAX((int8_t)buffer[3], -127);
108 report.y = MAX(-(int8_t)buffer[4], -127);
109
110 print_usb_data(&report);
111 host_mouse_send(&report);
112 }
113}
114
115static void print_usb_data(const report_mouse_t *report) {
116 if (!debug_mouse) return;
117
118 xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n", report->buttons, report->x, report->y, report->v, report->h);
119}