Skip to content

Customizable layouts

Gal Zaidenstein edited this page Jan 30, 2020 · 9 revisions

Customizing your layouts

  1. Set the number of keypads on your board (currently maximum 2 pads) by setting KEYPADS.
  2. Define the size of your matrix by setting MATRIX_ROWS and MATRIX_COLS, Note that currently it is assumed the pads have equally sized matrices with size MATRIX_ROWSxMATRIX_COLS each .
  3. Set the direction of your diodes (COL2ROW or ROW2COL).
  4. If rotary encoders are used set ENCODER_A_PIN, ENCODER_B_PIN and ENCODER_S_PIN.
  5. For NKRO support uncomment NKRO. note that NKRO does not mostly work properly on Android and iOS, due to mtu size. with NKRO disabled MK32 supports 18KRO.

Editing matrix.c

Set the pins you would like to use on each row and column by modifying MATRIX_ROWS_PINS[] and MATRIX_COLS_PINS[], it is assumed that the matrix pins for each pad are identical.

It is important to note that:

  • You set the correct number of pins for rows/columns as defined in keyboard_config.h
  • GPIO6-11 are usually used for SPI flash
  • GPIO34-39 can only be set as input mode and do not have software pullup or pulldown functions, as of now they should not be used for the keyboard matrix itself.
  • GPIOS 0,2,4,12-15,25-27,32-39 Can be used as RTC GPIOS as well (please read about power management in ReadMe)

Editing keymap.c

  • The keycodes are identical to QMK in order to make things easier.
  • You can set different keymaps, encoder layers and macros.

Adding keymap layers
**Note: It's important to keep the order of arrays and enums consistent for proper functionality.
Make sure the amount of layers set is identical to the amount set in keyboard_config.h

  1. Add the keymaps by name to enum custom_keycodes.
  2. Add the the layout as LAYOUTNAME_H by order to the layer_holds enum,and set the first layout name equal to LAYER_HOLD_BASE_VAL, you can then use LAYOUTNAME_H as a keycode for layer change on hold key hold.
  3. Add the name of the keymaps to char default_layout_names[LAYERS][MAX_LAYOUT_NAME_LENGTH].
  4. Create a keymap matrix with the correct size, for example:

uint16_t _QWERTY[MATRIX_ROWS][KEYMAP_COLS]={

		/* Qwerty
		 * ,------------------------------------------------------------------------------------.
		 * | Esc  |   Q  |   W  |   E   |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | Bksp |
		 * |------+------+------+-------+------+-------------+------+------+------+------+------|
		 * | Tab  |   A  |   S  |   D   |   F  |   G  |   H  |   J  |   K  |   L  |   ;  |  '   |
		 * |------+------+------+-------+------+------|------+------+------+------+------+------|
		 * | Shift|   Z  |   X  |   C   |   V  |   B  |   N  |   M  |   ,  |   .  |   /  |Enter |
		 * |------+------+------+-------+------+------+------+------+------+------+------+------|
		 * | Ctrl | GUI  |  Alt |Default|Lower |Space |Space |Raise | Left | Down |  Up  |Right |
		 * `------------------------------------------------------------------------------------'
		 */

		  {KC_ESC,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC },
		  {KC_TAB,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT },
		  {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT } ,
		  {KC_LCTRL,KC_LGUI, KC_LALT, DEFAULT,  LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT }

};
  1. Add a refrence to your matrix to uint16_t (*default_layouts[])[MATRIX_ROWS][KEYMAP_COLS].

Adding macros

  1. Set the amount of macros you would like to have with MACROS_NUM.
  2. Set your macro variable names in enum custom_macros, make sure the first macro is set equal to MACRO_BASE_VAL.
  3. Add your macro to uint16_t macros[MACROS_NUM][MACRO_LEN] (macros are currently only enabled for 3 keys).

Adding encoder layouts

  1. To add encoder layouts modify uint8_t default_encoder_map[LAYERS][ENCODER_SIZE] or uint8_t default_SLAVE_encoder_map[LAYERS][ENCODER_SIZE] accordingly.
    each element should be set as: {ENCODER_TYPE ,COUNTER_CLOCKWISE, CLOCKWISE,CLICK}.

  2. First element in encoder array should be set to the type of keycode you would like to set:
    MEDIA_ENCODER,MOUSE_ENCODER, or KEY_ENCODER.

  3. Add your macro to uint16_t macros[MACROS_NUM][MACRO_LEN] (macros are currently only enabled for 3 keys).