feat: add get layer command
This commit is contained in:
committed by
Florian Didron
parent
f7408111c7
commit
ac7de6603c
@@ -1,3 +1,4 @@
|
|||||||
|
#include QMK_KEYBOARD_H
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "webusb.h"
|
#include "webusb.h"
|
||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
@@ -41,13 +42,29 @@ void webusb_receive(uint8_t *data, uint8_t length) {
|
|||||||
|
|
||||||
if(webusb_state.paired == true) {
|
if(webusb_state.paired == true) {
|
||||||
switch(command) {
|
switch(command) {
|
||||||
//Handle commands in here
|
//Handle commands in here
|
||||||
|
case WEBUSB_GET_LAYER:
|
||||||
|
webusb_layer_event();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
webusb_error(WEBUSB_STATUS_NOT_PAIRED);
|
webusb_error(WEBUSB_STATUS_NOT_PAIRED);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void webusb_layer_event() {
|
||||||
|
uint8_t layer;
|
||||||
|
uint8_t event[4];
|
||||||
|
layer = biton32(layer_state);
|
||||||
|
event[0] = WEBUSB_STATUS_OK;
|
||||||
|
event[1] = WEBUSB_EVT_LAYER;
|
||||||
|
event[2] = layer;
|
||||||
|
event[3] = WEBUSB_STOP_BIT;
|
||||||
|
webusb_send(event, sizeof(event));
|
||||||
|
}
|
||||||
|
|
||||||
void webusb_error(uint8_t code) {
|
void webusb_error(uint8_t code) {
|
||||||
uint8_t buffer[1];
|
uint8_t buffer[1];
|
||||||
buffer[0] = code;
|
buffer[0] = code;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
void webusb_receive(uint8_t *data, uint8_t length);
|
void webusb_receive(uint8_t *data, uint8_t length);
|
||||||
void webusb_send(uint8_t *data, uint8_t length);
|
void webusb_send(uint8_t *data, uint8_t length);
|
||||||
|
void webusb_layer_event(void);
|
||||||
void webusb_error(uint8_t);
|
void webusb_error(uint8_t);
|
||||||
void webusb_set_pairing_state(void);
|
void webusb_set_pairing_state(void);
|
||||||
|
|
||||||
@@ -30,7 +31,8 @@ enum Webusb_Status_Code {
|
|||||||
|
|
||||||
enum Webusb_Command_Code {
|
enum Webusb_Command_Code {
|
||||||
WEBUSB_CMD_PAIR,
|
WEBUSB_CMD_PAIR,
|
||||||
WEBUSB_GET_FW_VERSION
|
WEBUSB_GET_FW_VERSION,
|
||||||
|
WEBUSB_GET_LAYER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Webusb_Event_Code {
|
enum Webusb_Event_Code {
|
||||||
|
|||||||
Reference in New Issue
Block a user