2020-10-14 21:16:42 +02:00
|
|
|
/* Copyright 2020 Ilya Zhuravlev
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2020-10-18 20:36:45 +02:00
|
|
|
#include <inttypes.h>
|
2020-12-07 01:23:57 +01:00
|
|
|
#include <stdbool.h>
|
2020-10-18 20:36:45 +02:00
|
|
|
|
2021-07-03 05:19:41 +02:00
|
|
|
#define VIAL_PROTOCOL_VERSION ((uint32_t)0x00000004)
|
2021-07-09 01:27:26 +02:00
|
|
|
#define VIAL_RAW_EPSIZE 32
|
2020-10-18 20:36:45 +02:00
|
|
|
|
2021-07-03 19:30:43 +02:00
|
|
|
void vial_init(void);
|
2020-10-14 21:16:42 +02:00
|
|
|
void vial_handle_cmd(uint8_t *data, uint8_t length);
|
2020-12-07 01:23:57 +01:00
|
|
|
|
|
|
|
#ifdef VIAL_ENCODERS_ENABLE
|
2021-06-26 22:22:02 +02:00
|
|
|
bool vial_encoder_update(uint8_t index, bool clockwise);
|
2020-12-07 01:23:57 +01:00
|
|
|
#endif
|
2020-12-27 14:03:10 +01:00
|
|
|
|
|
|
|
extern int vial_unlocked;
|
|
|
|
extern int vial_unlock_in_progress;
|
2020-12-29 21:36:12 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
vial_get_keyboard_id = 0x00,
|
|
|
|
vial_get_size = 0x01,
|
|
|
|
vial_get_def = 0x02,
|
|
|
|
vial_get_encoder = 0x03,
|
|
|
|
vial_set_encoder = 0x04,
|
2020-12-30 01:30:29 +01:00
|
|
|
vial_get_unlock_status = 0x05,
|
2020-12-29 21:36:12 +01:00
|
|
|
vial_unlock_start = 0x06,
|
|
|
|
vial_unlock_poll = 0x07,
|
|
|
|
vial_lock = 0x08,
|
2021-06-30 01:43:11 +02:00
|
|
|
vial_qmk_settings_query = 0x09,
|
|
|
|
vial_qmk_settings_get = 0x0A,
|
|
|
|
vial_qmk_settings_set = 0x0B,
|
2021-07-01 21:00:12 +02:00
|
|
|
vial_qmk_settings_reset = 0x0C,
|
2021-07-03 19:30:43 +02:00
|
|
|
vial_dynamic_entry_op = 0x0D, /* operate on tapdance, combos, etc */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
dynamic_vial_get_number_of_entries = 0x00,
|
|
|
|
dynamic_vial_tap_dance_get = 0x01,
|
|
|
|
dynamic_vial_tap_dance_set = 0x02,
|
2021-07-04 16:11:04 +02:00
|
|
|
dynamic_vial_combo_get = 0x03,
|
|
|
|
dynamic_vial_combo_set = 0x04,
|
2020-12-29 21:36:12 +01:00
|
|
|
};
|
2021-01-03 15:12:16 +01:00
|
|
|
|
2021-07-04 01:48:01 +02:00
|
|
|
/* Fake position in keyboard matrix, can't use 255 as that is immediately rejected by IS_NOEVENT
|
|
|
|
used to send arbitrary keycodes thru process_record_quantum_helper */
|
|
|
|
#define VIAL_MATRIX_MAGIC 254
|
2021-07-03 19:30:43 +02:00
|
|
|
|
|
|
|
#ifdef TAP_DANCE_ENABLE
|
|
|
|
|
|
|
|
#define VIAL_TAP_DANCE_ENABLE
|
|
|
|
|
|
|
|
#ifndef VIAL_TAP_DANCE_ENTRIES
|
|
|
|
#define VIAL_TAP_DANCE_ENTRIES 16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t on_tap;
|
|
|
|
uint16_t on_hold;
|
|
|
|
uint16_t on_double_tap;
|
|
|
|
uint16_t on_tap_hold;
|
|
|
|
uint16_t custom_tapping_term;
|
|
|
|
} vial_tap_dance_entry_t;
|
|
|
|
_Static_assert(sizeof(vial_tap_dance_entry_t) == 10, "Unexpected size of the vial_tap_dance_entry_t structure");
|
|
|
|
|
|
|
|
#else
|
|
|
|
#undef VIAL_TAP_DANCE_ENTRIES
|
|
|
|
#define VIAL_TAP_DANCE_ENTRIES 0
|
|
|
|
#endif
|
2021-07-04 05:12:12 +02:00
|
|
|
|
|
|
|
#ifdef COMBO_ENABLE
|
|
|
|
#define VIAL_COMBO_ENABLE
|
|
|
|
|
|
|
|
#ifndef VIAL_COMBO_ENTRIES
|
|
|
|
#define VIAL_COMBO_ENTRIES 16
|
|
|
|
#endif
|
|
|
|
|
2021-07-04 16:11:04 +02:00
|
|
|
typedef struct {
|
|
|
|
uint16_t input[4];
|
|
|
|
uint16_t output;
|
|
|
|
} vial_combo_entry_t;
|
|
|
|
_Static_assert(sizeof(vial_combo_entry_t) == 10, "Unexpected size of the vial_combo_entry_t structure");
|
|
|
|
|
2021-07-04 05:12:12 +02:00
|
|
|
/* also to catch wrong include order in e.g. process_combo.h */
|
|
|
|
#ifdef COMBO_COUNT
|
|
|
|
#error COMBO_COUNT redefined - define VIAL_COMBO_ENTRIES instead
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define COMBO_COUNT VIAL_COMBO_ENTRIES
|
|
|
|
|
2021-07-09 00:12:04 +02:00
|
|
|
#else
|
|
|
|
#define VIAL_COMBO_ENTRIES 0
|
2021-07-04 05:12:12 +02:00
|
|
|
#endif
|