ergodox-firmware/src/keyboard/layout.h

107 lines
3.8 KiB
C

/* ----------------------------------------------------------------------------
* ergoDOX : layout : saneo : exports
* ----------------------------------------------------------------------------
* Copyright (c) 2012 Ben Blazak <benblazak.dev@gmail.com>
* Released under The MIT License (MIT) (see "license.md")
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <avr/pgmspace.h>
#include "./keyboard.h"
typedef void (*void_funptr_t)(void);
// --------------------------------------------------------------------
uint8_t main_layers_top_layer (void);
uint8_t main_layers_top_sticky (void);
uint8_t main_layers_sticky (uint8_t layer);
void main_layers_enable (uint8_t layer, uint8_t sticky);
void main_layers_disable (uint8_t layer);
void main_layers_disable_top (void);
// basic
void kbfun_press_release (void);
void kbfun_press_release_preserve_sticky (void);
void kbfun_toggle (void);
void kbfun_transparent (void);
// layer functions
void kbfun_layer_enable (void);
void kbfun_layer_sticky (void);
void kbfun_layer_disable (void);
// device
void kbfun_jump_to_bootloader (void);
// special
void kbfun_shift_press_release (void);
void kbfun_control_press_release (void);
void kbfun_2_keys_capslock_press_release (void);
void kbfun_mediakey_press_release (void);
// private
void _kbfun_press_release (bool press, uint8_t keycode);
bool _kbfun_is_pressed (uint8_t keycode);
void _kbfun_mediakey_press_release (bool press, uint8_t keycode);
uint8_t _kbfun_get_keycode (void);
// device
void kbfun_jump_to_bootloader(void);
// --------------------------------------------------------------------
/*
* matrix 'get' macros, and `extern` matrix declarations
*
* These are written for when the matrices are stored solely in Flash.
* Layouts may redefine them if they wish and use Flash, RAM, EEPROM,
* or any combination of the three, as long as they maintain the same
* interface.
*
* - If the macro is overridden, the matrix declaration must be too,
* and vice versa.
*
* - 'set' functions are optional, and should be defined in the layout
* specific '.h'. They'll require the use of the EEPROM, possibly in
* clever conjunction with one of the other two memories (since the
* EEPROM is small). Custom key functions will also need to be
* written.
*
* - To override these macros with real functions, set the macro equal
* to itself (e.g. `#define kb_layout_get kb_layout_get`) and provide
* function prototypes, in the layout specific '.h'
*/
#ifndef kb_layout_get
extern const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS];
#define kb_layout_get(layer,row,column) \
( (uint8_t) \
pgm_read_byte(&( \
_kb_layout[layer][row][column] )) )
#endif
#ifndef kb_layout_press_get
extern const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS];
#define kb_layout_press_get(layer,row,column) \
( (void_funptr_t) \
pgm_read_word(&( \
_kb_layout_press[layer][row][column] )) )
#endif
#ifndef kb_layout_release_get
extern const void_funptr_t PROGMEM \
_kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS];
#define kb_layout_release_get(layer,row,column) \
( (void_funptr_t) \
pgm_read_word(&( \
_kb_layout_release[layer][row][column] )) )
#endif