commit acf6a966c4e7a176d0448f86fd32ee95f1594796
parent 2ce46c6004c655e9959f5d9326e07f32d70527bc
Author: Jack Sangdahl <jack@pngu.org>
Date: Sun, 24 Aug 2025 09:57:53 -0600
Add OS detection and modifier swapping for MacOS
Diffstat:
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/jack/config.h b/jack/config.h
@@ -7,13 +7,13 @@
#define BOTH_SHIFTS_TURNS_ON_CAPS_WORD
#define COMBO_TERM 40
#define NO_ACTION_ONESHOT
-#define UNICODE_SELECTED_MODES UNICODE_MODE_LINUX
+#define UNICODE_SELECTED_MODES UNICODE_MODE_LINUX, UNICODE_MODE_MACOS
#define ENABLE_COMPILE_KEYCODE
#define LAYER_STATE_8BIT
#undef LOCKING_SUPPORT_ENABLE
#undef LOCKING_RESYNC_ENABLE
#undef MANUFACTURER
-#define MANUFACTURER "jacks"
+#define MANUFACTURER "jack"
#ifdef OLED_ENABLE
#define OLED_FONT_H "users/jack/oledfont.h"
diff --git a/jack/jack.c b/jack/jack.c
@@ -67,6 +67,28 @@ void matrix_scan_user(void) {
#endif
}
+#ifdef OS_DETECTION_ENABLE
+typedef struct {
+ bool swap_ctl_gui;
+ uint8_t unicode_input_mode;
+} os_detection_config;
+
+bool process_detected_host_os_user(os_variant_t detected_os) {
+ os_detection_config os_config = {.swap_ctl_gui = false,
+ .unicode_input_mode = UNICODE_MODE_LINUX};
+ if (detected_os == OS_MACOS)
+ os_config = (os_detection_config){.swap_ctl_gui = true,
+ .unicode_input_mode = UNICODE_MODE_MACOS};
+ keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui =
+ os_config.swap_ctl_gui;
+ eeconfig_update_keymap(&keymap_config);
+#ifdef UNICODE_COMMON_ENABLE
+ set_unicode_input_mode(os_config.unicode_input_mode);
+#endif
+ return true;
+}
+#endif
+
#ifndef MAGIC_ENABLE
uint16_t keycode_config(uint16_t keycode) { return keycode; }
uint8_t mod_config(uint8_t mod) { return mod; }
diff --git a/jack/rules.mk b/jack/rules.mk
@@ -1,6 +1,6 @@
LTO_ENABLE = yes
TOP_SYMBOLS = yes
-MAGIC_ENABLE = no
+MAGIC_ENABLE = yes
COMBO_ENABLE = yes
COMMAND_ENABLE = no
CONSOLE_ENABLE = no
@@ -13,6 +13,7 @@ TAP_DANCE_ENABLE = yes
SPACE_CADET_ENABLE = no
AUTOCORRECT_ENABLE = yes
MOUSE_JIGGLE_ENABLE = yes
+OS_DETECTION_ENABLE = yes
CUSTOM_TAP_CODE_ENABLE = no
DEBOUNCE_TYPE = asym_eager_defer_pk
AVR_CFLAGS += -mrelax