From 8866bc03fa91323f4077bca93d0cfb17d8e159ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=86lla=20Chiana=20Arson=20Bobbie=20Moskopp?=
 <erle@dieweltistgarnichtso.net>
Date: Thu, 25 Sep 2025 22:04:28 +0200
Subject: [PATCH] keyboard-fw: Fix Hyper layers for Neo2 keyboard layout

Both enter and M3 need to be overridden in each matrix;
if this is not done, fn or fn toggle switches the enter
key and right M3 and turns the left M3 into a ctrl key.
---
 reform2-keyboard-fw/keyboard.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/reform2-keyboard-fw/keyboard.c b/reform2-keyboard-fw/keyboard.c
index 59ec135..6fc2533 100644
--- a/reform2-keyboard-fw/keyboard.c
+++ b/reform2-keyboard-fw/keyboard.c
@@ -292,9 +292,20 @@ int main(void)
 #endif
 
 #ifdef KBD_VARIANT_NEO2
+  // Both enter and M3 need to be overridden in each matrix;
+  // if this is not done, fn or fn toggle switches the enter
+  // key and right M3 and turns the left M3 into a ctrl key.
   matrix[KBD_COLS*2+13]=KEY_ENTER;
-  matrix[KBD_COLS*3+0]=HID_KEYBOARD_SC_CAPS_LOCK; // left M3
-  matrix[KBD_COLS*3+13]=KEY_BACKSLASH_AND_PIPE; // M3
+  matrix_fn[KBD_COLS*2+13]=KEY_ENTER;
+  matrix_fn_toggled[KBD_COLS*2+13]=KEY_ENTER;
+  // left M3
+  matrix[KBD_COLS*3+0]=HID_KEYBOARD_SC_CAPS_LOCK;
+  matrix_fn[KBD_COLS*3+0]=HID_KEYBOARD_SC_CAPS_LOCK;
+  matrix_fn_toggled[KBD_COLS*3+0]=HID_KEYBOARD_SC_CAPS_LOCK;
+  // right M3
+  matrix[KBD_COLS*3+13]=KEY_BACKSLASH_AND_PIPE;
+  matrix_fn[KBD_COLS*3+13]=KEY_BACKSLASH_AND_PIPE;
+  matrix_fn_toggled[KBD_COLS*3+13]=KEY_BACKSLASH_AND_PIPE;
   #ifdef KBD_VARIANT_3
     matrix[KBD_COLS*3+12]=KEY_BACKSLASH_AND_PIPE; // M3
     matrix[KBD_COLS*5+2]=HID_KEYBOARD_SC_RIGHT_CONTROL;
-- 
2.51.0

