summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-10-20 21:18:49 +0100
committerGitHub <noreply@github.com>2021-10-20 21:18:49 +0100
commitd4be4b67a251ecc046d857c5cd00cfb37c394ab7 (patch)
tree15f6dd05ec293081782a9b42a30e1a81b33b6aa0
parent5500c428dd41348243e8a1695986b0da070e2ffa (diff)
downloadqmk_firmware-d4be4b67a251ecc046d857c5cd00cfb37c394ab7.tar.gz
qmk_firmware-d4be4b67a251ecc046d857c5cd00cfb37c394ab7.zip
Relocate PS2 code (#14895)
* Relocate ps2 protocol code * clang * Move makefile logic
-rw-r--r--common_features.mk34
-rw-r--r--drivers/ps2/ps2.h (renamed from tmk_core/protocol/ps2.h)0
-rw-r--r--drivers/ps2/ps2_busywait.c (renamed from tmk_core/protocol/ps2_busywait.c)0
-rw-r--r--drivers/ps2/ps2_interrupt.c (renamed from tmk_core/protocol/ps2_interrupt.c)0
-rw-r--r--drivers/ps2/ps2_io.h (renamed from tmk_core/protocol/ps2_io.h)0
-rw-r--r--drivers/ps2/ps2_mouse.c (renamed from tmk_core/protocol/ps2_mouse.c)10
-rw-r--r--drivers/ps2/ps2_mouse.h (renamed from tmk_core/protocol/ps2_mouse.h)0
-rw-r--r--platforms/avr/drivers/ps2/ps2_io.c (renamed from tmk_core/protocol/ps2_io_avr.c)0
-rw-r--r--platforms/avr/drivers/ps2/ps2_usart.c (renamed from tmk_core/protocol/ps2_usart.c)1
-rw-r--r--platforms/chibios/drivers/ps2/ps2_io.c (renamed from tmk_core/protocol/ps2_io_chibios.c)0
-rw-r--r--tmk_core/protocol.mk25
11 files changed, 38 insertions, 32 deletions
diff --git a/common_features.mk b/common_features.mk
index 9b9425dc33..083aa4aaa4 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -576,6 +576,40 @@ ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
endif
endif
+ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
+ PS2_ENABLE := yes
+ SRC += ps2_mouse.c
+ OPT_DEFS += -DPS2_MOUSE_ENABLE
+ OPT_DEFS += -DMOUSE_ENABLE
+endif
+
+ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
+ PS2_ENABLE := yes
+ SRC += ps2_busywait.c
+ SRC += ps2_io_avr.c
+ OPT_DEFS += -DPS2_USE_BUSYWAIT
+endif
+
+ifeq ($(strip $(PS2_USE_INT)), yes)
+ PS2_ENABLE := yes
+ SRC += ps2_interrupt.c
+ SRC += ps2_io.c
+ OPT_DEFS += -DPS2_USE_INT
+endif
+
+ifeq ($(strip $(PS2_USE_USART)), yes)
+ PS2_ENABLE := yes
+ SRC += ps2_usart.c
+ SRC += ps2_io.c
+ OPT_DEFS += -DPS2_USE_USART
+endif
+
+ifeq ($(strip $(PS2_ENABLE)), yes)
+ COMMON_VPATH += $(DRIVER_PATH)/ps2
+ COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/ps2
+ OPT_DEFS += -DPS2_ENABLE
+endif
+
JOYSTICK_ENABLE ?= no
VALID_JOYSTICK_TYPES := analog digital
JOYSTICK_DRIVER ?= analog
diff --git a/tmk_core/protocol/ps2.h b/drivers/ps2/ps2.h
index f123192852..f123192852 100644
--- a/tmk_core/protocol/ps2.h
+++ b/drivers/ps2/ps2.h
diff --git a/tmk_core/protocol/ps2_busywait.c b/drivers/ps2/ps2_busywait.c
index 983194eea8..983194eea8 100644
--- a/tmk_core/protocol/ps2_busywait.c
+++ b/drivers/ps2/ps2_busywait.c
diff --git a/tmk_core/protocol/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c
index 70debd02f7..70debd02f7 100644
--- a/tmk_core/protocol/ps2_interrupt.c
+++ b/drivers/ps2/ps2_interrupt.c
diff --git a/tmk_core/protocol/ps2_io.h b/drivers/ps2/ps2_io.h
index de93cb7a39..de93cb7a39 100644
--- a/tmk_core/protocol/ps2_io.h
+++ b/drivers/ps2/ps2_io.h
diff --git a/tmk_core/protocol/ps2_mouse.c b/drivers/ps2/ps2_mouse.c
index 39251a6434..8a6668b410 100644
--- a/tmk_core/protocol/ps2_mouse.c
+++ b/drivers/ps2/ps2_mouse.c
@@ -16,13 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
-
-#if defined(__AVR__)
-# include <avr/io.h>
-#endif
-
#include "ps2_mouse.h"
#include "wait.h"
+#include "gpio.h"
#include "host.h"
#include "timer.h"
#include "print.h"
@@ -158,8 +154,8 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
#ifdef PS2_MOUSE_INVERT_BUTTONS
// swap left & right buttons
- uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT;
- uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT;
+ uint8_t needs_left = mouse_report->buttons & PS2_MOUSE_BTN_RIGHT;
+ uint8_t needs_right = mouse_report->buttons & PS2_MOUSE_BTN_LEFT;
mouse_report->buttons = (mouse_report->buttons & ~(PS2_MOUSE_BTN_MASK)) | (needs_left ? PS2_MOUSE_BTN_LEFT : 0) | (needs_right ? PS2_MOUSE_BTN_RIGHT : 0);
#else
// remove sign and overflow flags
diff --git a/tmk_core/protocol/ps2_mouse.h b/drivers/ps2/ps2_mouse.h
index c97c6c893a..c97c6c893a 100644
--- a/tmk_core/protocol/ps2_mouse.h
+++ b/drivers/ps2/ps2_mouse.h
diff --git a/tmk_core/protocol/ps2_io_avr.c b/platforms/avr/drivers/ps2/ps2_io.c
index 7c826fbf1a..7c826fbf1a 100644
--- a/tmk_core/protocol/ps2_io_avr.c
+++ b/platforms/avr/drivers/ps2/ps2_io.c
diff --git a/tmk_core/protocol/ps2_usart.c b/platforms/avr/drivers/ps2/ps2_usart.c
index 5f70083698..151cfcd68f 100644
--- a/tmk_core/protocol/ps2_usart.c
+++ b/platforms/avr/drivers/ps2/ps2_usart.c
@@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <avr/interrupt.h>
#include <util/delay.h>
+#include "gpio.h"
#include "ps2.h"
#include "ps2_io.h"
#include "print.h"
diff --git a/tmk_core/protocol/ps2_io_chibios.c b/platforms/chibios/drivers/ps2/ps2_io.c
index 906d85d848..906d85d848 100644
--- a/tmk_core/protocol/ps2_io_chibios.c
+++ b/platforms/chibios/drivers/ps2/ps2_io.c
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 30c87a0f12..8aa063c911 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -1,30 +1,5 @@
PROTOCOL_DIR = protocol
-ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
- SRC += $(PROTOCOL_DIR)/ps2_mouse.c
- OPT_DEFS += -DPS2_MOUSE_ENABLE
- OPT_DEFS += -DMOUSE_ENABLE
-endif
-
-ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
- SRC += protocol/ps2_busywait.c
- SRC += protocol/ps2_io_avr.c
- OPT_DEFS += -DPS2_USE_BUSYWAIT
-endif
-
-ifeq ($(strip $(PS2_USE_INT)), yes)
- SRC += protocol/ps2_interrupt.c
- SRC += protocol/ps2_io_$(PLATFORM_KEY).c
- OPT_DEFS += -DPS2_USE_INT
-endif
-
-ifeq ($(strip $(PS2_USE_USART)), yes)
- SRC += protocol/ps2_usart.c
- SRC += protocol/ps2_io_$(PLATFORM_KEY).c
- OPT_DEFS += -DPS2_USE_USART
-endif
-
-
ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes)
SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \