summaryrefslogtreecommitdiff
path: root/keyboards/planck/ez/ez.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/planck/ez/ez.c')
-rw-r--r--keyboards/planck/ez/ez.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index 79310da10a..f34af7a290 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -16,6 +16,9 @@
#include "ez.h"
#include "ch.h"
#include "hal.h"
+#ifdef WEBUSB_ENABLE
+#include "webusb.h"
+#endif
keyboard_config_t keyboard_config;
@@ -247,6 +250,16 @@ uint32_t layer_state_set_kb(uint32_t state) {
planck_ez_right_led_off();
state = layer_state_set_user(state);
uint8_t layer = biton32(state);
+#ifdef WEBUSB_ENABLE
+ if(webusb_state.paired == true) {
+ uint8_t event[4];
+ event[0] = WEBUSB_STATUS_OK;
+ event[1] = WEBUSB_EVT_LAYER;
+ event[2] = layer;
+ event[3] = WEBUSB_STOP_BIT;
+ webusb_send(event, sizeof(event));
+ }
+#endif
switch (layer) {
case 1:
planck_ez_left_led_on();
@@ -265,6 +278,17 @@ uint32_t layer_state_set_kb(uint32_t state) {
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+#ifdef WEBUSB_ENABLE
+ if(webusb_state.paired == true) {
+ uint8_t event[5];
+ event[0] = WEBUSB_STATUS_OK;
+ event[1] = record->event.pressed ? WEBUSB_EVT_KEYDOWN : WEBUSB_EVT_KEYUP;
+ event[2] = record->event.key.col;
+ event[3] = record->event.key.row;
+ event[4] = WEBUSB_STOP_BIT;
+ webusb_send(event, sizeof(event));
+ }
+#endif
switch (keycode) {
case LED_LEVEL:
if (record->event.pressed) {
@@ -325,3 +349,38 @@ bool music_mask_kb(uint16_t keycode) {
}
}
#endif
+#ifdef WEBUSB_ENABLE
+static uint16_t loops = 0;
+static bool is_on = false;
+
+void matrix_scan_kb(void) {
+ if(webusb_state.pairing == true) {
+ if(loops == 0) {
+ //lights off
+ }
+ if(loops % WEBUSB_BLINK_STEPS == 0) {
+ if(is_on) {
+ planck_ez_left_led_on();
+ planck_ez_right_led_off();
+ }
+ else {
+ planck_ez_left_led_off();
+ planck_ez_right_led_on();
+ }
+ is_on ^= 1;
+ }
+ if(loops > WEBUSB_BLINK_END * 2) {
+ webusb_state.pairing = false;
+ loops = 0;
+ planck_ez_left_led_off();
+ planck_ez_right_led_off();
+ }
+ loops++;
+ }
+ else if(loops > 0) {
+ loops = 0;
+ planck_ez_left_led_off();
+ planck_ez_right_led_off();
+ }
+}
+#endif