(still working on keys and stuff)
parent
76c4bb6c1f
commit
f7ba0b6497
|
@ -19,10 +19,11 @@
|
|||
* declined to be added to the copyright above).
|
||||
* - Transcribed by Ben Blazak when the layout format changed.
|
||||
*
|
||||
* TODO: fix this file, after the qwerty layout is done
|
||||
* TODO: rearrange things to put a btldr key somewhere
|
||||
*/
|
||||
|
||||
|
||||
#include "../../../../firmware/keyboard/ergodox/matrix.h"
|
||||
#include "./default/common.h"
|
||||
|
||||
|
||||
|
|
|
@ -19,23 +19,11 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "../../../../../firmware/keyboard.h"
|
||||
#include "../../../../../firmware/lib/layout/key-functions.h"
|
||||
#include "../../../../../firmware/lib/usb/usage-page/keyboard.h"
|
||||
#include "../../../../../firmware/lib/usb.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
kf__function_pointer_t press_function;
|
||||
uint16_t press_value;
|
||||
kf__function_pointer_t release_function;
|
||||
uint16_t release_value;
|
||||
} key_t;
|
||||
|
||||
#define KEY_T const key_t * const PROGMEM
|
||||
#include "../../../../../firmware/lib/usb/usage-page/keyboard.h"
|
||||
#include "../../../../../firmware/lib/layout/key-functions.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern KEY_T layout[][KB__ROWS][KB__COLUMNS];
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Extended (from the definitions in ".../lib/layout/keys.h") default key
|
||||
* definitions. Feel free not to use them, if they're not convenient.
|
||||
* This file implements and extends the definitions in ".../lib/layout/keys.h"
|
||||
*/
|
||||
|
||||
|
||||
|
@ -20,21 +19,13 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the "press" function for "name"
|
||||
#define P(name) keys__press__##name
|
||||
|
||||
// the "release" function for "name"
|
||||
#define R(name) keys__release__##name
|
||||
#define F(name) keys__function__##name
|
||||
|
||||
// the "chord" function for "name"
|
||||
#define C(name) keys__chord__##name
|
||||
|
||||
// the "key"; for putting the keys into the layout matrix
|
||||
// "key"; to help with putting the keys into the layout matrix
|
||||
#define K(name) { &P(name), &R(name) }
|
||||
|
||||
// the "function" for "name"
|
||||
#define F(name) keys__function__##name
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// note: needed by ".../lib/layout/keys.h"
|
||||
|
@ -49,44 +40,19 @@
|
|||
void R(name) (void) { F(release)(value); \
|
||||
F(release)(KEY__LeftShift); }
|
||||
|
||||
// note: for implementing chorded layouts such as asetniop (or chordmak)
|
||||
// TODO: not sure if this is how we want to do this
|
||||
#define KEYS__CHORD__CHARACTER(name, threshold, keycode) \
|
||||
void C(char__##name) (bool pressed) { \
|
||||
static counter = 0; \
|
||||
if (pressed) { \
|
||||
counter++; \
|
||||
} \
|
||||
if (counter == (threshold) && !pressed) { \
|
||||
F(press)(keycode); \
|
||||
usb__kb__send_report(); \
|
||||
F(release)(keycode); \
|
||||
} \
|
||||
if (!pressed) { \
|
||||
counter--; \
|
||||
} \
|
||||
}
|
||||
// TODO: dunno if this is right at all.....
|
||||
#define KEYS__CHORD__COMBINATION(name, threshold, names...) \
|
||||
void C(comb__##name) (bool pressed) { \
|
||||
static counter = 0; \
|
||||
if (pressed) { \
|
||||
counter++; \
|
||||
} \
|
||||
if (counter == (threshold) && !pressed) { \
|
||||
names \
|
||||
} \
|
||||
if (!pressed) { \
|
||||
counter--; \
|
||||
} \
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void F(press) (uint8_t keycode) { usb__kb__set_key(true, keycode); }
|
||||
void F(release) (uint8_t keycode) { usb__kb__set_key(false, keycode); }
|
||||
|
||||
void C(2_keys_caps)(bool pressed, uint8_t keycode) {
|
||||
void F(toggle)(uint8_t keycode) {
|
||||
if (usb__kb__read_key(keycode))
|
||||
usb__kb__set_key(false, keycode);
|
||||
else
|
||||
usb__kb__set_key(true, keycode);
|
||||
}
|
||||
|
||||
void F(2_keys_caps)(bool pressed, uint8_t keycode) {
|
||||
static counter = 0;
|
||||
if (pressed) {
|
||||
counter++;
|
||||
|
@ -121,21 +87,21 @@ void R(nop) (void) {}
|
|||
|
||||
// --- special keycode --------------------------------------------------------
|
||||
|
||||
KEYS__DEFAULT( power, KEY__Power );
|
||||
KEYS__DEFAULT( volumeU, KEY__VolumeUp );
|
||||
KEYS__DEFAULT( volumeD, KEY__VolumeDown );
|
||||
KEYS__DEFAULT( mute, KEY__Mute );
|
||||
KEYS__DEFAULT( power, KEY__Power );
|
||||
KEYS__DEFAULT( volumeU, KEY__VolumeUp );
|
||||
KEYS__DEFAULT( volumeD, KEY__VolumeDown );
|
||||
KEYS__DEFAULT( mute, KEY__Mute );
|
||||
|
||||
|
||||
// --- special function -------------------------------------------------------
|
||||
|
||||
// shL2kcaps : left shift + toggle capslock (if both shifts are pressed)
|
||||
void P(shL2kcaps) (void) { C(2_keys_caps)(true, KEY__LeftShift); }
|
||||
void R(shL2kcaps) (void) { C(2_keys_caps)(false, KEY__LeftShift); }
|
||||
void P(shL2kcaps) (void) { F(2_keys_caps)(true, KEY__LeftShift); }
|
||||
void R(shL2kcaps) (void) { F(2_keys_caps)(false, KEY__LeftShift); }
|
||||
|
||||
// shR2kcaps : right shift + toggle capslock (if both shifts are pressed)
|
||||
void P(shR2kcaps) (void) { C(2_keys_caps)(true, KEY__RightShift); }
|
||||
void R(shR2kcaps) (void) { C()2_keys_caps(false, KEY__RightShift); }
|
||||
void P(shR2kcaps) (void) { F(2_keys_caps)(true, KEY__RightShift); }
|
||||
void R(shR2kcaps) (void) { F()2_keys_caps(false, KEY__RightShift); }
|
||||
|
||||
// btldr : jump to the bootloader
|
||||
void P(btldr) (void) { kf__jump_to_bootloader(); }
|
|
@ -9,10 +9,11 @@
|
|||
* the symbol keys on the function layer was taken from the Arensito layout.
|
||||
*
|
||||
* Implements the "layout" section of '.../firmware/keyboard.h'
|
||||
*
|
||||
* TODO: fix this file, after the qwerty layout is done
|
||||
*/
|
||||
|
||||
|
||||
#include "../../../../firmware/keyboard/ergodox/matrix.h"
|
||||
#include "./default/common.h"
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
|
||||
#include "./default/common.h"
|
||||
#include "./default/matrix.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -79,6 +78,9 @@ KEY_T NumPop = { &kf__macro__progmem, &NumPop__press,
|
|||
// layout
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "./default/matrix.h"
|
||||
|
||||
|
||||
KEY_T layout[][KB__ROWS][KB__COLUMNS] = {
|
||||
|
||||
// ............................................................................
|
||||
|
|
|
@ -28,18 +28,6 @@ typedef void (*kf__function_pointer_t)(uint16_t value);
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// basic
|
||||
void kf__press (uint16_t keycode);
|
||||
void kf__release (uint16_t keycode);
|
||||
void kf__toggle (uint16_t keycode);
|
||||
void kf__layer__push (uint16_t id__layer);
|
||||
void kf__layer__pop (uint16_t id__ignore);
|
||||
// void kf__macro__sram (uint16_t pointer); // TODO
|
||||
void kf__macro__progmem (uint16_t pointer);
|
||||
// void kf__macro__eeprom (uint16_t pointer); // TODO
|
||||
void kf__chord__press__progmem (uint16_t pointer); // TODO: write doc.
|
||||
void kf__chord__release__progmem (uint16_t pointer); // TODO: write doc.
|
||||
|
||||
// TODO: switch to using two functions per key. pay *careful* attention to how
|
||||
// much space the functions are likely to use, lol (but, a function that simply
|
||||
// calls another function with one argument looks like it might be only 4
|
||||
|
@ -49,17 +37,12 @@ void kf__chord__release__progmem (uint16_t pointer); // TODO: write doc.
|
|||
// - macros
|
||||
// - chords
|
||||
// - sticky keys
|
||||
// - dead keys
|
||||
|
||||
// TODO: kf__macro__eeprom
|
||||
// - this should probably go into its own little place in 'lib'; it'll need a
|
||||
// function to write the macro to memory, code to keep track of what's
|
||||
// written in the eeprom, and stuff like that
|
||||
//
|
||||
// TODO: kf__macro__sram
|
||||
// - is this necessary? will it be confusing (if we already have
|
||||
// kf__macro__eeprom)? we should probably remove it.
|
||||
|
||||
// device
|
||||
void kf__jump_to_bootloader (uint16_t ignore);
|
||||
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (see "doc/licenses/MIT.md")
|
||||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** description
|
||||
* Implements the "basic" section of
|
||||
* ".../firmware/lib/layout/key-functions.h"
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "../../../../firmware/keyboard.h"
|
||||
#include "../../../../firmware/lib/usb.h"
|
||||
#include "../../../../firmware/lib/layout/layer-stack.h"
|
||||
#include "../key-functions.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static void _chord__progmem(bool pressed, void * pointer) { // TODO: test
|
||||
uint8_t * count = (uint8_t *) pgm_read_word( pointer );
|
||||
uint16_t threshold = (uint16_t) pgm_read_word( pointer+2 );
|
||||
void * key_pointer = (void *) pgm_read_word( pointer+4 );
|
||||
|
||||
if (pressed)
|
||||
*count++;
|
||||
|
||||
if (*count == threshold)
|
||||
kb__layout__exec_key_pointer(key_pointer);
|
||||
|
||||
if (!pressed)
|
||||
*count--;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void kf__press(uint16_t keycode) {
|
||||
usb__kb__set_key(true, keycode);
|
||||
usb__kb__send_report();
|
||||
}
|
||||
|
||||
void kf__release(uint16_t keycode) {
|
||||
usb__kb__set_key(false, keycode);
|
||||
usb__kb__send_report();
|
||||
}
|
||||
|
||||
void kf__toggle(uint16_t keycode) {
|
||||
if (usb__kb__read_key(keycode))
|
||||
usb__kb__set_key(false, keycode);
|
||||
else
|
||||
usb__kb__set_key(true, keycode):
|
||||
}
|
||||
|
||||
void kf__layer__push(uint16_t id__layer) {
|
||||
layer_stack__push( ((uint8_t)(id__layer >> 8)),
|
||||
((uint8_t)(id__layer & 0xff)) );
|
||||
}
|
||||
|
||||
void kf__layer__pop(uint16_t id__ignore) {
|
||||
layer_stack__pop_id( ((uint8_t)(id__ignore >> 8)) );
|
||||
}
|
||||
|
||||
void kf__macro__progmem(uint16_t pointer) { // TODO: test
|
||||
uint16_t last_element = pointer + 4 * (uint16_t) pgm_read_word(pointer);
|
||||
|
||||
kf__function_pointer_t function;
|
||||
uint16_t argument;
|
||||
|
||||
for(pointer += 2; pointer <= last_element; pointer += 4) {
|
||||
function = (kf__function_pointer_t) pgm_read_word( pointer );
|
||||
argument = (uint16_t) pgm_read_word( pointer+2 );
|
||||
|
||||
if (function)
|
||||
(*function)(argument);
|
||||
}
|
||||
}
|
||||
|
||||
void kf__chord__press__progmem(uint16_t pointer) {
|
||||
_chord__progmem(true, pointer);
|
||||
}
|
||||
|
||||
void kf__chord__release__progmem(uint16_t pointer) {
|
||||
_chord__progmem(false, pointer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue