new hid protocol with crc

This commit is contained in:
Devaev Maxim
2019-02-07 05:45:36 +03:00
parent 5bec2ff144
commit de1bed956c
12 changed files with 388 additions and 156 deletions

View File

@@ -62,6 +62,11 @@ function Hid() {
__mouse.setSocket(ws);
};
self.setState = function(state) {
__keyboard.setState(state);
__mouse.setState(state);
};
var __releaseAll = function() {
__keyboard.releaseAll();
};

View File

@@ -4,6 +4,7 @@ function Keyboard() {
/********************************************************************************/
var __ws = null;
var __ok = true;
var __keys = [].slice.call($$$("div#keyboard-desktop div.keyboard-block div.keyboard-row div.key"));
var __modifiers = [].slice.call($$$("div#keyboard-desktop div.keyboard-block div.keyboard-row div.modifier"));
@@ -53,6 +54,10 @@ function Keyboard() {
__updateLeds();
};
self.setState = function(state) {
__ok = state.ok;
};
self.releaseAll = function() {
__keys.concat(__modifiers).forEach(function(el_key) {
if (__isActive(el_key)) {
@@ -73,8 +78,13 @@ function Keyboard() {
|| $("keyboard-window").classList.contains("window-active")
)
) {
$("hid-keyboard-led").className = "led-green";
$("hid-keyboard-led").title = "Keyboard captured";
if (__ok) {
$("hid-keyboard-led").className = "led-green";
$("hid-keyboard-led").title = "Keyboard captured";
} else {
$("hid-keyboard-led").className = "led-yellow";
$("hid-keyboard-led").title = "Keyboard captured, HID offline";
}
} else {
$("hid-keyboard-led").className = "led-gray";
$("hid-keyboard-led").title = "Keyboard free";

View File

@@ -4,6 +4,7 @@ function Mouse() {
/********************************************************************************/
var __ws = null;
var __ok = true;
var __current_pos = {x: 0, y:0};
var __sent_pos = {x: 0, y:0};
@@ -44,6 +45,10 @@ function Mouse() {
__updateLeds();
};
self.setState = function(state) {
__ok = state.ok;
};
var __hoverStream = function() {
__stream_hovered = true;
__updateLeds();
@@ -57,8 +62,13 @@ function Mouse() {
var __updateLeds = function() {
if (__ws && (__stream_hovered || tools.browser.is_ios)) {
// Mouse is always available on iOS via touchscreen
$("hid-mouse-led").className = "led-green";
$("hid-mouse-led").title = "Mouse tracked";
if (__ok) {
$("hid-mouse-led").className = "led-green";
$("hid-mouse-led").title = "Mouse tracked";
} else {
$("hid-mouse-led").className = "led-yellow";
$("hid-mouse-led").title = "Mouse tracked, HID offline";
}
} else {
$("hid-mouse-led").className = "led-gray";
$("hid-mouse-led").title = "Mouse free";

View File

@@ -84,6 +84,8 @@ function Session() {
} else if (event.msg_type === "event") {
if (event.msg.event === "info_state") {
__setKvmdInfo(event.msg.event_attrs);
} else if (event.msg.event === "hid_state") {
__hid.setState(event.msg.event_attrs);
} else if (event.msg.event === "atx_state") {
__atx.setState(event.msg.event_attrs);
} else if (event.msg.event === "msd_state") {