diff options
author | Devaev Maxim <[email protected]> | 2019-02-07 05:45:36 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-02-07 05:45:36 +0300 |
commit | de1bed956cc714e8b750e3df22a563eac0800876 (patch) | |
tree | 8d5bea19bd8380313eab5ee1cdfb75784fdb3dc7 /web/share | |
parent | 5bec2ff1449832be374d69ece14e7a63d5d7379a (diff) |
new hid protocol with crc
Diffstat (limited to 'web/share')
-rw-r--r-- | web/share/js/kvm/hid.js | 5 | ||||
-rw-r--r-- | web/share/js/kvm/keyboard.js | 14 | ||||
-rw-r--r-- | web/share/js/kvm/mouse.js | 14 | ||||
-rw-r--r-- | web/share/js/kvm/session.js | 2 |
4 files changed, 31 insertions, 4 deletions
diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js index 1c60b099..b6896955 100644 --- a/web/share/js/kvm/hid.js +++ b/web/share/js/kvm/hid.js @@ -62,6 +62,11 @@ function Hid() { __mouse.setSocket(ws); }; + self.setState = function(state) { + __keyboard.setState(state); + __mouse.setState(state); + }; + var __releaseAll = function() { __keyboard.releaseAll(); }; diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js index c424c659..d5ccd80f 100644 --- a/web/share/js/kvm/keyboard.js +++ b/web/share/js/kvm/keyboard.js @@ -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"; diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index 59b3fc73..75836b1d 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -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"; diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js index 95f8fd88..7f2100bd 100644 --- a/web/share/js/kvm/session.js +++ b/web/share/js/kvm/session.js @@ -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") { |