master
Stefan Dorn 2016-06-12 02:54:30 +01:00
parent 1b7a4b23fd
commit 238a98d6b6
5 changed files with 35 additions and 117 deletions

View File

@ -222,8 +222,6 @@ class Layout
// ----------------------------------------------------------------------------
// ergoDOX layout : saneo (generated)
// ----------------------------------------------------------------------------
#include "./layout.h"
// ----------------------------------------------------------------------------
HEADER
@ -233,9 +231,9 @@ HEADER
File.open(LayoutFile, "w+") do |f|
f.puts header
f.puts "const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{keys} };"
f.puts "const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{downs} };"
f.puts "const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{ups} };"
f.puts "static const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{keys} };"
f.puts "static const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{downs} };"
f.puts "static const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { #{ups} };"
end
end
end

View File

@ -1,10 +1,8 @@
// ----------------------------------------------------------------------------
// ergoDOX layout : saneo (generated)
// ----------------------------------------------------------------------------
#include "./layout.h"
// ----------------------------------------------------------------------------
const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
static const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
(uint8_t) KEY_NULL,
(uint8_t) KEY_0_RightParenthesis,
(uint8_t) KEY_1_Exclamation,
@ -336,7 +334,7 @@ KB_MATRIX_LAYER(
(uint8_t) KEY_NULL,
(uint8_t) KEY_NULL),
};
const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
static const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
(void_funptr_t) &kbfun_transparent,
(void_funptr_t) &kbfun_press_release,
(void_funptr_t) &kbfun_press_release,
@ -668,7 +666,7 @@ KB_MATRIX_LAYER(
(void_funptr_t) &kbfun_transparent,
(void_funptr_t) &kbfun_press_release),
};
const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
static const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { KB_MATRIX_LAYER(
(void_funptr_t) &kbfun_transparent,
(void_funptr_t) &kbfun_press_release,
(void_funptr_t) &kbfun_press_release,

View File

@ -1,106 +0,0 @@
/* ----------------------------------------------------------------------------
* 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

View File

@ -7,6 +7,7 @@
* ------------------------------------------------------------------------- */
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdbool.h>
#include <stdbool.h>
#include <stdint.h>
@ -14,13 +15,15 @@
#include <util/delay.h>
#include <util/delay.h>
#include "./keyboard/controller.c"
#include "./keyboard/layout.c"
#include "./keyboard/keyboard.h"
// --------------------------------------------------------------------
// types and forward declarations
// --------------------------------------------------------------------
typedef void (*void_funptr_t)(void);
typedef enum StickyState {
eStickyNone,
eStickyOnceDown,
@ -48,6 +51,10 @@ static bool (*main_kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_main_kb_was_pressed;
static bool main_kb_was_transparent[KB_ROWS][KB_COLUMNS];
static uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS];
static const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS];
static const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS];
static const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS];
static uint8_t main_arg_layer;
static uint8_t main_arg_layer_offset;
static uint8_t main_arg_row;
@ -178,6 +185,18 @@ void main_exec_key(void) {
// ----------------------------------------------------------------------------
uint8_t kb_layout_get(uint8_t layer, uint8_t row, uint8_t column) {
return (uint8_t) pgm_read_byte(&(_kb_layout[layer][row][column] ));
}
void_funptr_t kb_layout_press_get(uint8_t layer, uint8_t row, uint8_t column) {
return (void_funptr_t) pgm_read_word(&(_kb_layout_press[layer][row][column] ));
}
void_funptr_t kb_layout_release_get(uint8_t layer, uint8_t row, uint8_t column) {
return (void_funptr_t) pgm_read_word(&(_kb_layout_release[layer][row][column]));
}
/*
* Generate a normal keypress or keyrelease
*
@ -596,3 +615,9 @@ void main_key_loop() {
_delay_ms(5);
}
}
// ---------------------------------------------------------------------------------
// generated keyboard layout
// ---------------------------------------------------------------------------------
#include "./keyboard/layout.c"

View File

@ -15,6 +15,9 @@ uint8_t _kbfun_get_keycode();
void _kbfun_mediakey_press_release(bool press,uint8_t keycode);
bool _kbfun_is_pressed(uint8_t keycode);
void _kbfun_press_release(bool press,uint8_t keycode);
uint8_t kb_layout_get(uint8_t layer,uint8_t row,uint8_t column);
void_funptr_t kb_layout_release_get(uint8_t layer,uint8_t row,uint8_t column);
void_funptr_t kb_layout_press_get(uint8_t layer,uint8_t row,uint8_t column);
void main_exec_key(void);
uint8_t main_layers_peek(uint8_t offset);
void main_layers_disable_top();