From 58a5030661b57f1dd05693053df2eddadc285f64 Mon Sep 17 00:00:00 2001
From: Drashna Jaelre <drashna@live.com>
Date: Sat, 21 Aug 2021 13:34:44 -0700
Subject: [Keymap] Drashna's Improve OLEDs and custom Split code (#14063)

* Fill the oleds with right mods

* Enable double mods on x32 oleds

* Disable forced NKRO

* Make oleds fancy only on good MCUs

* Overhaul oled display

* Further enhance oled, with kitty!

* Final oled form

* Not working transport

* Transport id of woring

* Add acceleration

* fix button placement for accel macro

* Fix accelartion location and behavior

* Remove OLED sync code

* Fix alignment issue

* Remove audio hack

* Fix up zima keymap

* Add matrix slave scan function and cleanup drashna.h

* Clean up user space

* Allow userspace sync to be disable-able

* Fix weird issue with audio

* Fix alignment issue with user split sync

* Disable second rgb matrix task

* Disable additional animations

* Change dynamic keymap settings

* Hacky fix for borked corne

* Add Blackpill (F411) support to tractyl manuform

* remove manual via eeprom reset

* Remove all references to rgblight twinkle

* Fix issues with config processing
---
 users/drashna/transport_sync.c | 122 +++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 59 deletions(-)

(limited to 'users/drashna/transport_sync.c')

diff --git a/users/drashna/transport_sync.c b/users/drashna/transport_sync.c
index c3ef2eff5b..fdd596c04c 100644
--- a/users/drashna/transport_sync.c
+++ b/users/drashna/transport_sync.c
@@ -1,30 +1,44 @@
-#ifdef SPLIT_TRANSACTION_IDS_USER
-#    include "transport_sync.h"
-#    include "transactions.h"
-#    include <string.h>
-
-#    ifdef UNICODE_ENABLE
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're  (@drashna) <drashna@live.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "transport_sync.h"
+#include "transactions.h"
+#include <string.h>
+
+#ifdef UNICODE_ENABLE
 extern unicode_config_t unicode_config;
-#    endif
-#    ifdef AUDIO_ENABLE
-#        include "audio.h"
-#    endif
-#    if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
+#endif
+#ifdef AUDIO_ENABLE
+#    include "audio.h"
+extern bool delayed_tasks_run;
+#endif
+#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
 extern bool tap_toggling;
-#    endif
-#    ifdef SWAP_HANDS_ENABLE
+#endif
+#ifdef SWAP_HANDS_ENABLE
 extern bool swap_hands;
-#    endif
+#endif
 extern userspace_config_t userspace_config;
 
-typedef struct {
-    bool     oled_on;
-    bool     audio_enable;
-    bool     audio_clicky_enable;
-    bool     tap_toggling;
-    bool     unicode_mode;
-    bool     swap_hands;
-    uint8_t  reserved :2;
+__attribute__((aligned(8))) typedef struct {
+    bool audio_enable;
+    bool audio_clicky_enable;
+    bool tap_toggling;
+    bool unicode_mode;
+    bool swap_hands;
 } user_runtime_config_t;
 
 uint16_t transport_keymap_config    = 0;
@@ -57,58 +71,49 @@ void keyboard_post_init_transport_sync(void) {
 
 void user_transport_update(void) {
     if (is_keyboard_master()) {
-#    ifdef OLED_DRIVER_ENABLE
-        user_state.oled_on = is_oled_on();
-#    endif
-
         transport_keymap_config    = keymap_config.raw;
         transport_userspace_config = userspace_config.raw;
-#    ifdef AUDIO_ENABLE
+#ifdef AUDIO_ENABLE
         user_state.audio_enable        = is_audio_on();
         user_state.audio_clicky_enable = is_clicky_on();
-#    endif
-#    if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
+#endif
+#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
         user_state.tap_toggling = tap_toggling;
-#    endif
-#    ifdef SWAP_HANDS_ENABLE
+#endif
+#ifdef SWAP_HANDS_ENABLE
         user_state.swap_hands = swap_hands;
-#    endif
+#endif
 
     } else {
-#    ifdef OLED_DRIVER_ENABLE
-        if (user_state.oled_on) {
-            oled_on();
-        } else {
-            oled_off();
-        }
-#    endif
         keymap_config.raw    = transport_keymap_config;
         userspace_config.raw = transport_userspace_config;
-#    ifdef UNICODE_ENABLE
+#ifdef UNICODE_ENABLE
         unicode_config.input_mode = user_state.unicode_mode;
-#    endif
-#    ifdef AUDIO_ENABLE
-        if (user_state.audio_enable != is_audio_on()) {
-            if (user_state.audio_enable) {
-                audio_on();
-            } else {
-                audio_off();
+#endif
+#ifdef AUDIO_ENABLE
+        if (delayed_tasks_run) {
+            if (user_state.audio_enable != is_audio_on()) {
+                if (user_state.audio_enable) {
+                    audio_on();
+                } else {
+                    audio_off();
+                }
             }
-        }
-        if (user_state.audio_clicky_enable != is_clicky_on()) {
-            if (user_state.audio_clicky_enable) {
-                clicky_on();
-            } else {
-                clicky_off();
+            if (user_state.audio_clicky_enable != is_clicky_on()) {
+                if (user_state.audio_clicky_enable) {
+                    clicky_on();
+                } else {
+                    clicky_off();
+                }
             }
         }
-#    endif
-#    if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
+#endif
+#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
         tap_toggling = user_state.tap_toggling;
-#    endif
-#    ifdef SWAP_HANDS_ENABLE
+#endif
+#ifdef SWAP_HANDS_ENABLE
         swap_hands = user_state.swap_hands;
-#    endif
+#endif
     }
 }
 
@@ -185,4 +190,3 @@ void housekeeping_task_user(void) {
     // Data sync from master to slave
     user_transport_sync();
 }
-#endif
-- 
cgit v1.2.3