merge from master
This commit is contained in:
commit
3996250d81
11279 changed files with 499671 additions and 99678 deletions
|
|
@ -37,18 +37,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
# include "nodebug.h"
|
||||
#endif
|
||||
|
||||
#ifdef POINTING_DEVICE_ENABLE
|
||||
# include "pointing_device.h"
|
||||
#endif
|
||||
|
||||
int tp_buttons;
|
||||
|
||||
#ifdef RETRO_TAPPING
|
||||
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
|
||||
int retro_tapping_counter = 0;
|
||||
#endif
|
||||
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
# include <fauxclicky.h>
|
||||
# include "fauxclicky.h"
|
||||
#endif
|
||||
|
||||
#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
||||
__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode) { return false; }
|
||||
__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; }
|
||||
#endif
|
||||
|
||||
#ifdef RETRO_TAPPING_PER_KEY
|
||||
__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; }
|
||||
#endif
|
||||
|
||||
#ifndef TAP_CODE_DELAY
|
||||
|
|
@ -67,7 +75,7 @@ void action_exec(keyevent_t event) {
|
|||
dprint("EVENT: ");
|
||||
debug_event(event);
|
||||
dprintln();
|
||||
#ifdef RETRO_TAPPING
|
||||
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
|
||||
retro_tapping_counter++;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -98,6 +106,11 @@ void action_exec(keyevent_t event) {
|
|||
if (has_oneshot_mods_timed_out()) {
|
||||
clear_oneshot_mods();
|
||||
}
|
||||
# ifdef SWAP_HANDS_ENABLE
|
||||
if (has_oneshot_swaphands_timed_out()) {
|
||||
clear_oneshot_swaphands();
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -165,6 +178,8 @@ void process_record_tap_hint(keyrecord_t *record) {
|
|||
# ifdef SWAP_HANDS_ENABLE
|
||||
case ACT_SWAP_HANDS:
|
||||
switch (action.swap.code) {
|
||||
case OP_SH_ONESHOT:
|
||||
break;
|
||||
case OP_SH_TAP_TOGGLE:
|
||||
default:
|
||||
swap_hands = !swap_hands;
|
||||
|
|
@ -185,7 +200,14 @@ void process_record(keyrecord_t *record) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!process_record_quantum(record)) return;
|
||||
if (!process_record_quantum(record)) {
|
||||
#ifndef NO_ACTION_ONESHOT
|
||||
if (is_oneshot_layer_active() && record->event.pressed) {
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
process_record_handler(record);
|
||||
post_process_record_quantum(record);
|
||||
|
|
@ -206,6 +228,19 @@ void process_record_handler(keyrecord_t *record) {
|
|||
process_action(record, action);
|
||||
}
|
||||
|
||||
#if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
|
||||
void register_button(bool pressed, enum mouse_buttons button) {
|
||||
# ifdef PS2_MOUSE_ENABLE
|
||||
tp_buttons = pressed ? tp_buttons | button : tp_buttons & ~button;
|
||||
# endif
|
||||
# ifdef POINTING_DEVICE_ENABLE
|
||||
report_mouse_t currentReport = pointing_device_get_report();
|
||||
currentReport.buttons = pressed ? currentReport.buttons | button : currentReport.buttons & ~button;
|
||||
pointing_device_set_report(currentReport);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief Take an action and processes it.
|
||||
*
|
||||
* FIXME: Needs documentation.
|
||||
|
|
@ -224,7 +259,11 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
#ifndef NO_ACTION_ONESHOT
|
||||
bool do_release_oneshot = false;
|
||||
// notice we only clear the one shot layer if the pressed key is not a modifier.
|
||||
if (is_oneshot_layer_active() && event.pressed && !IS_MOD(action.key.code)) {
|
||||
if (is_oneshot_layer_active() && event.pressed && (action.kind.id == ACT_USAGE || !IS_MOD(action.key.code))
|
||||
# ifdef SWAP_HANDS_ENABLE
|
||||
&& !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
|
||||
# endif
|
||||
) {
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
do_release_oneshot = !is_oneshot_layer_active();
|
||||
}
|
||||
|
|
@ -324,7 +363,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
|
||||
if (
|
||||
# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
||||
!get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false)) &&
|
||||
!get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false), record) &&
|
||||
# endif
|
||||
record->tap.interrupted) {
|
||||
dprint("mods_tap: tap: cancel: add_mods\n");
|
||||
|
|
@ -346,6 +385,8 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
dprint("MODS_TAP: Tap: unregister_code\n");
|
||||
if (action.layer_tap.code == KC_CAPS) {
|
||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||
} else {
|
||||
wait_ms(TAP_CODE_DELAY);
|
||||
}
|
||||
unregister_code(action.key.code);
|
||||
} else {
|
||||
|
|
@ -382,37 +423,57 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
/* Mouse key */
|
||||
case ACT_MOUSEKEY:
|
||||
if (event.pressed) {
|
||||
switch (action.key.code) {
|
||||
case KC_MS_BTN1:
|
||||
tp_buttons |= (1 << 0);
|
||||
break;
|
||||
case KC_MS_BTN2:
|
||||
tp_buttons |= (1 << 1);
|
||||
break;
|
||||
case KC_MS_BTN3:
|
||||
tp_buttons |= (1 << 2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mousekey_on(action.key.code);
|
||||
mousekey_send();
|
||||
} else {
|
||||
switch (action.key.code) {
|
||||
# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
|
||||
case KC_MS_BTN1:
|
||||
tp_buttons &= ~(1 << 0);
|
||||
register_button(true, MOUSE_BTN1);
|
||||
break;
|
||||
case KC_MS_BTN2:
|
||||
tp_buttons &= ~(1 << 1);
|
||||
register_button(true, MOUSE_BTN2);
|
||||
break;
|
||||
case KC_MS_BTN3:
|
||||
tp_buttons &= ~(1 << 2);
|
||||
register_button(true, MOUSE_BTN3);
|
||||
break;
|
||||
# endif
|
||||
# ifdef POINTING_DEVICE_ENABLE
|
||||
case KC_MS_BTN4:
|
||||
register_button(true, MOUSE_BTN4);
|
||||
break;
|
||||
case KC_MS_BTN5:
|
||||
register_button(true, MOUSE_BTN5);
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
mousekey_send();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
mousekey_off(action.key.code);
|
||||
mousekey_send();
|
||||
switch (action.key.code) {
|
||||
# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
|
||||
case KC_MS_BTN1:
|
||||
register_button(false, MOUSE_BTN1);
|
||||
break;
|
||||
case KC_MS_BTN2:
|
||||
register_button(false, MOUSE_BTN2);
|
||||
break;
|
||||
case KC_MS_BTN3:
|
||||
register_button(false, MOUSE_BTN3);
|
||||
break;
|
||||
# endif
|
||||
# ifdef POINTING_DEVICE_ENABLE
|
||||
case KC_MS_BTN4:
|
||||
register_button(false, MOUSE_BTN4);
|
||||
break;
|
||||
case KC_MS_BTN5:
|
||||
register_button(false, MOUSE_BTN5);
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
mousekey_send();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
@ -593,6 +654,16 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
swap_hands = false;
|
||||
}
|
||||
break;
|
||||
# ifndef NO_ACTION_ONESHOT
|
||||
case OP_SH_ONESHOT:
|
||||
if (event.pressed) {
|
||||
set_oneshot_swaphands();
|
||||
} else {
|
||||
release_oneshot_swaphands();
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
|
||||
# ifndef NO_ACTION_TAPPING
|
||||
case OP_SH_TAP_TOGGLE:
|
||||
/* tap toggle */
|
||||
|
|
@ -658,20 +729,23 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
#endif
|
||||
|
||||
#ifndef NO_ACTION_TAPPING
|
||||
# ifdef RETRO_TAPPING
|
||||
# if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
|
||||
if (!is_tap_action(action)) {
|
||||
retro_tapping_counter = 0;
|
||||
} else {
|
||||
if (event.pressed) {
|
||||
if (tap_count > 0) {
|
||||
retro_tapping_counter = 0;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
if (tap_count > 0) {
|
||||
retro_tapping_counter = 0;
|
||||
} else {
|
||||
if (retro_tapping_counter == 2) {
|
||||
if (
|
||||
# ifdef RETRO_TAPPING_PER_KEY
|
||||
get_retro_tapping(get_event_keycode(record->event, false), record) &&
|
||||
# endif
|
||||
retro_tapping_counter == 2) {
|
||||
tap_code(action.layer_tap.code);
|
||||
}
|
||||
retro_tapping_counter = 0;
|
||||
|
|
@ -681,6 +755,14 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef SWAP_HANDS_ENABLE
|
||||
# ifndef NO_ACTION_ONESHOT
|
||||
if (event.pressed && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)) {
|
||||
use_oneshot_swaphands();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_ACTION_ONESHOT
|
||||
/* Because we switch layers after a oneshot event, we need to release the
|
||||
* key before we leave the layer or no key up event will be generated.
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_H
|
||||
#define ACTION_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -29,7 +29,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Disable macro and function features when LTO is enabled, since they break */
|
||||
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
|
||||
#ifdef LTO_ENABLE
|
||||
# ifndef NO_ACTION_MACRO
|
||||
# define NO_ACTION_MACRO
|
||||
# endif
|
||||
|
|
@ -124,5 +124,3 @@ void debug_action(action_t action);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ACTION_H */
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_CODE_H
|
||||
#define ACTION_CODE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/** \brief Action codes
|
||||
*
|
||||
|
|
@ -294,15 +294,15 @@ enum swap_hands_param_tap_op {
|
|||
OP_SH_OFF_ON,
|
||||
OP_SH_OFF,
|
||||
OP_SH_ON,
|
||||
OP_SH_ONESHOT,
|
||||
};
|
||||
|
||||
#define ACTION_SWAP_HANDS() ACTION_SWAP_HANDS_ON_OFF()
|
||||
#define ACTION_SWAP_HANDS_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TOGGLE)
|
||||
#define ACTION_SWAP_HANDS_TAP_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TAP_TOGGLE)
|
||||
#define ACTION_SWAP_HANDS_ONESHOT() ACTION(ACT_SWAP_HANDS, OP_SH_ONESHOT)
|
||||
#define ACTION_SWAP_HANDS_TAP_KEY(key) ACTION(ACT_SWAP_HANDS, key)
|
||||
#define ACTION_SWAP_HANDS_ON_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_ON_OFF)
|
||||
#define ACTION_SWAP_HANDS_OFF_ON() ACTION(ACT_SWAP_HANDS, OP_SH_OFF_ON)
|
||||
#define ACTION_SWAP_HANDS_ON() ACTION(ACT_SWAP_HANDS, OP_SH_ON)
|
||||
#define ACTION_SWAP_HANDS_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_OFF)
|
||||
|
||||
#endif /* ACTION_CODE_H */
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ uint8_t layer_switch_get_layer(keypos_t key) {
|
|||
|
||||
layer_state_t layers = layer_state | default_layer_state;
|
||||
/* check top layer first */
|
||||
for (int8_t i = sizeof(layer_state_t) * 8 - 1; i >= 0; i--) {
|
||||
for (int8_t i = MAX_LAYER - 1; i >= 0; i--) {
|
||||
if (layers & (1UL << i)) {
|
||||
action = action_for_key(i, key);
|
||||
if (action.code != ACTION_TRANSPARENT) {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_LAYER_H
|
||||
#define ACTION_LAYER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "keyboard.h"
|
||||
|
|
@ -23,12 +23,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#if defined(LAYER_STATE_8BIT)
|
||||
typedef uint8_t layer_state_t;
|
||||
# define MAX_LAYER_BITS 3
|
||||
# ifndef MAX_LAYER
|
||||
# define MAX_LAYER 8
|
||||
# endif
|
||||
# define get_highest_layer(state) biton(state)
|
||||
#elif defined(LAYER_STATE_16BIT)
|
||||
typedef uint16_t layer_state_t;
|
||||
# define MAX_LAYER_BITS 4
|
||||
# ifndef MAX_LAYER
|
||||
# define MAX_LAYER 16
|
||||
# endif
|
||||
# define get_highest_layer(state) biton16(state)
|
||||
#else
|
||||
typedef uint32_t layer_state_t;
|
||||
# define MAX_LAYER_BITS 5
|
||||
# ifndef MAX_LAYER
|
||||
# define MAX_LAYER 32
|
||||
# endif
|
||||
# define get_highest_layer(state) biton32(state)
|
||||
#endif
|
||||
|
||||
|
|
@ -70,9 +82,11 @@ void layer_on(uint8_t layer);
|
|||
void layer_off(uint8_t layer);
|
||||
void layer_invert(uint8_t layer);
|
||||
/* bitwise operation */
|
||||
void layer_or(layer_state_t state);
|
||||
void layer_and(layer_state_t state);
|
||||
void layer_xor(layer_state_t state);
|
||||
void layer_or(layer_state_t state);
|
||||
void layer_and(layer_state_t state);
|
||||
void layer_xor(layer_state_t state);
|
||||
layer_state_t layer_state_set_user(layer_state_t state);
|
||||
layer_state_t layer_state_set_kb(layer_state_t state);
|
||||
#else
|
||||
# define layer_state 0
|
||||
|
||||
|
|
@ -89,15 +103,13 @@ void layer_xor(layer_state_t state);
|
|||
# define layer_or(state) (void)state
|
||||
# define layer_and(state) (void)state
|
||||
# define layer_xor(state) (void)state
|
||||
# define layer_state_set_kb(state) (void)state
|
||||
# define layer_state_set_user(state) (void)state
|
||||
#endif
|
||||
|
||||
layer_state_t layer_state_set_user(layer_state_t state);
|
||||
layer_state_t layer_state_set_kb(layer_state_t state);
|
||||
|
||||
/* pressed actions cache */
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
/* The number of bits needed to represent the layer number: log2(32). */
|
||||
# define MAX_LAYER_BITS 5
|
||||
|
||||
void update_source_layers_cache(keypos_t key, uint8_t layer);
|
||||
uint8_t read_source_layers_cache(keypos_t key);
|
||||
#endif
|
||||
|
|
@ -108,5 +120,3 @@ uint8_t layer_switch_get_layer(keypos_t key);
|
|||
|
||||
/* return action depending on current layer status */
|
||||
action_t layer_switch_get_action(keypos_t key);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_MACRO_H
|
||||
#define ACTION_MACRO_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "progmem.h"
|
||||
|
||||
|
|
@ -120,5 +121,3 @@ enum macro_command_id {
|
|||
/* for backward comaptibility */
|
||||
#define MD(key) DOWN(KC_##key)
|
||||
#define MU(key) UP(KC_##key)
|
||||
|
||||
#endif /* ACTION_MACRO_H */
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
# define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
|
||||
# define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
|
||||
|
||||
__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPING_TERM; }
|
||||
__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; }
|
||||
|
||||
# ifdef TAPPING_TERM_PER_KEY
|
||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event, false)))
|
||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event, false), &tapping_key))
|
||||
# else
|
||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
||||
# endif
|
||||
|
|
@ -122,7 +122,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||
# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)
|
||||
else if (
|
||||
# ifdef TAPPING_TERM_PER_KEY
|
||||
(get_tapping_term(get_event_keycode(tapping_key.event, false)) >= 500) &&
|
||||
(get_tapping_term(get_event_keycode(tapping_key.event, false), keyp) >= 500) &&
|
||||
# endif
|
||||
# ifdef PERMISSIVE_HOLD_PER_KEY
|
||||
!get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp) &&
|
||||
|
|
|
|||
|
|
@ -14,16 +14,14 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_TAPPING_H
|
||||
#define ACTION_TAPPING_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/* period of tapping(ms) */
|
||||
#ifndef TAPPING_TERM
|
||||
# define TAPPING_TERM 200
|
||||
#endif
|
||||
|
||||
//#define RETRO_TAPPING // Tap anyway, even after TAPPING_TERM, as long as there was no interruption
|
||||
|
||||
/* tap count needed for toggling a feature */
|
||||
#ifndef TAPPING_TOGGLE
|
||||
# define TAPPING_TOGGLE 5
|
||||
|
|
@ -33,8 +31,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#ifndef NO_ACTION_TAPPING
|
||||
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
|
||||
uint16_t get_tapping_term(uint16_t keycode);
|
||||
void action_tapping_process(keyrecord_t record);
|
||||
#endif
|
||||
|
||||
uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record);
|
||||
bool get_permissive_hold(uint16_t keycode, keyrecord_t *record);
|
||||
bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record);
|
||||
bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record);
|
||||
bool get_retro_tapping(uint16_t keycode, keyrecord_t *record);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -83,9 +83,63 @@ static int8_t oneshot_layer_data = 0;
|
|||
inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; }
|
||||
inline uint8_t get_oneshot_layer_state(void) { return oneshot_layer_data & 0b111; }
|
||||
|
||||
# ifdef SWAP_HANDS_ENABLE
|
||||
enum {
|
||||
SHO_OFF,
|
||||
SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet
|
||||
SHO_PRESSED, // Swap hands button is currently pressed
|
||||
SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys
|
||||
} swap_hands_oneshot = SHO_OFF;
|
||||
# endif
|
||||
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
static uint16_t oneshot_layer_time = 0;
|
||||
inline bool has_oneshot_layer_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED); }
|
||||
# ifdef SWAP_HANDS_ENABLE
|
||||
static uint16_t oneshot_swaphands_time = 0;
|
||||
inline bool has_oneshot_swaphands_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE); }
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef SWAP_HANDS_ENABLE
|
||||
|
||||
void set_oneshot_swaphands(void) {
|
||||
swap_hands_oneshot = SHO_PRESSED;
|
||||
swap_hands = true;
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
oneshot_swaphands_time = timer_read();
|
||||
if (oneshot_layer_time != 0) {
|
||||
oneshot_layer_time = oneshot_swaphands_time;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
void release_oneshot_swaphands(void) {
|
||||
if (swap_hands_oneshot == SHO_PRESSED) {
|
||||
swap_hands_oneshot = SHO_ACTIVE;
|
||||
}
|
||||
if (swap_hands_oneshot == SHO_USED) {
|
||||
clear_oneshot_swaphands();
|
||||
}
|
||||
}
|
||||
|
||||
void use_oneshot_swaphands(void) {
|
||||
if (swap_hands_oneshot == SHO_PRESSED) {
|
||||
swap_hands_oneshot = SHO_USED;
|
||||
}
|
||||
if (swap_hands_oneshot == SHO_ACTIVE) {
|
||||
clear_oneshot_swaphands();
|
||||
}
|
||||
}
|
||||
|
||||
void clear_oneshot_swaphands(void) {
|
||||
swap_hands_oneshot = SHO_OFF;
|
||||
swap_hands = false;
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
oneshot_swaphands_time = 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
/** \brief Set oneshot layer
|
||||
|
|
@ -236,6 +290,32 @@ void set_macro_mods(uint8_t mods) { macro_mods = mods; }
|
|||
void clear_macro_mods(void) { macro_mods = 0; }
|
||||
|
||||
#ifndef NO_ACTION_ONESHOT
|
||||
/** \brief get oneshot mods
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
uint8_t get_oneshot_mods(void) { return oneshot_mods; }
|
||||
|
||||
void add_oneshot_mods(uint8_t mods) {
|
||||
if ((oneshot_mods & mods) != mods) {
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
oneshot_time = timer_read();
|
||||
# endif
|
||||
oneshot_mods |= mods;
|
||||
oneshot_mods_changed_kb(mods);
|
||||
}
|
||||
}
|
||||
|
||||
void del_oneshot_mods(uint8_t mods) {
|
||||
if (oneshot_mods & mods) {
|
||||
oneshot_mods &= ~mods;
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
oneshot_time = oneshot_mods ? timer_read() : 0;
|
||||
# endif
|
||||
oneshot_mods_changed_kb(oneshot_mods);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief set oneshot mods
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
|
@ -262,11 +342,6 @@ void clear_oneshot_mods(void) {
|
|||
oneshot_mods_changed_kb(oneshot_mods);
|
||||
}
|
||||
}
|
||||
/** \brief get oneshot mods
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
uint8_t get_oneshot_mods(void) { return oneshot_mods; }
|
||||
#endif
|
||||
|
||||
/** \brief Called when the one shot modifiers have been changed.
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACTION_UTIL_H
|
||||
#define ACTION_UTIL_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "report.h"
|
||||
|
|
@ -57,12 +57,11 @@ void set_macro_mods(uint8_t mods);
|
|||
void clear_macro_mods(void);
|
||||
|
||||
/* oneshot modifier */
|
||||
void set_oneshot_mods(uint8_t mods);
|
||||
uint8_t get_oneshot_mods(void);
|
||||
void add_oneshot_mods(uint8_t mods);
|
||||
void del_oneshot_mods(uint8_t mods);
|
||||
void set_oneshot_mods(uint8_t mods);
|
||||
void clear_oneshot_mods(void);
|
||||
void oneshot_toggle(void);
|
||||
void oneshot_enable(void);
|
||||
void oneshot_disable(void);
|
||||
bool has_oneshot_mods_timed_out(void);
|
||||
|
||||
uint8_t get_oneshot_locked_mods(void);
|
||||
|
|
@ -77,6 +76,7 @@ void reset_oneshot_layer(void);
|
|||
bool is_oneshot_layer_active(void);
|
||||
uint8_t get_oneshot_layer_state(void);
|
||||
bool has_oneshot_layer_timed_out(void);
|
||||
bool has_oneshot_swaphands_timed_out(void);
|
||||
|
||||
void oneshot_locked_mods_changed_user(uint8_t mods);
|
||||
void oneshot_locked_mods_changed_kb(uint8_t mods);
|
||||
|
|
@ -88,8 +88,13 @@ void oneshot_layer_changed_kb(uint8_t layer);
|
|||
/* inspect */
|
||||
uint8_t has_anymod(void);
|
||||
|
||||
#ifdef SWAP_HANDS_ENABLE
|
||||
void set_oneshot_swaphands(void);
|
||||
void release_oneshot_swaphands(void);
|
||||
void use_oneshot_swaphands(void);
|
||||
void clear_oneshot_swaphands(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
#pragma once
|
||||
|
||||
#define CONSOLE_PRINTBUF_SIZE 512
|
||||
|
||||
void console_printf(char *fmt, ...);
|
||||
|
||||
#define __xprintf console_printf
|
||||
|
||||
#endif //_PRINTF_H_
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "matrix.h"
|
||||
#include "i2c_master.h"
|
||||
#include "led_matrix.h"
|
||||
#include "md_rgb_matrix.h"
|
||||
#include "suspend.h"
|
||||
|
||||
/** \brief Suspend idle
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ void bootloader_jump(void) {
|
|||
|
||||
#else // Assume remaining boards are DFU, even if the flag isn't set
|
||||
|
||||
# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though?
|
||||
# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though?
|
||||
UDCON = 1;
|
||||
USBCON = (1 << FRZCLK); // disable USB
|
||||
UCSR1B = 0;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
# include "rgblight.h"
|
||||
extern rgblight_config_t rgblight_config;
|
||||
static bool rgblight_enabled;
|
||||
static bool is_suspended;
|
||||
#endif
|
||||
|
||||
/** \brief Suspend idle
|
||||
|
|
@ -104,12 +101,7 @@ static void power_down(uint8_t wdto) {
|
|||
// stop_all_notes();
|
||||
# endif /* AUDIO_ENABLE */
|
||||
# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
rgblight_timer_disable();
|
||||
if (!is_suspended) {
|
||||
is_suspended = true;
|
||||
rgblight_enabled = rgblight_config.enable;
|
||||
rgblight_disable_noeeprom();
|
||||
}
|
||||
rgblight_suspend();
|
||||
# endif
|
||||
suspend_power_down_kb();
|
||||
|
||||
|
|
@ -177,14 +169,7 @@ void suspend_wakeup_init(void) {
|
|||
#endif
|
||||
led_set(host_keyboard_leds());
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
is_suspended = false;
|
||||
if (rgblight_enabled) {
|
||||
# ifdef BOOTLOADER_TEENSY
|
||||
wait_ms(10);
|
||||
# endif
|
||||
rgblight_enable_noeeprom();
|
||||
}
|
||||
rgblight_timer_enable();
|
||||
rgblight_wakeup();
|
||||
#endif
|
||||
suspend_wakeup_init_kb();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef SUSPEND_AVR_H
|
||||
#define SUSPEND_AVR_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -24,5 +23,3 @@ __asm__ __volatile__ ( \
|
|||
: "r0" \
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TIMER_AVR_H
|
||||
#define TIMER_AVR_H 1
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -38,5 +37,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#if (TIMER_RAW_TOP > 255)
|
||||
# error "Timer0 can't count 1ms at this clock freq. Use larger prescaler."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ xatoi:
|
|||
brcs 70f ;/
|
||||
cpi r22, 10 ;if(r22 >= 10) {
|
||||
brcs 53f ; r22 -= 7;
|
||||
subi r22, 7 ; if(r22 < 10)
|
||||
subi r22, 7 ; if(r22 < 10)
|
||||
cpi r22, 10 ;
|
||||
brcs 70f ;}
|
||||
53: cp r22, r25 ;if(r22 >= r25) error;
|
||||
|
|
@ -496,5 +496,3 @@ xatoi:
|
|||
ret
|
||||
.endfunc
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
Extended itoa, puts and printf (C)ChaN, 2011
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef XPRINTF_H
|
||||
#define XPRINTF_H
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
|
@ -102,5 +101,3 @@ char xatoi(char **str, long *ret);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BOOTLOADER_H
|
||||
#define BOOTLOADER_H
|
||||
#pragma once
|
||||
|
||||
/* give code for your bootloader to come up if needed */
|
||||
void bootloader_jump(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ void bootmagic(void) {
|
|||
default_layer = eeconfig_read_default_layer();
|
||||
default_layer_set((layer_state_t)default_layer);
|
||||
}
|
||||
/* Also initialize layer state to trigger callback functions for layer_state */
|
||||
layer_state_set_kb((layer_state_t)layer_state);
|
||||
|
||||
/* EE_HANDS handedness */
|
||||
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef BOOTMAGIC_H
|
||||
#define BOOTMAGIC_H
|
||||
#pragma once
|
||||
|
||||
/* FIXME: Add special doxygen comments for defines here. */
|
||||
|
||||
|
|
@ -101,5 +100,3 @@
|
|||
|
||||
void bootmagic(void);
|
||||
bool bootmagic_scan_keycode(uint8_t keycode);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#include "quantum.h"
|
||||
|
||||
bool is_keyboard_left(void);
|
||||
|
||||
/** \brief Reset eeprom
|
||||
*
|
||||
* ...just incase someone wants to only change the eeprom behaviour
|
||||
|
|
@ -48,4 +46,4 @@ __attribute__((weak)) void bootmagic_lite(void) {
|
|||
// Jump to bootloader.
|
||||
bootloader_jump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,68 @@
|
|||
#include "bootloader.h"
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#ifdef STM32_BOOTLOADER_ADDRESS
|
||||
/* STM32 */
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
#include "wait.h"
|
||||
|
||||
/* This code should be checked whether it runs correctly on platforms */
|
||||
# define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
|
||||
extern uint32_t __ram0_end__;
|
||||
# define BOOTLOADER_MAGIC 0xDEADBEEF
|
||||
# define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4)
|
||||
#define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
|
||||
#define BOOTLOADER_MAGIC 0xDEADBEEF
|
||||
#define MAGIC_ADDR (unsigned long *)(SYMVAL(__ram0_end__) - 4)
|
||||
|
||||
/** \brief Jump to the bootloader
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void bootloader_jump(void) {
|
||||
#ifndef STM32_BOOTLOADER_DUAL_BANK
|
||||
# define STM32_BOOTLOADER_DUAL_BANK FALSE
|
||||
#endif
|
||||
|
||||
#if STM32_BOOTLOADER_DUAL_BANK
|
||||
|
||||
// Need pin definitions
|
||||
# include "config_common.h"
|
||||
|
||||
# ifndef STM32_BOOTLOADER_DUAL_BANK_GPIO
|
||||
# error "No STM32_BOOTLOADER_DUAL_BANK_GPIO defined, don't know which pin to toggle"
|
||||
# endif
|
||||
|
||||
# ifndef STM32_BOOTLOADER_DUAL_BANK_POLARITY
|
||||
# define STM32_BOOTLOADER_DUAL_BANK_POLARITY 0
|
||||
# endif
|
||||
|
||||
# ifndef STM32_BOOTLOADER_DUAL_BANK_DELAY
|
||||
# define STM32_BOOTLOADER_DUAL_BANK_DELAY 100000
|
||||
# endif
|
||||
|
||||
extern uint32_t __ram0_end__;
|
||||
|
||||
__attribute__((weak)) void bootloader_jump(void) {
|
||||
// For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash
|
||||
// bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do
|
||||
// it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to
|
||||
// BOOT0's RC charging circuit, lets it charge the capacitor, and issue a system reset. See the QMK discord
|
||||
// #hardware channel pins for an example circuit.
|
||||
palSetPadMode(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
# if STM32_BOOTLOADER_DUAL_BANK_POLARITY
|
||||
palSetPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO));
|
||||
# else
|
||||
palClearPad(PAL_PORT(STM32_BOOTLOADER_DUAL_BANK_GPIO), PAL_PAD(STM32_BOOTLOADER_DUAL_BANK_GPIO));
|
||||
# endif
|
||||
|
||||
// Wait for a while for the capacitor to charge
|
||||
wait_ms(100);
|
||||
|
||||
// Issue a system reset to get the ROM bootloader to execute, with BOOT0 high
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void enter_bootloader_mode_if_requested(void) {} // not needed at all, but if anybody attempts to invoke it....
|
||||
|
||||
#elif defined(STM32_BOOTLOADER_ADDRESS) // STM32_BOOTLOADER_DUAL_BANK
|
||||
|
||||
extern uint32_t __ram0_end__;
|
||||
|
||||
__attribute__((weak)) void bootloader_jump(void) {
|
||||
*MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
/** \brief Enter bootloader mode if requested
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void enter_bootloader_mode_if_requested(void) {
|
||||
unsigned long *check = MAGIC_ADDR;
|
||||
if (*check == BOOTLOADER_MAGIC) {
|
||||
|
|
@ -41,27 +79,27 @@ void enter_bootloader_mode_if_requested(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#elif defined(KL2x) || defined(K20x) /* STM32_BOOTLOADER_ADDRESS */
|
||||
#elif defined(KL2x) || defined(K20x) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS
|
||||
/* Kinetis */
|
||||
|
||||
# if defined(KIIBOHD_BOOTLOADER)
|
||||
# if defined(BOOTLOADER_KIIBOHD)
|
||||
/* Kiibohd Bootloader (MCHCK and Infinity KB) */
|
||||
# define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000
|
||||
const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
|
||||
void bootloader_jump(void) {
|
||||
const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
|
||||
__attribute__((weak)) void bootloader_jump(void) {
|
||||
__builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
|
||||
// request reset
|
||||
SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk;
|
||||
}
|
||||
|
||||
# else /* defined(KIIBOHD_BOOTLOADER) */
|
||||
# else /* defined(BOOTLOADER_KIIBOHD) */
|
||||
/* Default for Kinetis - expecting an ARM Teensy */
|
||||
# include "wait.h"
|
||||
void bootloader_jump(void) {
|
||||
__attribute__((weak)) void bootloader_jump(void) {
|
||||
wait_ms(100);
|
||||
__BKPT(0);
|
||||
}
|
||||
# endif /* defined(KIIBOHD_BOOTLOADER) */
|
||||
# endif /* defined(BOOTLOADER_KIIBOHD) */
|
||||
|
||||
#else /* neither STM32 nor KINETIS */
|
||||
__attribute__((weak)) void bootloader_jump(void) {}
|
||||
|
|
|
|||
|
|
@ -22,3 +22,10 @@
|
|||
#if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX)
|
||||
# define USE_I2CV1
|
||||
#endif
|
||||
|
||||
// teensy
|
||||
#if defined(K20x) || defined(KL2x)
|
||||
# define USE_I2CV1
|
||||
# define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed
|
||||
# define USE_GPIOV1
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,11 +21,10 @@
|
|||
* This library also assumes that the pages are not used by the firmware.
|
||||
*/
|
||||
|
||||
#ifndef __EEPROM_H
|
||||
#define __EEPROM_H
|
||||
#pragma once
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
#include "flash_stm32.h"
|
||||
|
||||
// HACK ALERT. This definition may not match your processor
|
||||
|
|
@ -36,12 +35,14 @@
|
|||
# define MCU_STM32F103RB
|
||||
#elif defined(EEPROM_EMU_STM32F072xB)
|
||||
# define MCU_STM32F072CB
|
||||
#elif defined(EEPROM_EMU_STM32F042x6)
|
||||
# define MCU_STM32F042K6
|
||||
#else
|
||||
# error "not implemented."
|
||||
#endif
|
||||
|
||||
#ifndef EEPROM_PAGE_SIZE
|
||||
# if defined(MCU_STM32F103RB)
|
||||
# if defined(MCU_STM32F103RB) || defined(MCU_STM32F042K6)
|
||||
# define FEE_PAGE_SIZE (uint16_t)0x400 // Page size = 1KByte
|
||||
# define FEE_DENSITY_PAGES 2 // How many pages are used
|
||||
# elif defined(MCU_STM32F103ZE) || defined(MCU_STM32F103RE) || defined(MCU_STM32F103RD) || defined(MCU_STM32F303CC) || defined(MCU_STM32F072CB)
|
||||
|
|
@ -55,6 +56,8 @@
|
|||
#ifndef EEPROM_START_ADDRESS
|
||||
# if defined(MCU_STM32F103RB) || defined(MCU_STM32F072CB)
|
||||
# define FEE_MCU_FLASH_SIZE 128 // Size in Kb
|
||||
# elif defined(MCU_STM32F042K6)
|
||||
# define FEE_MCU_FLASH_SIZE 32 // Size in Kb
|
||||
# elif defined(MCU_STM32F103ZE) || defined(MCU_STM32F103RE)
|
||||
# define FEE_MCU_FLASH_SIZE 512 // Size in Kb
|
||||
# elif defined(MCU_STM32F103RD)
|
||||
|
|
@ -79,5 +82,3 @@ uint16_t EEPROM_Init(void);
|
|||
void EEPROM_Erase(void);
|
||||
uint16_t EEPROM_WriteDataByte(uint16_t Address, uint8_t DataByte);
|
||||
uint8_t EEPROM_ReadDataByte(uint16_t Address);
|
||||
|
||||
#endif /* __EEPROM_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
|
||||
#include "eeconfig.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
#elif defined(EEPROM_EMU_STM32F072xB)
|
||||
# define STM32F072xB
|
||||
# include "stm32f0xx.h"
|
||||
#elif defined(EEPROM_EMU_STM32F042x6)
|
||||
# define STM32F042x6
|
||||
# include "stm32f0xx.h"
|
||||
#else
|
||||
# error "not implemented."
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,15 +16,14 @@
|
|||
* Modifications for QMK and STM32F303 by Yiancar
|
||||
*/
|
||||
|
||||
#ifndef __FLASH_STM32_H
|
||||
#define __FLASH_STM32_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
|
||||
typedef enum { FLASH_BUSY = 1, FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_ERROR_OPT, FLASH_COMPLETE, FLASH_TIMEOUT, FLASH_BAD_ADDRESS } FLASH_Status;
|
||||
|
||||
|
|
@ -41,5 +40,3 @@ void FLASH_ClearFlag(uint32_t FLASH_FLAG);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __FLASH_STM32_H */
|
||||
|
|
|
|||
|
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
* found at: http://www.sparetimelabs.com/tinyprintf/tinyprintf.php
|
||||
* and: http://www.sparetimelabs.com/printfrevisited/printfrevisited.php
|
||||
*/
|
||||
|
||||
/*
|
||||
File: printf.c
|
||||
|
||||
Copyright (C) 2004 Kustaa Nyholm
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
typedef void (*putcf)(void*, char);
|
||||
static putcf stdout_putf;
|
||||
static void* stdout_putp;
|
||||
|
||||
// this adds cca 400 bytes
|
||||
#define PRINTF_LONG_SUPPORT
|
||||
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
|
||||
static void uli2a(unsigned long int num, unsigned int base, int uc, char* bf) {
|
||||
int n = 0;
|
||||
unsigned int d = 1;
|
||||
while (num / d >= base) d *= base;
|
||||
while (d != 0) {
|
||||
int dgt = num / d;
|
||||
num %= d;
|
||||
d /= base;
|
||||
if (n || dgt > 0 || d == 0) {
|
||||
*bf++ = dgt + (dgt < 10 ? '0' : (uc ? 'A' : 'a') - 10);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
*bf = 0;
|
||||
}
|
||||
|
||||
static void li2a(long num, char* bf) {
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
*bf++ = '-';
|
||||
}
|
||||
uli2a(num, 10, 0, bf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void ui2a(unsigned int num, unsigned int base, int uc, char* bf) {
|
||||
int n = 0;
|
||||
unsigned int d = 1;
|
||||
while (num / d >= base) d *= base;
|
||||
while (d != 0) {
|
||||
int dgt = num / d;
|
||||
num %= d;
|
||||
d /= base;
|
||||
if (n || dgt > 0 || d == 0) {
|
||||
*bf++ = dgt + (dgt < 10 ? '0' : (uc ? 'A' : 'a') - 10);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
*bf = 0;
|
||||
}
|
||||
|
||||
static void i2a(int num, char* bf) {
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
*bf++ = '-';
|
||||
}
|
||||
ui2a(num, 10, 0, bf);
|
||||
}
|
||||
|
||||
static int a2d(char ch) {
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return ch - '0';
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
return ch - 'a' + 10;
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
return ch - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char a2i(char ch, const char** src, int base, int* nump) {
|
||||
const char* p = *src;
|
||||
int num = 0;
|
||||
int digit;
|
||||
while ((digit = a2d(ch)) >= 0) {
|
||||
if (digit > base) break;
|
||||
num = num * base + digit;
|
||||
ch = *p++;
|
||||
}
|
||||
*src = p;
|
||||
*nump = num;
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void putchw(void* putp, putcf putf, int n, char z, char* bf) {
|
||||
char fc = z ? '0' : ' ';
|
||||
char ch;
|
||||
char* p = bf;
|
||||
while (*p++ && n > 0) n--;
|
||||
while (n-- > 0) putf(putp, fc);
|
||||
while ((ch = *bf++)) putf(putp, ch);
|
||||
}
|
||||
|
||||
void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) {
|
||||
// This used to handle max of 12, but binary support jumps this to at least 32
|
||||
char bf[36];
|
||||
|
||||
char ch;
|
||||
|
||||
while ((ch = *(fmt++))) {
|
||||
if (ch != '%')
|
||||
putf(putp, ch);
|
||||
else {
|
||||
char lz = 0;
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
char lng = 0;
|
||||
#endif
|
||||
int w = 0;
|
||||
ch = *(fmt++);
|
||||
if (ch == '0') {
|
||||
ch = *(fmt++);
|
||||
lz = 1;
|
||||
}
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
ch = a2i(ch, &fmt, 10, &w);
|
||||
}
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (ch == 'l') {
|
||||
ch = *(fmt++);
|
||||
lng = 1;
|
||||
}
|
||||
#endif
|
||||
switch (ch) {
|
||||
case 0:
|
||||
goto abort;
|
||||
case 'u': {
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 10, 0, bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 10, 0, bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
}
|
||||
case 'd': {
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
li2a(va_arg(va, unsigned long int), bf);
|
||||
else
|
||||
#endif
|
||||
i2a(va_arg(va, int), bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
}
|
||||
case 'x':
|
||||
case 'X':
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 16, (ch == 'X'), bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 16, (ch == 'X'), bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
case 'c':
|
||||
putf(putp, (char)(va_arg(va, int)));
|
||||
break;
|
||||
case 's':
|
||||
putchw(putp, putf, w, 0, va_arg(va, char*));
|
||||
break;
|
||||
case 'b':
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 2, 0, bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 2, 0, bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
case '%':
|
||||
putf(putp, ch);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
abort:;
|
||||
}
|
||||
|
||||
void init_printf(void* putp, void (*putf)(void*, char)) {
|
||||
stdout_putf = putf;
|
||||
stdout_putp = putp;
|
||||
}
|
||||
|
||||
int tfp_printf(const char* fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
tfp_format(stdout_putp, stdout_putf, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void putcp(void* p, char c) { *(*((char**)p))++ = c; }
|
||||
|
||||
int tfp_sprintf(char* s, const char* fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
tfp_format(&s, putcp, fmt, va);
|
||||
putcp(&s, 0);
|
||||
va_end(va);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* found at: http://www.sparetimelabs.com/tinyprintf/tinyprintf.php
|
||||
* and: http://www.sparetimelabs.com/printfrevisited/printfrevisited.php
|
||||
*/
|
||||
|
||||
/*
|
||||
File: printf.h
|
||||
|
||||
Copyright (C) 2004 Kustaa Nyholm
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
This library is realy just two files: 'printf.h' and 'printf.c'.
|
||||
|
||||
They provide a simple and small (+200 loc) printf functionality to
|
||||
be used in embedded systems.
|
||||
|
||||
I've found them so usefull in debugging that I do not bother with a
|
||||
debugger at all.
|
||||
|
||||
They are distributed in source form, so to use them, just compile them
|
||||
into your project.
|
||||
|
||||
Two printf variants are provided: printf and sprintf.
|
||||
|
||||
The formats supported by this implementation are: 'd' 'u' 'c' 's' 'x' 'X'.
|
||||
|
||||
Zero padding and field width are also supported.
|
||||
|
||||
If the library is compiled with 'PRINTF_SUPPORT_LONG' defined then the
|
||||
long specifier is also
|
||||
supported. Note that this will pull in some long math routines (pun intended!)
|
||||
and thus make your executable noticably longer.
|
||||
|
||||
The memory foot print of course depends on the target cpu, compiler and
|
||||
compiler options, but a rough guestimate (based on a H8S target) is about
|
||||
1.4 kB for code and some twenty 'int's and 'char's, say 60 bytes of stack space.
|
||||
Not too bad. Your milage may vary. By hacking the source code you can
|
||||
get rid of some hunred bytes, I'm sure, but personally I feel the balance of
|
||||
functionality and flexibility versus code size is close to optimal for
|
||||
many embedded systems.
|
||||
|
||||
To use the printf you need to supply your own character output function,
|
||||
something like :
|
||||
|
||||
void putc ( void* p, char c)
|
||||
{
|
||||
while (!SERIAL_PORT_EMPTY) ;
|
||||
SERIAL_PORT_TX_REGISTER = c;
|
||||
}
|
||||
|
||||
Before you can call printf you need to initialize it to use your
|
||||
character output function with something like:
|
||||
|
||||
init_printf(NULL,putc);
|
||||
|
||||
Notice the 'NULL' in 'init_printf' and the parameter 'void* p' in 'putc',
|
||||
the NULL (or any pointer) you pass into the 'init_printf' will eventually be
|
||||
passed to your 'putc' routine. This allows you to pass some storage space (or
|
||||
anything realy) to the character output function, if necessary.
|
||||
This is not often needed but it was implemented like that because it made
|
||||
implementing the sprintf function so neat (look at the source code).
|
||||
|
||||
The code is re-entrant, except for the 'init_printf' function, so it
|
||||
is safe to call it from interupts too, although this may result in mixed output.
|
||||
If you rely on re-entrancy, take care that your 'putc' function is re-entrant!
|
||||
|
||||
The printf and sprintf functions are actually macros that translate to
|
||||
'tfp_printf' and 'tfp_sprintf'. This makes it possible
|
||||
to use them along with 'stdio.h' printf's in a single source file.
|
||||
You just need to undef the names before you include the 'stdio.h'.
|
||||
Note that these are not function like macros, so if you have variables
|
||||
or struct members with these names, things will explode in your face.
|
||||
Without variadic macros this is the best we can do to wrap these
|
||||
fucnction. If it is a problem just give up the macros and use the
|
||||
functions directly or rename them.
|
||||
|
||||
For further details see source code.
|
||||
|
||||
regs Kusti, 23.10.2004
|
||||
*/
|
||||
|
||||
#ifndef __TFP_PRINTF__
|
||||
#define __TFP_PRINTF__
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void init_printf(void* putp, void (*putf)(void*, char));
|
||||
|
||||
int tfp_printf(const char* fmt, ...);
|
||||
int tfp_sprintf(char* s, const char* fmt, ...);
|
||||
|
||||
void tfp_format(void* putp, void (*putf)(void*, char), const char* fmt, va_list va);
|
||||
|
||||
#define printf tfp_printf
|
||||
#define sprintf tfp_sprintf
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
|
||||
#include "led.h"
|
||||
#include "sleep_led.h"
|
||||
|
|
@ -211,4 +211,4 @@ void sleep_led_toggle(void) {
|
|||
// not implemented
|
||||
}
|
||||
|
||||
#endif /* platform selection */
|
||||
#endif /* platform selection */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* TODO */
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include <ch.h>
|
||||
#include <hal.h>
|
||||
|
||||
#include "matrix.h"
|
||||
#include "action.h"
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include "mousekey.h"
|
||||
#include "host.h"
|
||||
#include "suspend.h"
|
||||
#include "led.h"
|
||||
#include "wait.h"
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
|
|
@ -17,9 +18,6 @@
|
|||
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
# include "rgblight.h"
|
||||
extern rgblight_config_t rgblight_config;
|
||||
static bool rgblight_enabled;
|
||||
static bool is_suspended;
|
||||
#endif
|
||||
|
||||
/** \brief suspend idle
|
||||
|
|
@ -47,16 +45,25 @@ __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void suspend_power_down(void) {
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_set(0);
|
||||
#endif
|
||||
|
||||
// Turn off LED indicators
|
||||
uint8_t leds_off = 0;
|
||||
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
|
||||
if (is_backlight_enabled()) {
|
||||
// Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
|
||||
leds_off |= (1 << USB_LED_CAPS_LOCK);
|
||||
}
|
||||
#endif
|
||||
led_set(leds_off);
|
||||
|
||||
// TODO: figure out what to power down and how
|
||||
// shouldn't power down TPM/FTM if we want a breathing LED
|
||||
// also shouldn't power down USB
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
rgblight_timer_disable();
|
||||
if (!is_suspended) {
|
||||
is_suspended = true;
|
||||
rgblight_enabled = rgblight_config.enable;
|
||||
rgblight_disable_noeeprom();
|
||||
}
|
||||
rgblight_suspend();
|
||||
#endif
|
||||
|
||||
suspend_power_down_kb();
|
||||
|
|
@ -119,12 +126,9 @@ void suspend_wakeup_init(void) {
|
|||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_init();
|
||||
#endif /* BACKLIGHT_ENABLE */
|
||||
led_set(host_keyboard_leds());
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
is_suspended = false;
|
||||
if (rgblight_enabled) {
|
||||
rgblight_enable_noeeprom();
|
||||
}
|
||||
rgblight_timer_enable();
|
||||
rgblight_wakeup();
|
||||
#endif
|
||||
suspend_wakeup_init_kb();
|
||||
}
|
||||
|
|
|
|||
104
tmk_core/common/chibios/syscall-fallbacks.c
Normal file
104
tmk_core/common/chibios/syscall-fallbacks.c
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* Copyright 2021 Nick Brassel, QMK
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
__attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) {
|
||||
__errno_r(r) = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _lseek_r(struct _reent *r, int file, int ptr, int dir) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _read_r(struct _reent *r, int file, char *ptr, int len) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _write_r(struct _reent *r, int file, char *ptr, int len) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _close_r(struct _reent *r, int file) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _link_r(struct _reent *r, const char *oldpath, const char *newpath) {
|
||||
__errno_r(r) = EPERM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _unlink_r(struct _reent *r, const char *path) {
|
||||
__errno_r(r) = EPERM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) clock_t _times_r(struct _reent *r, void *t) {
|
||||
__errno_r(r) = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _fstat_r(struct _reent *r, int file, struct stat *st) {
|
||||
__errno_r(r) = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _isatty_r(struct _reent *r, int fd) {
|
||||
__errno_r(r) = EBADF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) caddr_t _sbrk_r(struct _reent *r, int incr) {
|
||||
__errno_r(r) = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _kill(int pid, int sig) {
|
||||
errno = EPERM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) pid_t _getpid(void) { return 1; }
|
||||
|
||||
__attribute__((weak, used)) void _fini(void) { return; }
|
||||
|
||||
__attribute__((weak, used, noreturn)) void _exit(int i) {
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) int _gettimeofday_r(struct _reent *r, struct timeval *t, void *tzp) {
|
||||
__errno_r(r) = EPERM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
__attribute__((weak, used)) void *__dso_handle;
|
||||
|
||||
__attribute__((weak, used)) void __cxa_pure_virtual(void) {
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "ch.h"
|
||||
#include <ch.h>
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,800 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "wait.h"
|
||||
#include "keycode.h"
|
||||
#include "host.h"
|
||||
#include "keymap.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "timer.h"
|
||||
#include "keyboard.h"
|
||||
#include "bootloader.h"
|
||||
#include "action_layer.h"
|
||||
#include "action_util.h"
|
||||
#include "eeconfig.h"
|
||||
#include "sleep_led.h"
|
||||
#include "led.h"
|
||||
#include "command.h"
|
||||
#include "quantum.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# include "backlight.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
# include "mousekey.h"
|
||||
#endif
|
||||
|
||||
#ifdef PROTOCOL_VUSB
|
||||
# include "usbdrv.h"
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
# include "audio.h"
|
||||
#endif /* AUDIO_ENABLE */
|
||||
|
||||
static bool command_common(uint8_t code);
|
||||
static void command_common_help(void);
|
||||
static void print_version(void);
|
||||
static void print_status(void);
|
||||
static bool command_console(uint8_t code);
|
||||
static void command_console_help(void);
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
static bool mousekey_console(uint8_t code);
|
||||
static void mousekey_console_help(void);
|
||||
#endif
|
||||
|
||||
static void switch_default_layer(uint8_t layer);
|
||||
|
||||
command_state_t command_state = ONESHOT;
|
||||
|
||||
bool command_proc(uint8_t code) {
|
||||
switch (command_state) {
|
||||
case ONESHOT:
|
||||
if (!IS_COMMAND()) return false;
|
||||
return (command_extra(code) || command_common(code));
|
||||
break;
|
||||
case CONSOLE:
|
||||
if (IS_COMMAND())
|
||||
return (command_extra(code) || command_common(code));
|
||||
else
|
||||
return (command_console_extra(code) || command_console(code));
|
||||
break;
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
case MOUSEKEY:
|
||||
mousekey_console(code);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
command_state = ONESHOT;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* TODO: Refactoring is needed. */
|
||||
/* This allows to define extra commands. return false when not processed. */
|
||||
bool command_extra(uint8_t code) __attribute__((weak));
|
||||
bool command_extra(uint8_t code) {
|
||||
(void)code;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool command_console_extra(uint8_t code) __attribute__((weak));
|
||||
bool command_console_extra(uint8_t code) {
|
||||
(void)code;
|
||||
return false;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Command common
|
||||
***********************************************************/
|
||||
static void command_common_help(void) {
|
||||
print("\n\t- Magic -\n" STR(MAGIC_KEY_DEBUG) ": Debug Message Toggle\n" STR(MAGIC_KEY_DEBUG_MATRIX) ": Matrix Debug Mode Toggle - Show keypresses in matrix grid\n" STR(MAGIC_KEY_DEBUG_KBD) ": Keyboard Debug Toggle - Show keypress report\n" STR(MAGIC_KEY_DEBUG_MOUSE) ": Debug Mouse Toggle\n" STR(MAGIC_KEY_VERSION) ": Version\n" STR(MAGIC_KEY_STATUS) ": Status\n" STR(MAGIC_KEY_CONSOLE) ": Activate Console Mode\n"
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||
STR(MAGIC_KEY_LAYER0) ": Switch to Layer 0\n" STR(MAGIC_KEY_LAYER1) ": Switch to Layer 1\n" STR(MAGIC_KEY_LAYER2) ": Switch to Layer 2\n" STR(MAGIC_KEY_LAYER3) ": Switch to Layer 3\n" STR(MAGIC_KEY_LAYER4) ": Switch to Layer 4\n" STR(MAGIC_KEY_LAYER5) ": Switch to Layer 5\n" STR(MAGIC_KEY_LAYER6) ": Switch to Layer 6\n" STR(MAGIC_KEY_LAYER7) ": Switch to Layer 7\n" STR(MAGIC_KEY_LAYER8) ": Switch to Layer 8\n" STR(MAGIC_KEY_LAYER9) ": Switch to Layer 9\n"
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||
"F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
|
||||
"0-9: Switch to Layer 0-9\n"
|
||||
#endif
|
||||
|
||||
STR(MAGIC_KEY_LAYER0_ALT) ": Switch to Layer 0 (alternate)\n"
|
||||
|
||||
STR(MAGIC_KEY_BOOTLOADER) ": Jump to Bootloader\n" STR(MAGIC_KEY_BOOTLOADER_ALT) ": Jump to Bootloader (alternate)\n"
|
||||
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
STR(MAGIC_KEY_LOCK) ": Lock Keyboard\n"
|
||||
#endif
|
||||
|
||||
STR(MAGIC_KEY_EEPROM) ": Print EEPROM Settings\n" STR(MAGIC_KEY_EEPROM_CLEAR) ": Clear EEPROM\n"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
STR(MAGIC_KEY_NKRO) ": NKRO Toggle\n"
|
||||
#endif
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
STR(MAGIC_KEY_SLEEP_LED) ": Sleep LED Test\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
static void print_version(void) {
|
||||
// print version & information
|
||||
print("\n\t- Version -\n");
|
||||
print("DESC: " STR(DESCRIPTION) "\n");
|
||||
print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
|
||||
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
|
||||
"VER: " STR(DEVICE_VER) "\n");
|
||||
#ifdef SKIP_VERSION
|
||||
print("BUILD: (" __DATE__ ")\n");
|
||||
#else
|
||||
print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n");
|
||||
# ifdef PROTOCOL_CHIBIOS
|
||||
print("CHIBIOS: " STR(CHIBIOS_VERSION) ", CONTRIB: " STR(CHIBIOS_CONTRIB_VERSION) "\n");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* build options */
|
||||
print("OPTIONS:"
|
||||
|
||||
#ifdef PROTOCOL_LUFA
|
||||
" LUFA"
|
||||
#endif
|
||||
#ifdef PROTOCOL_VUSB
|
||||
" VUSB"
|
||||
#endif
|
||||
#ifdef BOOTMAGIC_ENABLE
|
||||
" BOOTMAGIC"
|
||||
#endif
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
" MOUSEKEY"
|
||||
#endif
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
" EXTRAKEY"
|
||||
#endif
|
||||
#ifdef CONSOLE_ENABLE
|
||||
" CONSOLE"
|
||||
#endif
|
||||
#ifdef COMMAND_ENABLE
|
||||
" COMMAND"
|
||||
#endif
|
||||
#ifdef NKRO_ENABLE
|
||||
" NKRO"
|
||||
#endif
|
||||
#ifdef LINK_TIME_OPTIMIZATION_ENABLE
|
||||
" LTO"
|
||||
#endif
|
||||
|
||||
" " STR(BOOTLOADER_SIZE) "\n");
|
||||
|
||||
print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
|
||||
#if defined(__AVR__)
|
||||
" AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ " AVR_ARCH: avr" STR(__AVR_ARCH__)
|
||||
#endif
|
||||
"\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void print_status(void) {
|
||||
print("\n\t- Status -\n");
|
||||
|
||||
print_val_hex8(host_keyboard_leds());
|
||||
#ifndef PROTOCOL_VUSB
|
||||
// these aren't set on the V-USB protocol, so we just ignore them for now
|
||||
print_val_hex8(keyboard_protocol);
|
||||
print_val_hex8(keyboard_idle);
|
||||
#endif
|
||||
#ifdef NKRO_ENABLE
|
||||
print_val_hex8(keymap_config.nkro);
|
||||
#endif
|
||||
print_val_hex32(timer_read32());
|
||||
return;
|
||||
}
|
||||
|
||||
static void print_eeconfig(void) {
|
||||
// Print these variables if NO_PRINT or USER_PRINT are not defined.
|
||||
#if !defined(NO_PRINT) && !defined(USER_PRINT)
|
||||
|
||||
print("default_layer: ");
|
||||
print_dec(eeconfig_read_default_layer());
|
||||
print("\n");
|
||||
|
||||
debug_config_t dc;
|
||||
dc.raw = eeconfig_read_debug();
|
||||
print("debug_config.raw: ");
|
||||
print_hex8(dc.raw);
|
||||
print("\n");
|
||||
print(".enable: ");
|
||||
print_dec(dc.enable);
|
||||
print("\n");
|
||||
print(".matrix: ");
|
||||
print_dec(dc.matrix);
|
||||
print("\n");
|
||||
print(".keyboard: ");
|
||||
print_dec(dc.keyboard);
|
||||
print("\n");
|
||||
print(".mouse: ");
|
||||
print_dec(dc.mouse);
|
||||
print("\n");
|
||||
|
||||
keymap_config_t kc;
|
||||
kc.raw = eeconfig_read_keymap();
|
||||
print("keymap_config.raw: ");
|
||||
print_hex8(kc.raw);
|
||||
print("\n");
|
||||
print(".swap_control_capslock: ");
|
||||
print_dec(kc.swap_control_capslock);
|
||||
print("\n");
|
||||
print(".capslock_to_control: ");
|
||||
print_dec(kc.capslock_to_control);
|
||||
print("\n");
|
||||
print(".swap_lctl_lgui: ");
|
||||
print_dec(kc.swap_lctl_lgui);
|
||||
print("\n");
|
||||
print(".swap_rctl_rgui: ");
|
||||
print_dec(kc.swap_rctl_rgui);
|
||||
print("\n");
|
||||
print(".swap_lalt_lgui: ");
|
||||
print_dec(kc.swap_lalt_lgui);
|
||||
print("\n");
|
||||
print(".swap_ralt_rgui: ");
|
||||
print_dec(kc.swap_ralt_rgui);
|
||||
print("\n");
|
||||
print(".no_gui: ");
|
||||
print_dec(kc.no_gui);
|
||||
print("\n");
|
||||
print(".swap_grave_esc: ");
|
||||
print_dec(kc.swap_grave_esc);
|
||||
print("\n");
|
||||
print(".swap_backslash_backspace: ");
|
||||
print_dec(kc.swap_backslash_backspace);
|
||||
print("\n");
|
||||
print(".nkro: ");
|
||||
print_dec(kc.nkro);
|
||||
print("\n");
|
||||
|
||||
# ifdef BACKLIGHT_ENABLE
|
||||
backlight_config_t bc;
|
||||
bc.raw = eeconfig_read_backlight();
|
||||
print("backlight_config.raw: ");
|
||||
print_hex8(bc.raw);
|
||||
print("\n");
|
||||
print(".enable: ");
|
||||
print_dec(bc.enable);
|
||||
print("\n");
|
||||
print(".level: ");
|
||||
print_dec(bc.level);
|
||||
print("\n");
|
||||
# endif /* BACKLIGHT_ENABLE */
|
||||
|
||||
#endif /* !NO_PRINT */
|
||||
}
|
||||
|
||||
static bool command_common(uint8_t code) {
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
static host_driver_t *host_driver = 0;
|
||||
#endif
|
||||
|
||||
switch (code) {
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
|
||||
// test breathing sleep LED
|
||||
case MAGIC_KC(MAGIC_KEY_SLEEP_LED):
|
||||
print("Sleep LED Test\n");
|
||||
sleep_led_toggle();
|
||||
led_set(host_keyboard_leds());
|
||||
break;
|
||||
#endif
|
||||
|
||||
// print stored eeprom config
|
||||
case MAGIC_KC(MAGIC_KEY_EEPROM):
|
||||
print("eeconfig:\n");
|
||||
print_eeconfig();
|
||||
break;
|
||||
|
||||
// clear eeprom
|
||||
case MAGIC_KC(MAGIC_KEY_EEPROM_CLEAR):
|
||||
print("Clearing EEPROM\n");
|
||||
eeconfig_init();
|
||||
break;
|
||||
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
|
||||
// lock/unlock keyboard
|
||||
case MAGIC_KC(MAGIC_KEY_LOCK):
|
||||
if (host_get_driver()) {
|
||||
host_driver = host_get_driver();
|
||||
clear_keyboard();
|
||||
host_set_driver(0);
|
||||
print("Locked.\n");
|
||||
} else {
|
||||
host_set_driver(host_driver);
|
||||
print("Unlocked.\n");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// print help
|
||||
case MAGIC_KC(MAGIC_KEY_HELP):
|
||||
case MAGIC_KC(MAGIC_KEY_HELP_ALT):
|
||||
command_common_help();
|
||||
break;
|
||||
|
||||
// activate console
|
||||
case MAGIC_KC(MAGIC_KEY_CONSOLE):
|
||||
debug_matrix = false;
|
||||
debug_keyboard = false;
|
||||
debug_mouse = false;
|
||||
debug_enable = false;
|
||||
command_console_help();
|
||||
print("C> ");
|
||||
command_state = CONSOLE;
|
||||
break;
|
||||
|
||||
// jump to bootloader
|
||||
case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
|
||||
case MAGIC_KC(MAGIC_KEY_BOOTLOADER_ALT):
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
print("\n\nJumping to bootloader... ");
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
shutdown_user();
|
||||
#else
|
||||
wait_ms(1000);
|
||||
#endif
|
||||
bootloader_jump(); // not return
|
||||
break;
|
||||
|
||||
// debug toggle
|
||||
case MAGIC_KC(MAGIC_KEY_DEBUG):
|
||||
debug_enable = !debug_enable;
|
||||
if (debug_enable) {
|
||||
print("\ndebug: on\n");
|
||||
} else {
|
||||
print("\ndebug: off\n");
|
||||
debug_matrix = false;
|
||||
debug_keyboard = false;
|
||||
debug_mouse = false;
|
||||
}
|
||||
break;
|
||||
|
||||
// debug matrix toggle
|
||||
case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
|
||||
debug_matrix = !debug_matrix;
|
||||
if (debug_matrix) {
|
||||
print("\nmatrix: on\n");
|
||||
debug_enable = true;
|
||||
} else {
|
||||
print("\nmatrix: off\n");
|
||||
}
|
||||
break;
|
||||
|
||||
// debug keyboard toggle
|
||||
case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
|
||||
debug_keyboard = !debug_keyboard;
|
||||
if (debug_keyboard) {
|
||||
print("\nkeyboard: on\n");
|
||||
debug_enable = true;
|
||||
} else {
|
||||
print("\nkeyboard: off\n");
|
||||
}
|
||||
break;
|
||||
|
||||
// debug mouse toggle
|
||||
case MAGIC_KC(MAGIC_KEY_DEBUG_MOUSE):
|
||||
debug_mouse = !debug_mouse;
|
||||
if (debug_mouse) {
|
||||
print("\nmouse: on\n");
|
||||
debug_enable = true;
|
||||
} else {
|
||||
print("\nmouse: off\n");
|
||||
}
|
||||
break;
|
||||
|
||||
// print version
|
||||
case MAGIC_KC(MAGIC_KEY_VERSION):
|
||||
print_version();
|
||||
break;
|
||||
|
||||
// print status
|
||||
case MAGIC_KC(MAGIC_KEY_STATUS):
|
||||
print_status();
|
||||
break;
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
|
||||
// NKRO toggle
|
||||
case MAGIC_KC(MAGIC_KEY_NKRO):
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
keymap_config.nkro = !keymap_config.nkro;
|
||||
if (keymap_config.nkro) {
|
||||
print("NKRO: on\n");
|
||||
} else {
|
||||
print("NKRO: off\n");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
// switch layers
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0_ALT):
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0):
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER1):
|
||||
switch_default_layer(1);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER2):
|
||||
switch_default_layer(2);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER3):
|
||||
switch_default_layer(3);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER4):
|
||||
switch_default_layer(4);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER5):
|
||||
switch_default_layer(5);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER6):
|
||||
switch_default_layer(6);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER7):
|
||||
switch_default_layer(7);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER8):
|
||||
switch_default_layer(8);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER9):
|
||||
switch_default_layer(9);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||
|
||||
case KC_F1 ... KC_F9:
|
||||
switch_default_layer((code - KC_F1) + 1);
|
||||
break;
|
||||
case KC_F10:
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
|
||||
|
||||
case KC_1 ... KC_9:
|
||||
switch_default_layer((code - KC_1) + 1);
|
||||
break;
|
||||
case KC_0:
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
print("?");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Command console
|
||||
***********************************************************/
|
||||
static void command_console_help(void) {
|
||||
print("\n\t- Console -\n"
|
||||
"ESC/q: quit\n"
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
"m: mousekey\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
static bool command_console(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_H:
|
||||
case KC_SLASH: /* ? */
|
||||
command_console_help();
|
||||
break;
|
||||
case KC_Q:
|
||||
case KC_ESC:
|
||||
command_state = ONESHOT;
|
||||
return false;
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
case KC_M:
|
||||
mousekey_console_help();
|
||||
print("M> ");
|
||||
command_state = MOUSEKEY;
|
||||
return true;
|
||||
#endif
|
||||
default:
|
||||
print("?");
|
||||
return false;
|
||||
}
|
||||
print("C> ");
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
/***********************************************************
|
||||
* Mousekey console
|
||||
***********************************************************/
|
||||
static uint8_t mousekey_param = 0;
|
||||
|
||||
static void mousekey_param_print(void) {
|
||||
// Print these variables if NO_PRINT or USER_PRINT are not defined.
|
||||
# if !defined(NO_PRINT) && !defined(USER_PRINT)
|
||||
print("\n\t- Values -\n");
|
||||
print("1: delay(*10ms): ");
|
||||
pdec(mk_delay);
|
||||
print("\n");
|
||||
print("2: interval(ms): ");
|
||||
pdec(mk_interval);
|
||||
print("\n");
|
||||
print("3: max_speed: ");
|
||||
pdec(mk_max_speed);
|
||||
print("\n");
|
||||
print("4: time_to_max: ");
|
||||
pdec(mk_time_to_max);
|
||||
print("\n");
|
||||
print("5: wheel_max_speed: ");
|
||||
pdec(mk_wheel_max_speed);
|
||||
print("\n");
|
||||
print("6: wheel_time_to_max: ");
|
||||
pdec(mk_wheel_time_to_max);
|
||||
print("\n");
|
||||
# endif /* !NO_PRINT */
|
||||
}
|
||||
|
||||
//#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
|
||||
# define PRINT_SET_VAL(v) xprintf(# v " = %d\n", (v))
|
||||
static void mousekey_param_inc(uint8_t param, uint8_t inc) {
|
||||
switch (param) {
|
||||
case 1:
|
||||
if (mk_delay + inc < UINT8_MAX)
|
||||
mk_delay += inc;
|
||||
else
|
||||
mk_delay = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_delay);
|
||||
break;
|
||||
case 2:
|
||||
if (mk_interval + inc < UINT8_MAX)
|
||||
mk_interval += inc;
|
||||
else
|
||||
mk_interval = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_interval);
|
||||
break;
|
||||
case 3:
|
||||
if (mk_max_speed + inc < UINT8_MAX)
|
||||
mk_max_speed += inc;
|
||||
else
|
||||
mk_max_speed = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_max_speed);
|
||||
break;
|
||||
case 4:
|
||||
if (mk_time_to_max + inc < UINT8_MAX)
|
||||
mk_time_to_max += inc;
|
||||
else
|
||||
mk_time_to_max = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_time_to_max);
|
||||
break;
|
||||
case 5:
|
||||
if (mk_wheel_max_speed + inc < UINT8_MAX)
|
||||
mk_wheel_max_speed += inc;
|
||||
else
|
||||
mk_wheel_max_speed = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_wheel_max_speed);
|
||||
break;
|
||||
case 6:
|
||||
if (mk_wheel_time_to_max + inc < UINT8_MAX)
|
||||
mk_wheel_time_to_max += inc;
|
||||
else
|
||||
mk_wheel_time_to_max = UINT8_MAX;
|
||||
PRINT_SET_VAL(mk_wheel_time_to_max);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mousekey_param_dec(uint8_t param, uint8_t dec) {
|
||||
switch (param) {
|
||||
case 1:
|
||||
if (mk_delay > dec)
|
||||
mk_delay -= dec;
|
||||
else
|
||||
mk_delay = 0;
|
||||
PRINT_SET_VAL(mk_delay);
|
||||
break;
|
||||
case 2:
|
||||
if (mk_interval > dec)
|
||||
mk_interval -= dec;
|
||||
else
|
||||
mk_interval = 0;
|
||||
PRINT_SET_VAL(mk_interval);
|
||||
break;
|
||||
case 3:
|
||||
if (mk_max_speed > dec)
|
||||
mk_max_speed -= dec;
|
||||
else
|
||||
mk_max_speed = 0;
|
||||
PRINT_SET_VAL(mk_max_speed);
|
||||
break;
|
||||
case 4:
|
||||
if (mk_time_to_max > dec)
|
||||
mk_time_to_max -= dec;
|
||||
else
|
||||
mk_time_to_max = 0;
|
||||
PRINT_SET_VAL(mk_time_to_max);
|
||||
break;
|
||||
case 5:
|
||||
if (mk_wheel_max_speed > dec)
|
||||
mk_wheel_max_speed -= dec;
|
||||
else
|
||||
mk_wheel_max_speed = 0;
|
||||
PRINT_SET_VAL(mk_wheel_max_speed);
|
||||
break;
|
||||
case 6:
|
||||
if (mk_wheel_time_to_max > dec)
|
||||
mk_wheel_time_to_max -= dec;
|
||||
else
|
||||
mk_wheel_time_to_max = 0;
|
||||
PRINT_SET_VAL(mk_wheel_time_to_max);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mousekey_console_help(void) {
|
||||
print("\n\t- Mousekey -\n"
|
||||
"ESC/q: quit\n"
|
||||
"1: delay(*10ms)\n"
|
||||
"2: interval(ms)\n"
|
||||
"3: max_speed\n"
|
||||
"4: time_to_max\n"
|
||||
"5: wheel_max_speed\n"
|
||||
"6: wheel_time_to_max\n"
|
||||
"\n"
|
||||
"p: print values\n"
|
||||
"d: set defaults\n"
|
||||
"up: +1\n"
|
||||
"down: -1\n"
|
||||
"pgup: +10\n"
|
||||
"pgdown: -10\n"
|
||||
"\n"
|
||||
"speed = delta * max_speed * (repeat / time_to_max)\n");
|
||||
xprintf("where delta: cursor=%d, wheel=%d\n"
|
||||
"See http://en.wikipedia.org/wiki/Mouse_keys\n",
|
||||
MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA);
|
||||
}
|
||||
|
||||
static bool mousekey_console(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_H:
|
||||
case KC_SLASH: /* ? */
|
||||
mousekey_console_help();
|
||||
break;
|
||||
case KC_Q:
|
||||
case KC_ESC:
|
||||
if (mousekey_param) {
|
||||
mousekey_param = 0;
|
||||
} else {
|
||||
print("C> ");
|
||||
command_state = CONSOLE;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case KC_P:
|
||||
mousekey_param_print();
|
||||
break;
|
||||
case KC_1:
|
||||
case KC_2:
|
||||
case KC_3:
|
||||
case KC_4:
|
||||
case KC_5:
|
||||
case KC_6:
|
||||
mousekey_param = numkey2num(code);
|
||||
break;
|
||||
case KC_UP:
|
||||
mousekey_param_inc(mousekey_param, 1);
|
||||
break;
|
||||
case KC_DOWN:
|
||||
mousekey_param_dec(mousekey_param, 1);
|
||||
break;
|
||||
case KC_PGUP:
|
||||
mousekey_param_inc(mousekey_param, 10);
|
||||
break;
|
||||
case KC_PGDN:
|
||||
mousekey_param_dec(mousekey_param, 10);
|
||||
break;
|
||||
case KC_D:
|
||||
mk_delay = MOUSEKEY_DELAY / 10;
|
||||
mk_interval = MOUSEKEY_INTERVAL;
|
||||
mk_max_speed = MOUSEKEY_MAX_SPEED;
|
||||
mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
|
||||
mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
||||
mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
||||
print("set default\n");
|
||||
break;
|
||||
default:
|
||||
print("?");
|
||||
return false;
|
||||
}
|
||||
if (mousekey_param) {
|
||||
xprintf("M%d> ", mousekey_param);
|
||||
} else {
|
||||
print("M>");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************************************
|
||||
* Utilities
|
||||
***********************************************************/
|
||||
uint8_t numkey2num(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_1:
|
||||
return 1;
|
||||
case KC_2:
|
||||
return 2;
|
||||
case KC_3:
|
||||
return 3;
|
||||
case KC_4:
|
||||
return 4;
|
||||
case KC_5:
|
||||
return 5;
|
||||
case KC_6:
|
||||
return 6;
|
||||
case KC_7:
|
||||
return 7;
|
||||
case KC_8:
|
||||
return 8;
|
||||
case KC_9:
|
||||
return 9;
|
||||
case KC_0:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void switch_default_layer(uint8_t layer) {
|
||||
xprintf("L%d\n", layer);
|
||||
default_layer_set(1UL << layer);
|
||||
clear_keyboard();
|
||||
}
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* FIXME: Add doxygen comments for the behavioral defines in here. */
|
||||
|
||||
/* TODO: Refactoring */
|
||||
typedef enum { ONESHOT, CONSOLE, MOUSEKEY } command_state_t;
|
||||
extern command_state_t command_state;
|
||||
|
||||
/* This allows to extend commands. Return false when command is not processed. */
|
||||
bool command_extra(uint8_t code);
|
||||
bool command_console_extra(uint8_t code);
|
||||
|
||||
#ifdef COMMAND_ENABLE
|
||||
uint8_t numkey2num(uint8_t code);
|
||||
bool command_proc(uint8_t code);
|
||||
#else
|
||||
# define command_proc(code) false
|
||||
#endif
|
||||
|
||||
#ifndef IS_COMMAND
|
||||
# define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||
# define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
|
||||
# define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||
# define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_HELP
|
||||
# define MAGIC_KEY_HELP H
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_HELP_ALT
|
||||
# define MAGIC_KEY_HELP_ALT SLASH
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_DEBUG
|
||||
# define MAGIC_KEY_DEBUG D
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_DEBUG_MATRIX
|
||||
# define MAGIC_KEY_DEBUG_MATRIX X
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_DEBUG_KBD
|
||||
# define MAGIC_KEY_DEBUG_KBD K
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_DEBUG_MOUSE
|
||||
# define MAGIC_KEY_DEBUG_MOUSE M
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_VERSION
|
||||
# define MAGIC_KEY_VERSION V
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_STATUS
|
||||
# define MAGIC_KEY_STATUS S
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_CONSOLE
|
||||
# define MAGIC_KEY_CONSOLE C
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER0
|
||||
# define MAGIC_KEY_LAYER0 0
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER0_ALT
|
||||
# define MAGIC_KEY_LAYER0_ALT GRAVE
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER1
|
||||
# define MAGIC_KEY_LAYER1 1
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER2
|
||||
# define MAGIC_KEY_LAYER2 2
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER3
|
||||
# define MAGIC_KEY_LAYER3 3
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER4
|
||||
# define MAGIC_KEY_LAYER4 4
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER5
|
||||
# define MAGIC_KEY_LAYER5 5
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER6
|
||||
# define MAGIC_KEY_LAYER6 6
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER7
|
||||
# define MAGIC_KEY_LAYER7 7
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER8
|
||||
# define MAGIC_KEY_LAYER8 8
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LAYER9
|
||||
# define MAGIC_KEY_LAYER9 9
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_BOOTLOADER
|
||||
# define MAGIC_KEY_BOOTLOADER B
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_BOOTLOADER_ALT
|
||||
# define MAGIC_KEY_BOOTLOADER_ALT ESC
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_LOCK
|
||||
# define MAGIC_KEY_LOCK CAPS
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_EEPROM
|
||||
# define MAGIC_KEY_EEPROM E
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_EEPROM_CLEAR
|
||||
# define MAGIC_KEY_EEPROM_CLEAR BSPACE
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_NKRO
|
||||
# define MAGIC_KEY_NKRO N
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_KEY_SLEEP_LED
|
||||
# define MAGIC_KEY_SLEEP_LED Z
|
||||
|
||||
#endif
|
||||
|
||||
#define XMAGIC_KC(key) KC_##key
|
||||
#define MAGIC_KC(key) XMAGIC_KC(key)
|
||||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H 1
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "print.h"
|
||||
|
|
@ -168,5 +167,3 @@ extern debug_config_t debug_config;
|
|||
# define debug_bin_reverse(data)
|
||||
|
||||
#endif /* NO_DEBUG */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "action_layer.h"
|
||||
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
# include "hal.h"
|
||||
# include <hal.h>
|
||||
# include "eeprom_stm32.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -13,6 +13,10 @@
|
|||
# include "eeprom_driver.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC_ENABLE)
|
||||
# include "haptic.h"
|
||||
#endif
|
||||
|
||||
/** \brief eeconfig enable
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
|
@ -65,6 +69,15 @@ void eeconfig_init_quantum(void) {
|
|||
eeprom_update_byte(EECONFIG_HANDEDNESS, 0);
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC_ENABLE)
|
||||
haptic_reset();
|
||||
#else
|
||||
// this is used in case haptic is disabled, but we still want sane defaults
|
||||
// in the haptic configuration eeprom. All zero will trigger a haptic_reset
|
||||
// when a haptic-enabled firmware is loaded onto the keyboard.
|
||||
eeprom_update_dword(EECONFIG_HAPTIC, 0);
|
||||
#endif
|
||||
|
||||
eeconfig_init_kb();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EECONFIG_H
|
||||
#define EECONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -111,5 +110,3 @@ void eeconfig_update_haptic(uint32_t val);
|
|||
|
||||
bool eeconfig_read_handedness(void);
|
||||
void eeconfig_update_handedness(bool val);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef TMK_CORE_COMMON_EEPROM_H_
|
||||
#define TMK_CORE_COMMON_EEPROM_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(__AVR__) && !defined(EEPROM_DRIVER)
|
||||
# include <avr/eeprom.h>
|
||||
|
|
@ -20,5 +19,3 @@ void eeprom_update_word(uint16_t *__p, uint16_t __value);
|
|||
void eeprom_update_dword(uint32_t *__p, uint32_t __value);
|
||||
void eeprom_update_block(const void *__src, void *__dst, size_t __n);
|
||||
#endif
|
||||
|
||||
#endif /* TMK_CORE_COMMON_EEPROM_H_ */
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HOST_DRIVER_H
|
||||
#define HOST_DRIVER_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "report.h"
|
||||
|
|
@ -31,5 +30,3 @@ typedef struct {
|
|||
void (*send_system)(uint16_t);
|
||||
void (*send_consumer)(uint16_t);
|
||||
} host_driver_t;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifdef RGBLIGHT_ENABLE
|
||||
# include "rgblight.h"
|
||||
#endif
|
||||
#ifdef ENCODER_ENABLE
|
||||
# include "encoder.h"
|
||||
#endif
|
||||
#ifdef STENO_ENABLE
|
||||
# include "process_steno.h"
|
||||
#endif
|
||||
|
|
@ -89,23 +92,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifdef VIA_ENABLE
|
||||
# include "via.h"
|
||||
#endif
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
# include "dip_switch.h"
|
||||
#endif
|
||||
|
||||
// Only enable this if console is enabled to print to
|
||||
#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
|
||||
static uint32_t matrix_timer = 0;
|
||||
static uint32_t matrix_scan_count = 0;
|
||||
#if defined(DEBUG_MATRIX_SCAN_RATE)
|
||||
static uint32_t matrix_timer = 0;
|
||||
static uint32_t matrix_scan_count = 0;
|
||||
static uint32_t last_matrix_scan_count = 0;
|
||||
|
||||
void matrix_scan_perf_task(void) {
|
||||
matrix_scan_count++;
|
||||
|
||||
uint32_t timer_now = timer_read32();
|
||||
if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) {
|
||||
dprintf("matrix scan frequency: %d\n", matrix_scan_count);
|
||||
|
||||
matrix_timer = timer_now;
|
||||
matrix_scan_count = 0;
|
||||
# if defined(CONSOLE_ENABLE)
|
||||
dprintf("matrix scan frequency: %lu\n", matrix_scan_count);
|
||||
# endif
|
||||
last_matrix_scan_count = matrix_scan_count;
|
||||
matrix_timer = timer_now;
|
||||
matrix_scan_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_matrix_scan_rate(void) { return last_matrix_scan_count; }
|
||||
#else
|
||||
# define matrix_scan_perf_task()
|
||||
#endif
|
||||
|
|
@ -216,6 +227,12 @@ void keyboard_setup(void) {
|
|||
*/
|
||||
__attribute__((weak)) bool is_keyboard_master(void) { return true; }
|
||||
|
||||
/** \brief is_keyboard_left
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__((weak)) bool is_keyboard_left(void) { return true; }
|
||||
|
||||
/** \brief should_process_keypress
|
||||
*
|
||||
* Override this function if you have a condition where keypresses processing should change:
|
||||
|
|
@ -223,6 +240,20 @@ __attribute__((weak)) bool is_keyboard_master(void) { return true; }
|
|||
*/
|
||||
__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); }
|
||||
|
||||
/** \brief housekeeping_task_kb
|
||||
*
|
||||
* Override this function if you have a need to execute code for every keyboard main loop iteration.
|
||||
* This is specific to keyboard-level functionality.
|
||||
*/
|
||||
__attribute__((weak)) void housekeeping_task_kb(void) {}
|
||||
|
||||
/** \brief housekeeping_task_user
|
||||
*
|
||||
* Override this function if you have a need to execute code for every keyboard main loop iteration.
|
||||
* This is specific to user/keymap-level functionality.
|
||||
*/
|
||||
__attribute__((weak)) void housekeeping_task_user(void) {}
|
||||
|
||||
/** \brief keyboard_init
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
|
@ -259,6 +290,9 @@ void keyboard_init(void) {
|
|||
#ifdef RGBLIGHT_ENABLE
|
||||
rgblight_init();
|
||||
#endif
|
||||
#ifdef ENCODER_ENABLE
|
||||
encoder_init();
|
||||
#endif
|
||||
#ifdef STENO_ENABLE
|
||||
steno_init();
|
||||
#endif
|
||||
|
|
@ -272,6 +306,14 @@ void keyboard_init(void) {
|
|||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
#endif
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
dip_switch_init();
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
|
||||
debug_enable = true;
|
||||
#endif
|
||||
|
||||
keyboard_post_init_kb(); /* Always keep this last */
|
||||
}
|
||||
|
||||
|
|
@ -296,6 +338,9 @@ void keyboard_task(void) {
|
|||
uint8_t keys_processed = 0;
|
||||
#endif
|
||||
|
||||
housekeeping_task_kb();
|
||||
housekeeping_task_user();
|
||||
|
||||
#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT)
|
||||
uint8_t ret = matrix_scan();
|
||||
#else
|
||||
|
|
@ -355,6 +400,10 @@ MATRIX_LOOP_END:
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_ENABLE
|
||||
encoder_read();
|
||||
#endif
|
||||
|
||||
#ifdef QWIIC_ENABLE
|
||||
qwiic_task();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -63,14 +62,19 @@ void keyboard_task(void);
|
|||
void keyboard_set_leds(uint8_t leds);
|
||||
/* it runs whenever code has to behave differently on a slave */
|
||||
bool is_keyboard_master(void);
|
||||
/* it runs whenever code has to behave differently on left vs right split */
|
||||
bool is_keyboard_left(void);
|
||||
|
||||
void keyboard_pre_init_kb(void);
|
||||
void keyboard_pre_init_user(void);
|
||||
void keyboard_post_init_kb(void);
|
||||
void keyboard_post_init_user(void);
|
||||
|
||||
void housekeeping_task_kb(void);
|
||||
void housekeeping_task_user(void);
|
||||
|
||||
uint32_t get_matrix_scan_rate(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* See https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
||||
* or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older)
|
||||
*/
|
||||
#ifndef KEYCODE_H
|
||||
#define KEYCODE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/* FIXME: Add doxygen comments here */
|
||||
|
||||
|
|
@ -542,4 +542,3 @@ enum mouse_keys {
|
|||
KC_MS_ACCEL1,
|
||||
KC_MS_ACCEL2
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
/* FIXME: Add doxygen comments here. */
|
||||
|
||||
/* keyboard LEDs */
|
||||
#define USB_LED_NUM_LOCK 0
|
||||
#define USB_LED_CAPS_LOCK 1
|
||||
#define USB_LED_SCROLL_LOCK 2
|
||||
#define USB_LED_COMPOSE 3
|
||||
#define USB_LED_KANA 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
bool num_lock : 1;
|
||||
bool caps_lock : 1;
|
||||
bool scroll_lock : 1;
|
||||
bool compose : 1;
|
||||
bool kana : 1;
|
||||
uint8_t reserved : 3;
|
||||
};
|
||||
} led_t;
|
||||
|
||||
void led_set(uint8_t usb_led);
|
||||
|
||||
void led_init_ports(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -33,4 +33,7 @@ void magic(void) {
|
|||
uint8_t default_layer = 0;
|
||||
default_layer = eeconfig_read_default_layer();
|
||||
default_layer_set((layer_state_t)default_layer);
|
||||
|
||||
/* Also initialize layer state to trigger callback functions for layer_state */
|
||||
layer_state_set_kb((layer_state_t)layer_state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#ifndef MAGIC_H
|
||||
#define MAGIC_H
|
||||
#pragma once
|
||||
|
||||
void magic(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef MATRIX_H
|
||||
#define MATRIX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if (MATRIX_COLS <= 8)
|
||||
typedef uint8_t matrix_row_t;
|
||||
#elif (MATRIX_COLS <= 16)
|
||||
typedef uint16_t matrix_row_t;
|
||||
#elif (MATRIX_COLS <= 32)
|
||||
typedef uint32_t matrix_row_t;
|
||||
#else
|
||||
# error "MATRIX_COLS: invalid value"
|
||||
#endif
|
||||
|
||||
#if (MATRIX_ROWS <= 8)
|
||||
typedef uint8_t matrix_col_t;
|
||||
#elif (MATRIX_ROWS <= 16)
|
||||
typedef uint16_t matrix_col_t;
|
||||
#elif (MATRIX_ROWS <= 32)
|
||||
typedef uint32_t matrix_col_t;
|
||||
#else
|
||||
# error "MATRIX_ROWS: invalid value"
|
||||
#endif
|
||||
|
||||
#define MATRIX_ROW_SHIFTER ((matrix_row_t)1)
|
||||
|
||||
#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* number of matrix rows */
|
||||
uint8_t matrix_rows(void);
|
||||
/* number of matrix columns */
|
||||
uint8_t matrix_cols(void);
|
||||
/* should be called at early stage of startup before matrix_init.(optional) */
|
||||
void matrix_setup(void);
|
||||
/* intialize matrix for scaning. */
|
||||
void matrix_init(void);
|
||||
/* scan all key states on matrix */
|
||||
uint8_t matrix_scan(void);
|
||||
/* whether modified from previous scan. used after matrix_scan. */
|
||||
bool matrix_is_modified(void) __attribute__((deprecated));
|
||||
/* whether a switch is on */
|
||||
bool matrix_is_on(uint8_t row, uint8_t col);
|
||||
/* matrix state on row */
|
||||
matrix_row_t matrix_get_row(uint8_t row);
|
||||
/* print matrix for debug */
|
||||
void matrix_print(void);
|
||||
/* delay between changing matrix pin state and reading values */
|
||||
void matrix_io_delay(void);
|
||||
|
||||
/* power control */
|
||||
void matrix_power_up(void);
|
||||
void matrix_power_down(void);
|
||||
|
||||
/* executes code for Quantum */
|
||||
void matrix_init_quantum(void);
|
||||
void matrix_scan_quantum(void);
|
||||
|
||||
void matrix_init_kb(void);
|
||||
void matrix_scan_kb(void);
|
||||
|
||||
void matrix_init_user(void);
|
||||
void matrix_scan_user(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "keycode.h"
|
||||
|
|
@ -33,9 +33,9 @@ inline int8_t times_inv_sqrt2(int8_t x) {
|
|||
|
||||
static report_mouse_t mouse_report = {0};
|
||||
static void mousekey_debug(void);
|
||||
static uint8_t mousekey_accel = 0;
|
||||
static uint8_t mousekey_repeat = 0;
|
||||
static uint16_t last_timer = 0;
|
||||
static uint8_t mousekey_accel = 0;
|
||||
static uint8_t mousekey_repeat = 0;
|
||||
static uint8_t mousekey_wheel_repeat = 0;
|
||||
|
||||
#ifndef MK_3_SPEED
|
||||
|
||||
|
|
@ -66,6 +66,8 @@ uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
|
|||
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
||||
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
||||
|
||||
# ifndef MK_COMBINED
|
||||
|
||||
static uint8_t move_unit(void) {
|
||||
uint16_t unit;
|
||||
if (mousekey_accel & (1 << 0)) {
|
||||
|
|
@ -92,6 +94,44 @@ static uint8_t wheel_unit(void) {
|
|||
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2;
|
||||
} else if (mousekey_accel & (1 << 2)) {
|
||||
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed);
|
||||
} else if (mousekey_wheel_repeat == 0) {
|
||||
unit = MOUSEKEY_WHEEL_DELTA;
|
||||
} else if (mousekey_wheel_repeat >= mk_wheel_time_to_max) {
|
||||
unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
|
||||
} else {
|
||||
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_wheel_repeat) / mk_wheel_time_to_max;
|
||||
}
|
||||
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
|
||||
}
|
||||
|
||||
# else /* #ifndef MK_COMBINED */
|
||||
|
||||
static uint8_t move_unit(void) {
|
||||
uint16_t unit;
|
||||
if (mousekey_accel & (1 << 0)) {
|
||||
unit = 1;
|
||||
} else if (mousekey_accel & (1 << 1)) {
|
||||
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 2;
|
||||
} else if (mousekey_accel & (1 << 2)) {
|
||||
unit = MOUSEKEY_MOVE_MAX;
|
||||
} else if (mousekey_repeat == 0) {
|
||||
unit = MOUSEKEY_MOVE_DELTA;
|
||||
} else if (mousekey_repeat >= mk_time_to_max) {
|
||||
unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
|
||||
} else {
|
||||
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
|
||||
}
|
||||
return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
|
||||
}
|
||||
|
||||
static uint8_t wheel_unit(void) {
|
||||
uint16_t unit;
|
||||
if (mousekey_accel & (1 << 0)) {
|
||||
unit = 1;
|
||||
} else if (mousekey_accel & (1 << 1)) {
|
||||
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2;
|
||||
} else if (mousekey_accel & (1 << 2)) {
|
||||
unit = MOUSEKEY_WHEEL_MAX;
|
||||
} else if (mousekey_repeat == 0) {
|
||||
unit = MOUSEKEY_WHEEL_DELTA;
|
||||
} else if (mousekey_repeat >= mk_wheel_time_to_max) {
|
||||
|
|
@ -102,17 +142,22 @@ static uint8_t wheel_unit(void) {
|
|||
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
|
||||
}
|
||||
|
||||
# endif /* #ifndef MK_COMBINED */
|
||||
|
||||
void mousekey_task(void) {
|
||||
// report cursor and scroll movement independently
|
||||
report_mouse_t const tmpmr = mouse_report;
|
||||
if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) {
|
||||
|
||||
mouse_report.x = 0;
|
||||
mouse_report.y = 0;
|
||||
mouse_report.v = 0;
|
||||
mouse_report.h = 0;
|
||||
|
||||
if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) {
|
||||
if (mousekey_repeat != UINT8_MAX) mousekey_repeat++;
|
||||
mouse_report.v = 0;
|
||||
mouse_report.h = 0;
|
||||
if (mouse_report.x > 0) mouse_report.x = move_unit();
|
||||
if (mouse_report.x < 0) mouse_report.x = move_unit() * -1;
|
||||
if (mouse_report.y > 0) mouse_report.y = move_unit();
|
||||
if (mouse_report.y < 0) mouse_report.y = move_unit() * -1;
|
||||
if (tmpmr.x != 0) mouse_report.x = move_unit() * ((tmpmr.x > 0) ? 1 : -1);
|
||||
if (tmpmr.y != 0) mouse_report.y = move_unit() * ((tmpmr.y > 0) ? 1 : -1);
|
||||
|
||||
/* diagonal move [1/sqrt(2)] */
|
||||
if (mouse_report.x && mouse_report.y) {
|
||||
mouse_report.x = times_inv_sqrt2(mouse_report.x);
|
||||
|
|
@ -124,18 +169,12 @@ void mousekey_task(void) {
|
|||
mouse_report.y = 1;
|
||||
}
|
||||
}
|
||||
mousekey_send();
|
||||
last_timer_c = last_timer;
|
||||
mouse_report = tmpmr;
|
||||
}
|
||||
if ((mouse_report.v || mouse_report.h) && timer_elapsed(last_timer_w) > (mousekey_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) {
|
||||
if (mousekey_repeat != UINT8_MAX) mousekey_repeat++;
|
||||
mouse_report.x = 0;
|
||||
mouse_report.y = 0;
|
||||
if (mouse_report.v > 0) mouse_report.v = wheel_unit();
|
||||
if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1;
|
||||
if (mouse_report.h > 0) mouse_report.h = wheel_unit();
|
||||
if (mouse_report.h < 0) mouse_report.h = wheel_unit() * -1;
|
||||
if ((tmpmr.v || tmpmr.h) && timer_elapsed(last_timer_w) > (mousekey_wheel_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) {
|
||||
if (mousekey_wheel_repeat != UINT8_MAX) mousekey_wheel_repeat++;
|
||||
if (tmpmr.v != 0) mouse_report.v = wheel_unit() * ((tmpmr.v > 0) ? 1 : -1);
|
||||
if (tmpmr.h != 0) mouse_report.h = wheel_unit() * ((tmpmr.h > 0) ? 1 : -1);
|
||||
|
||||
/* diagonal move [1/sqrt(2)] */
|
||||
if (mouse_report.v && mouse_report.h) {
|
||||
mouse_report.v = times_inv_sqrt2(mouse_report.v);
|
||||
|
|
@ -147,10 +186,10 @@ void mousekey_task(void) {
|
|||
mouse_report.h = 1;
|
||||
}
|
||||
}
|
||||
mousekey_send();
|
||||
last_timer_w = last_timer;
|
||||
mouse_report = tmpmr;
|
||||
}
|
||||
|
||||
if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send();
|
||||
mouse_report = tmpmr;
|
||||
}
|
||||
|
||||
void mousekey_on(uint8_t code) {
|
||||
|
|
@ -221,7 +260,8 @@ void mousekey_off(uint8_t code) {
|
|||
mousekey_accel &= ~(1 << 1);
|
||||
else if (code == KC_MS_ACCEL2)
|
||||
mousekey_accel &= ~(1 << 2);
|
||||
if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0) mousekey_repeat = 0;
|
||||
if (mouse_report.x == 0 && mouse_report.y == 0) mousekey_repeat = 0;
|
||||
if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0;
|
||||
}
|
||||
|
||||
#else /* #ifndef MK_3_SPEED */
|
||||
|
|
@ -243,20 +283,22 @@ uint16_t w_intervals[mkspd_COUNT] = {MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0
|
|||
void mousekey_task(void) {
|
||||
// report cursor and scroll movement independently
|
||||
report_mouse_t const tmpmr = mouse_report;
|
||||
if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) {
|
||||
mouse_report.h = 0;
|
||||
mouse_report.v = 0;
|
||||
mousekey_send();
|
||||
last_timer_c = last_timer;
|
||||
mouse_report = tmpmr;
|
||||
mouse_report.x = 0;
|
||||
mouse_report.y = 0;
|
||||
mouse_report.v = 0;
|
||||
mouse_report.h = 0;
|
||||
|
||||
if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) {
|
||||
mouse_report.x = tmpmr.x;
|
||||
mouse_report.y = tmpmr.y;
|
||||
}
|
||||
if ((mouse_report.h || mouse_report.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) {
|
||||
mouse_report.x = 0;
|
||||
mouse_report.y = 0;
|
||||
mousekey_send();
|
||||
last_timer_w = last_timer;
|
||||
mouse_report = tmpmr;
|
||||
if ((tmpmr.h || tmpmr.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) {
|
||||
mouse_report.v = tmpmr.v;
|
||||
mouse_report.h = tmpmr.h;
|
||||
}
|
||||
|
||||
if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send();
|
||||
mouse_report = tmpmr;
|
||||
}
|
||||
|
||||
void adjust_speed(void) {
|
||||
|
|
@ -371,14 +413,17 @@ void mousekey_off(uint8_t code) {
|
|||
|
||||
void mousekey_send(void) {
|
||||
mousekey_debug();
|
||||
uint16_t time = timer_read();
|
||||
if (mouse_report.x || mouse_report.y) last_timer_c = time;
|
||||
if (mouse_report.v || mouse_report.h) last_timer_w = time;
|
||||
host_mouse_send(&mouse_report);
|
||||
last_timer = timer_read();
|
||||
}
|
||||
|
||||
void mousekey_clear(void) {
|
||||
mouse_report = (report_mouse_t){};
|
||||
mousekey_repeat = 0;
|
||||
mousekey_accel = 0;
|
||||
mouse_report = (report_mouse_t){};
|
||||
mousekey_repeat = 0;
|
||||
mousekey_wheel_repeat = 0;
|
||||
mousekey_accel = 0;
|
||||
}
|
||||
|
||||
static void mousekey_debug(void) {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MOUSEKEY_H
|
||||
# define MOUSEKEY_H
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "host.h"
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NODEBUG_H
|
||||
#define NODEBUG_H
|
||||
#pragma once
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
# define NO_DEBUG
|
||||
|
|
@ -25,5 +24,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#else
|
||||
# include "debug.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PRINT_H__
|
||||
#define PRINT_H__ 1
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -72,9 +71,7 @@ extern "C"
|
|||
|
||||
# elif defined(PROTOCOL_CHIBIOS) /* PROTOCOL_CHIBIOS */
|
||||
|
||||
# ifndef TERMINAL_ENABLE
|
||||
# include "chibios/printf.h"
|
||||
# endif
|
||||
# include "printf.h" // lib/printf/printf.h
|
||||
|
||||
# ifdef USER_PRINT /* USER_PRINT */
|
||||
|
||||
|
|
@ -89,7 +86,6 @@ extern "C"
|
|||
# define uprintf printf
|
||||
|
||||
# else /* NORMAL PRINT */
|
||||
|
||||
// Create user & normal print defines
|
||||
# define print(s) printf(s)
|
||||
# define println(s) printf(s "\r\n")
|
||||
|
|
@ -272,5 +268,3 @@ extern "C"
|
|||
#define pbin16(data) print_bin16(data)
|
||||
#define pbin_reverse(data) print_bin_reverse8(data)
|
||||
#define pbin_reverse16(data) print_bin_reverse16(data)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
# include <avr/pgmspace.h>
|
||||
#else
|
||||
# define PROGMEM
|
||||
# define PGM_P const char*
|
||||
# define memcpy_P(dest, src, n) memcpy(dest, src, n)
|
||||
# define pgm_read_byte(address_short) *((uint8_t*)(address_short))
|
||||
# define pgm_read_word(address_short) *((uint16_t*)(address_short))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#ifndef _RAW_HID_H_
|
||||
#define _RAW_HID_H_
|
||||
#pragma once
|
||||
|
||||
void raw_hid_receive(uint8_t *data, uint8_t length);
|
||||
|
||||
void raw_hid_send(uint8_t *data, uint8_t length);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ enum mouse_buttons {
|
|||
* See https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=75
|
||||
*/
|
||||
enum consumer_usages {
|
||||
// 15.5 Display Controls (https://www.usb.org/sites/default/files/hutrr41_0.pdf)
|
||||
BRIGHTNESS_UP = 0x06F,
|
||||
// 15.5 Display Controls
|
||||
SNAPSHOT = 0x065,
|
||||
BRIGHTNESS_UP = 0x06F, // https://www.usb.org/sites/default/files/hutrr41_0.pdf
|
||||
BRIGHTNESS_DOWN = 0x070,
|
||||
// 15.7 Transport Controls
|
||||
TRANSPORT_RECORD = 0x0B2,
|
||||
|
|
@ -59,6 +60,7 @@ enum consumer_usages {
|
|||
TRANSPORT_PREV_TRACK = 0x0B6,
|
||||
TRANSPORT_STOP = 0x0B7,
|
||||
TRANSPORT_EJECT = 0x0B8,
|
||||
TRANSPORT_RANDOM_PLAY = 0x0B9,
|
||||
TRANSPORT_STOP_EJECT = 0x0CC,
|
||||
TRANSPORT_PLAY_PAUSE = 0x0CD,
|
||||
// 15.9.1 Audio Controls - Volume
|
||||
|
|
@ -73,6 +75,7 @@ enum consumer_usages {
|
|||
AL_LOCK = 0x19E,
|
||||
AL_CONTROL_PANEL = 0x19F,
|
||||
AL_ASSISTANT = 0x1CB,
|
||||
AL_KEYBOARD_LAYOUT = 0x1AE,
|
||||
// 15.16 Generic GUI Application Controls
|
||||
AC_MINIMIZE = 0x206,
|
||||
AC_SEARCH = 0x221,
|
||||
|
|
@ -121,12 +124,6 @@ enum desktop_usages {
|
|||
|
||||
#define KEYBOARD_REPORT_KEYS 6
|
||||
|
||||
/* VUSB hardcodes keyboard and mouse+extrakey only */
|
||||
#if defined(PROTOCOL_VUSB)
|
||||
# undef KEYBOARD_SHARED_EP
|
||||
# undef MOUSE_SHARED_EP
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -190,7 +187,11 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
#if JOYSTICK_AXES_COUNT > 0
|
||||
# if JOYSTICK_AXES_RESOLUTION > 8
|
||||
int16_t axes[JOYSTICK_AXES_COUNT];
|
||||
# else
|
||||
int8_t axes[JOYSTICK_AXES_COUNT];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if JOYSTICK_BUTTON_COUNT > 0
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SENDCHAR_H
|
||||
#define SENDCHAR_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -30,5 +29,3 @@ int8_t sendchar(uint8_t c);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef SLEEP_LED_H
|
||||
#define SLEEP_LED_H
|
||||
#pragma once
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
|
||||
|
|
@ -16,5 +15,3 @@ void sleep_led_toggle(void);
|
|||
# define sleep_led_toggle()
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef SUSPEND_H
|
||||
#define SUSPEND_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -13,5 +12,3 @@ void suspend_wakeup_init_user(void);
|
|||
void suspend_wakeup_init_kb(void);
|
||||
void suspend_power_down_user(void);
|
||||
void suspend_power_down_kb(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,4 +30,4 @@ uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), l
|
|||
void set_time(uint32_t t) { current_time = t; }
|
||||
void advance_time(uint32_t ms) { current_time += ms; }
|
||||
|
||||
void wait_ms(uint32_t ms) { advance_time(ms); }
|
||||
void wait_ms(uint32_t ms) { advance_time(ms); }
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H 1
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -45,11 +44,9 @@ uint16_t timer_elapsed(uint16_t last);
|
|||
uint32_t timer_elapsed32(uint32_t last);
|
||||
|
||||
// Utility functions to check if a future time has expired & autmatically handle time wrapping if checked / reset frequently (half of max value)
|
||||
#define timer_expired(current, future) (((uint16_t)current - (uint16_t)future) < 0x8000)
|
||||
#define timer_expired32(current, future) (((uint32_t)current - (uint32_t)future) < 0x80000000)
|
||||
#define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2)
|
||||
#define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "uart.h"
|
||||
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||
# define UDRn UDR0
|
||||
# define UBRRnL UBRR0L
|
||||
# define UCSRnA UCSR0A
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef _uart_included_h_
|
||||
#define _uart_included_h_
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -7,5 +6,3 @@ void uart_init(uint32_t baud);
|
|||
void uart_putchar(uint8_t c);
|
||||
uint8_t uart_getchar(void);
|
||||
uint8_t uart_available(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
|
||||
// bit population - return number of on-bit
|
||||
__attribute__((noinline)) uint8_t bitpop(uint8_t bits) {
|
||||
uint8_t c;
|
||||
for (c = 0; bits; c++) bits &= bits - 1;
|
||||
return c;
|
||||
/*
|
||||
const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
|
||||
return bit_count[bits>>4] + bit_count[bits&0x0F]
|
||||
*/
|
||||
}
|
||||
|
||||
uint8_t bitpop16(uint16_t bits) {
|
||||
uint8_t c;
|
||||
for (c = 0; bits; c++) bits &= bits - 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
uint8_t bitpop32(uint32_t bits) {
|
||||
uint8_t c;
|
||||
for (c = 0; bits; c++) bits &= bits - 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
// most significant on-bit - return highest location of on-bit
|
||||
// NOTE: return 0 when bit0 is on or all bits are off
|
||||
__attribute__((noinline)) uint8_t biton(uint8_t bits) {
|
||||
uint8_t n = 0;
|
||||
if (bits >> 4) {
|
||||
bits >>= 4;
|
||||
n += 4;
|
||||
}
|
||||
if (bits >> 2) {
|
||||
bits >>= 2;
|
||||
n += 2;
|
||||
}
|
||||
if (bits >> 1) {
|
||||
bits >>= 1;
|
||||
n += 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
uint8_t biton16(uint16_t bits) {
|
||||
uint8_t n = 0;
|
||||
if (bits >> 8) {
|
||||
bits >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
if (bits >> 4) {
|
||||
bits >>= 4;
|
||||
n += 4;
|
||||
}
|
||||
if (bits >> 2) {
|
||||
bits >>= 2;
|
||||
n += 2;
|
||||
}
|
||||
if (bits >> 1) {
|
||||
bits >>= 1;
|
||||
n += 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
uint8_t biton32(uint32_t bits) {
|
||||
uint8_t n = 0;
|
||||
if (bits >> 16) {
|
||||
bits >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (bits >> 8) {
|
||||
bits >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
if (bits >> 4) {
|
||||
bits >>= 4;
|
||||
n += 4;
|
||||
}
|
||||
if (bits >> 2) {
|
||||
bits >>= 2;
|
||||
n += 2;
|
||||
}
|
||||
if (bits >> 1) {
|
||||
bits >>= 1;
|
||||
n += 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) uint8_t bitrev(uint8_t bits) {
|
||||
bits = (bits & 0x0f) << 4 | (bits & 0xf0) >> 4;
|
||||
bits = (bits & 0b00110011) << 2 | (bits & 0b11001100) >> 2;
|
||||
bits = (bits & 0b01010101) << 1 | (bits & 0b10101010) >> 1;
|
||||
return bits;
|
||||
}
|
||||
|
||||
uint16_t bitrev16(uint16_t bits) {
|
||||
bits = bitrev(bits & 0x00ff) << 8 | bitrev((bits & 0xff00) >> 8);
|
||||
return bits;
|
||||
}
|
||||
|
||||
uint32_t bitrev32(uint32_t bits) {
|
||||
bits = (uint32_t)bitrev16(bits & 0x0000ffff) << 16 | bitrev16((bits & 0xffff0000) >> 16);
|
||||
return bits;
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// convert to L string
|
||||
#define LSTR(s) XLSTR(s)
|
||||
#define XLSTR(s) L## #s
|
||||
// convert to string
|
||||
#define STR(s) XSTR(s)
|
||||
#define XSTR(s) #s
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t bitpop(uint8_t bits);
|
||||
uint8_t bitpop16(uint16_t bits);
|
||||
uint8_t bitpop32(uint32_t bits);
|
||||
|
||||
uint8_t biton(uint8_t bits);
|
||||
uint8_t biton16(uint16_t bits);
|
||||
uint8_t biton32(uint32_t bits);
|
||||
|
||||
uint8_t bitrev(uint8_t bits);
|
||||
uint16_t bitrev16(uint16_t bits);
|
||||
uint32_t bitrev32(uint32_t bits);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
#ifndef _VIRTSER_H_
|
||||
#define _VIRTSER_H_
|
||||
#pragma once
|
||||
|
||||
/* Define this function in your code to process incoming bytes */
|
||||
void virtser_recv(const uint8_t ch);
|
||||
|
||||
/* Call this to send a character over the Virtual Serial Device */
|
||||
void virtser_send(const uint8_t byte);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef WAIT_H
|
||||
#define WAIT_H
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
|
@ -12,7 +11,7 @@ extern "C" {
|
|||
# define wait_ms(ms) _delay_ms(ms)
|
||||
# define wait_us(us) _delay_us(us)
|
||||
#elif defined PROTOCOL_CHIBIOS
|
||||
# include "ch.h"
|
||||
# include <ch.h>
|
||||
# define wait_ms(ms) \
|
||||
do { \
|
||||
if (ms != 0) { \
|
||||
|
|
@ -41,5 +40,3 @@ void wait_ms(uint32_t ms);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue