2012-04-10 10:44:27 +02:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* key functions: 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>
|
|
|
|
* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef KEY_FUNCTIONS_h
|
|
|
|
#define KEY_FUNCTIONS_h
|
|
|
|
|
2012-04-29 08:40:00 +02:00
|
|
|
#include "lib/data-types.h"
|
2012-04-10 10:44:27 +02:00
|
|
|
|
bugfix (mostly): changed the way layers are handled
before, if you pressed a key, then shifted layers, then released it, the
first layer's press() would be called, and the 2nd layer's release()
would be called, causing keys to stick, and probably other errors. now,
the layer that the key was on when it was pressed is kept track of, and
the proper release() is called.
also, layers can be shifted per key now, instead of just for the whole
board at once
i also changed how keyboard-private includes are handled. "private"
stuff is now in its own file, instead of being nested in an extra
`#ifdef`.
and i think that's it. i'm pretty tired right now, so there may be
errors, but it seemed to work all right with cursory tests.
2012-06-11 12:27:34 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
// include the appropriate 'matrix.h'
|
|
|
|
// -------
|
|
|
|
// we're not simply including 'keyboard.h' here because this header is
|
|
|
|
// meant to be included by 'keyboard/layout/*.c', which is indirectly
|
|
|
|
// included by 'keyboard.h'; and that would lead to a circular include,
|
|
|
|
// which gcc might (depending on the order of include statements it
|
|
|
|
// encounters) deal with by processing this file before 'matrix.h',
|
|
|
|
// which would give us undefined macros here
|
|
|
|
#undef _str
|
|
|
|
#undef _expstr
|
|
|
|
#undef _inc
|
|
|
|
#define _str(s) #s // stringify
|
|
|
|
#define _expstr(s) _str(s) // expand -> stringify
|
|
|
|
#define _inc _expstr(keyboard/MAKEFILE_KEYBOARD/matrix.h) // inc(lude)
|
|
|
|
#include _inc
|
|
|
|
#undef _str
|
|
|
|
#undef _expstr
|
|
|
|
#undef _inc
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#define KBFUN_FUNCTION_ARGS \
|
2012-06-15 07:02:57 +02:00
|
|
|
uint8_t keycode_, \
|
|
|
|
bool pressed_, \
|
|
|
|
uint8_t * current_layer_, \
|
bugfix (mostly): changed the way layers are handled
before, if you pressed a key, then shifted layers, then released it, the
first layer's press() would be called, and the 2nd layer's release()
would be called, causing keys to stick, and probably other errors. now,
the layer that the key was on when it was pressed is kept track of, and
the proper release() is called.
also, layers can be shifted per key now, instead of just for the whole
board at once
i also changed how keyboard-private includes are handled. "private"
stuff is now in its own file, instead of being nested in an extra
`#ifdef`.
and i think that's it. i'm pretty tired right now, so there may be
errors, but it seemed to work all right with cursory tests.
2012-06-11 12:27:34 +02:00
|
|
|
uint8_t (*current_layers_)[KB_ROWS][KB_COLUMNS], \
|
|
|
|
uint8_t (*pressed_layers_)[KB_ROWS][KB_COLUMNS], \
|
2012-06-15 07:02:57 +02:00
|
|
|
uint8_t * row_, \
|
|
|
|
uint8_t * col_
|
bugfix (mostly): changed the way layers are handled
before, if you pressed a key, then shifted layers, then released it, the
first layer's press() would be called, and the 2nd layer's release()
would be called, causing keys to stick, and probably other errors. now,
the layer that the key was on when it was pressed is kept track of, and
the proper release() is called.
also, layers can be shifted per key now, instead of just for the whole
board at once
i also changed how keyboard-private includes are handled. "private"
stuff is now in its own file, instead of being nested in an extra
`#ifdef`.
and i think that's it. i'm pretty tired right now, so there may be
errors, but it seemed to work all right with cursory tests.
2012-06-11 12:27:34 +02:00
|
|
|
|
|
|
|
typedef void (*kbfun_funptr_t)( KBFUN_FUNCTION_ARGS );
|
|
|
|
|
2012-06-15 23:36:50 +02:00
|
|
|
void kbfun_press ( KBFUN_FUNCTION_ARGS );
|
|
|
|
void kbfun_release ( KBFUN_FUNCTION_ARGS );
|
|
|
|
void kbfun_layer_set ( KBFUN_FUNCTION_ARGS );
|
|
|
|
void kbfun_layer_inc ( KBFUN_FUNCTION_ARGS );
|
|
|
|
void kbfun_layer_dec ( KBFUN_FUNCTION_ARGS );
|
|
|
|
void kbfun_2_keys_capslock_press_release ( KBFUN_FUNCTION_ARGS );
|
2012-04-10 10:44:27 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|