Questions on remapping the keyboard

Friends, I’m reading the handbook on how to remap the keyboard, but I’m afraid I don’t quite understand what to do exactly. I do apologise if I have missed a piece of documentation explaining it.

The handbook as well as the repo’s readme say I should edit the matrix arrays in keyboard.c, but I think they have been moved out to matrix.h and matrix_v.h perhaps? If so it is still unclear how to change the key mapping. The things I’d like to do are:

  • Turn HYPER to CTRL
  • Turn CTRL that’s under TAB to HYPER
  • Turn CTRL that’s between MNT and left space to ALT
  • Disable the … key (unless someone recommends a good use for it)
  • Turn the two ALTs between the space keys into space keys

If someone could tell me how to change one of the above I think I should be able to figure out the rest. Thanks!

Hej!
I changed the right part of the space bar to Ctrl by modifying Keyboard.c. The corresponding patch is:

diff --git a/reform2-keyboard-fw/Keyboard.c b/reform2-keyboard-fw/Keyboard.c
index 1dc1310..38aba7d 100644
--- a/reform2-keyboard-fw/Keyboard.c
+++ b/reform2-keyboard-fw/Keyboard.c
@@ -60,7 +60,7 @@ uint8_t matrix[COLS*6+2] = {
 
   HID_KEYBOARD_SC_LEFT_SHIFT, HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE, KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M, HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN, HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN, KEY_SLASH_AND_QUESTION_MARK,  HID_KEYBOARD_SC_UP_ARROW, HID_KEYBOARD_SC_RIGHT_SHIFT,
 
-  HID_KEYBOARD_SC_RIGHT_GUI, HID_KEYBOARD_SC_LEFT_GUI, HID_KEYBOARD_SC_RIGHT_CONTROL, KEY_SPACE, HID_KEYBOARD_SC_LEFT_ALT, HID_KEYBOARD_SC_RIGHT_ALT, KEY_SPACE, HID_KEYBOARD_SC_PAGE_UP, HID_KEYBOARD_SC_PAGE_DOWN, HID_KEYBOARD_SC_LEFT_ARROW, HID_KEYBOARD_SC_DOWN_ARROW, HID_KEYBOARD_SC_RIGHT_ARROW,  0xfe,0xed,0xca,0xfe
+  HID_KEYBOARD_SC_RIGHT_GUI, HID_KEYBOARD_SC_LEFT_GUI, HID_KEYBOARD_SC_RIGHT_CONTROL, KEY_SPACE, HID_KEYBOARD_SC_LEFT_ALT, HID_KEYBOARD_SC_RIGHT_ALT, HID_KEYBOARD_SC_RIGHT_CONTROL, HID_KEYBOARD_SC_PAGE_UP, HID_KEYBOARD_SC_PAGE_DOWN, HID_KEYBOARD_SC_LEFT_ARROW, HID_KEYBOARD_SC_DOWN_ARROW, HID_KEYBOARD_SC_RIGHT_ARROW,  0xfe,0xed,0xca,0xfe
 };
 
 /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */

But note that changing the actual keyboard firmware is not the only way you can change the keyboard mapping. I documented how I added a SysRq key on the OS level using udev which should also work for other keycodes: Remapping keyboard without firmware modification (adding SysRq key) - #3 by Chartreuse

To actually make use of the Hyper key as such (I think it acts by default as “right GUI/logo” key), you will also have to adjust the xkb config to map that modifier key. I haven’t written that part down yet but intend to do so soon.

Best of luck!

Hey @doctorhoo thank you for your help!

It seems like the matrix array has been moved out of keyboard.c.

What I don’t understand is what is the difference between matrix.h and matrix_v.h. Does anybody happen to know?

I’ve been looking into remapping the keyboard as well and it looks like the default keys are mapped in keyboard.h . I think matrix.h is for special layers toggled by hyper key and hyper+circle. Haven’t tested poking around those files and building the layout i want, i’ll report back here if it works how i think it does.

@chipperoodles ah, yes you’re right! It is quite trivial in fact to change them, thank you!

This is how I ended up tweaking the keyboard itself (the HYPER key is actually ALT):

1 Like