From 82db198c3bb64b2e3193c6684dd56910184f2fb9 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 20 Oct 2021 20:52:13 +0100 Subject: [PATCH 1/3] Relocate ps2 protocol code --- {tmk_core/protocol => drivers/ps2}/ps2.h | 0 .../protocol => drivers/ps2}/ps2_busywait.c | 0 .../protocol => drivers/ps2}/ps2_interrupt.c | 0 {tmk_core/protocol => drivers/ps2}/ps2_io.h | 0 .../protocol => drivers/ps2}/ps2_mouse.c | 6 +--- .../protocol => drivers/ps2}/ps2_mouse.h | 0 .../avr/drivers/ps2/ps2_io.c | 0 .../avr/drivers/ps2}/ps2_usart.c | 1 + .../chibios/drivers/ps2/ps2_io.c | 0 tmk_core/protocol.mk | 28 +++++++++++++------ 10 files changed, 21 insertions(+), 14 deletions(-) rename {tmk_core/protocol => drivers/ps2}/ps2.h (100%) rename {tmk_core/protocol => drivers/ps2}/ps2_busywait.c (100%) rename {tmk_core/protocol => drivers/ps2}/ps2_interrupt.c (100%) rename {tmk_core/protocol => drivers/ps2}/ps2_io.h (100%) rename {tmk_core/protocol => drivers/ps2}/ps2_mouse.c (99%) rename {tmk_core/protocol => drivers/ps2}/ps2_mouse.h (100%) rename tmk_core/protocol/ps2_io_avr.c => platforms/avr/drivers/ps2/ps2_io.c (100%) rename {tmk_core/protocol => platforms/avr/drivers/ps2}/ps2_usart.c (99%) rename tmk_core/protocol/ps2_io_chibios.c => platforms/chibios/drivers/ps2/ps2_io.c (100%) diff --git a/tmk_core/protocol/ps2.h b/drivers/ps2/ps2.h similarity index 100% rename from tmk_core/protocol/ps2.h rename to drivers/ps2/ps2.h diff --git a/tmk_core/protocol/ps2_busywait.c b/drivers/ps2/ps2_busywait.c similarity index 100% rename from tmk_core/protocol/ps2_busywait.c rename to drivers/ps2/ps2_busywait.c diff --git a/tmk_core/protocol/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c similarity index 100% rename from tmk_core/protocol/ps2_interrupt.c rename to drivers/ps2/ps2_interrupt.c diff --git a/tmk_core/protocol/ps2_io.h b/drivers/ps2/ps2_io.h similarity index 100% rename from tmk_core/protocol/ps2_io.h rename to drivers/ps2/ps2_io.h diff --git a/tmk_core/protocol/ps2_mouse.c b/drivers/ps2/ps2_mouse.c similarity index 99% rename from tmk_core/protocol/ps2_mouse.c rename to drivers/ps2/ps2_mouse.c index 39251a643437..ef7264b71ba0 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 . */ #include - -#if defined(__AVR__) -# include -#endif - #include "ps2_mouse.h" #include "wait.h" +#include "gpio.h" #include "host.h" #include "timer.h" #include "print.h" diff --git a/tmk_core/protocol/ps2_mouse.h b/drivers/ps2/ps2_mouse.h similarity index 100% rename from tmk_core/protocol/ps2_mouse.h rename to drivers/ps2/ps2_mouse.h diff --git a/tmk_core/protocol/ps2_io_avr.c b/platforms/avr/drivers/ps2/ps2_io.c similarity index 100% rename from tmk_core/protocol/ps2_io_avr.c rename to platforms/avr/drivers/ps2/ps2_io.c diff --git a/tmk_core/protocol/ps2_usart.c b/platforms/avr/drivers/ps2/ps2_usart.c similarity index 99% rename from tmk_core/protocol/ps2_usart.c rename to platforms/avr/drivers/ps2/ps2_usart.c index 5f70083698fa..151cfcd68f3a 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 #include #include +#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 similarity index 100% rename from tmk_core/protocol/ps2_io_chibios.c rename to platforms/chibios/drivers/ps2/ps2_io.c diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 30c87a0f124a..6e3146dc4674 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -1,29 +1,39 @@ -PROTOCOL_DIR = protocol - ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes) - SRC += $(PROTOCOL_DIR)/ps2_mouse.c + PS2_ENABLE := yes + SRC += 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 + PS2_ENABLE := yes + SRC += ps2_busywait.c + SRC += 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 + PS2_ENABLE := yes + SRC += ps2_interrupt.c + SRC += ps2_io.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 + 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 + + +PROTOCOL_DIR = protocol ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes) SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c From 0d4663c979103b014477a244048db55ae304e1b4 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 20 Oct 2021 20:55:18 +0100 Subject: [PATCH 2/3] clang --- drivers/ps2/ps2_mouse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c index ef7264b71ba0..8a6668b41069 100644 --- a/drivers/ps2/ps2_mouse.c +++ b/drivers/ps2/ps2_mouse.c @@ -154,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 From 9221e2e2b8d754965875ca56a9e945bad709c04d Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 20 Oct 2021 21:01:56 +0100 Subject: [PATCH 3/3] Move makefile logic --- common_features.mk | 34 ++++++++++++++++++++++++++++++++++ tmk_core/protocol.mk | 35 ----------------------------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/common_features.mk b/common_features.mk index 9b9425dc33cd..083aa4aaa4f5 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.mk b/tmk_core/protocol.mk index 6e3146dc4674..8aa063c9116c 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -1,38 +1,3 @@ -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 - - PROTOCOL_DIR = protocol ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes)