From cf85efce22f8a45ca3eb97902c9b2a3ca47f67d1 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 29 Sep 2024 00:38:48 +0900 Subject: [PATCH] sun_usb: Add build option for sun mouse support --- converter/sun_usb/Makefile | 8 ++++++++ converter/sun_usb/Makefile.atmega32u4 | 2 ++ converter/sun_usb/sun_usb.c | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/converter/sun_usb/Makefile b/converter/sun_usb/Makefile index f2b20eaa7a..a761dc6b7d 100644 --- a/converter/sun_usb/Makefile +++ b/converter/sun_usb/Makefile @@ -62,6 +62,8 @@ COMMAND_ENABLE ?= yes # Commands for debug and configuration UNIMAP_ENABLE = yes KEYMAP_SECTION_ENABLE = yes +SUN_MOUSE_ENABLE ?= yes # Sun mouse support + # Boot Section Size in bytes # Teensy halfKay 512 @@ -89,6 +91,12 @@ else SRC := $(KEYMAP_FILE).c $(SRC) endif +ifeq (yes,$(strip $(SUN_MOUSE_ENABLE))) + OPT_DEFS += -DSUN_MOUSE_ENABLE=1 +else + OPT_DEFS += -DSUN_MOUSE_ENABLE=0 +endif + # Search Path VPATH += $(TARGET_DIR) diff --git a/converter/sun_usb/Makefile.atmega32u4 b/converter/sun_usb/Makefile.atmega32u4 index 3f721fe340..e234d15629 100644 --- a/converter/sun_usb/Makefile.atmega32u4 +++ b/converter/sun_usb/Makefile.atmega32u4 @@ -1,5 +1,7 @@ TARGET = sun_usb_atmega32u4 MCU = atmega32u4 +SUN_MOUSE_ENABLE = no # Sun mouse support + include Makefile diff --git a/converter/sun_usb/sun_usb.c b/converter/sun_usb/sun_usb.c index c9112ac2bc..72af076a32 100644 --- a/converter/sun_usb/sun_usb.c +++ b/converter/sun_usb/sun_usb.c @@ -29,6 +29,10 @@ along with this program. If not, see . #include "host.h" +#if !defined(SUN_MOUSE_ENABLE) +# define SUN_MOUSE_ENABLE 1 +#endif + // Timer count #define BAUD 1200 #define PRESCALE 8 @@ -156,6 +160,7 @@ ISR(TIMER1_COMPA_vect) } +#if SUN_MOUSE_ENABLE // // mouse uart // @@ -224,6 +229,7 @@ ISR(TIMER1_COMPC_vect) break; } } +#endif void hook_early_init(void) @@ -265,11 +271,13 @@ void hook_early_init(void) EICRA |= (1 << ISC21) | (1 << ISC20); EIMSK |= (1 << INT2); +#if SUN_MOUSE_ENABLE // mouse init suart_init(&ms_suart); // enable interrupt on rising edge for mouse EICRB |= (1 << ISC51) |(1 << ISC50); EIMSK |= (1 << INT5); +#endif sei(); } @@ -296,6 +304,7 @@ void hook_late_init(void) * the device seems to fail to follow movement and send wrong value when dragging it rapidly. * it causes opposite direction movement in the result. encoder speed limit? if not a bug in my code. */ +#if SUN_MOUSE_ENABLE void hook_main_loop(void) { static uint8_t n = 0; @@ -338,6 +347,7 @@ void hook_main_loop(void) } n = (n + 1) % 5; } +#endif /*