summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-07-24 02:09:18 +0300
committerMaxim Devaev <[email protected]>2021-07-24 02:09:18 +0300
commita33efcaef3e69fb097a71198d6b8cecb02491800 (patch)
treed7cd7b79d2848133d2e988515e7e7343b63120ac
parent96481aa745026b614f442e92f421fe32f83c1d90 (diff)
disabled instead of empty string
-rw-r--r--kvmd/plugins/hid/_mcu/__init__.py8
-rw-r--r--kvmd/plugins/hid/_mcu/proto.py16
-rw-r--r--kvmd/validators/hid.py4
-rw-r--r--web/share/js/kvm/hid.js8
4 files changed, 19 insertions, 17 deletions
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py
index bcca89b9..07aeface 100644
--- a/kvmd/plugins/hid/_mcu/__init__.py
+++ b/kvmd/plugins/hid/_mcu/__init__.py
@@ -179,12 +179,12 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
if outputs1 & 0b10000000: # Dynamic
if outputs2 & 0b00000001: # USB
- keyboard_outputs["available"].extend(["usb"])
- mouse_outputs["available"].extend(["usb", "usb_rel"])
+ keyboard_outputs["available"].extend(["usb", "disabled"])
+ mouse_outputs["available"].extend(["usb", "usb_rel", "disabled"])
if outputs2 & 0b00000010: # PS/2
- keyboard_outputs["available"].extend(["ps2"])
- mouse_outputs["available"].extend(["ps2"])
+ keyboard_outputs["available"].extend(["ps2", "disabled"])
+ mouse_outputs["available"].extend(["ps2", "disabled"])
active_keyboard = get_active_keyboard(outputs1)
if active_keyboard in keyboard_outputs["available"]:
diff --git a/kvmd/plugins/hid/_mcu/proto.py b/kvmd/plugins/hid/_mcu/proto.py
index bc3feafa..16757d7d 100644
--- a/kvmd/plugins/hid/_mcu/proto.py
+++ b/kvmd/plugins/hid/_mcu/proto.py
@@ -38,14 +38,15 @@ class BaseEvent:
# =====
_KEYBOARD_NAMES_TO_CODES = {
- "usb": 0b00000001,
- "ps2": 0b00000011,
+ "disabled": 0b00000000,
+ "usb": 0b00000001,
+ "ps2": 0b00000011,
}
_KEYBOARD_CODES_TO_NAMES = tools.swapped_kvs(_KEYBOARD_NAMES_TO_CODES)
def get_active_keyboard(outputs: int) -> str:
- return _KEYBOARD_CODES_TO_NAMES.get(outputs & 0b00000111, "")
+ return _KEYBOARD_CODES_TO_NAMES.get(outputs & 0b00000111, "disabled")
@dataclasses.dataclass(frozen=True)
@@ -62,15 +63,16 @@ class SetKeyboardOutputEvent(BaseEvent):
# =====
_MOUSE_NAMES_TO_CODES = {
- "usb": 0b00001000,
- "usb_rel": 0b00010000,
- "ps2": 0b00011000,
+ "disabled": 0b00000000,
+ "usb": 0b00001000,
+ "usb_rel": 0b00010000,
+ "ps2": 0b00011000,
}
_MOUSE_CODES_TO_NAMES = tools.swapped_kvs(_MOUSE_NAMES_TO_CODES)
def get_active_mouse(outputs: int) -> str:
- return _MOUSE_CODES_TO_NAMES.get(outputs & 0b00111000, "")
+ return _MOUSE_CODES_TO_NAMES.get(outputs & 0b00111000, "disabled")
@dataclasses.dataclass(frozen=True)
diff --git a/kvmd/validators/hid.py b/kvmd/validators/hid.py
index f47a516c..7d942969 100644
--- a/kvmd/validators/hid.py
+++ b/kvmd/validators/hid.py
@@ -33,11 +33,11 @@ from .basic import valid_number
# =====
def valid_hid_keyboard_output(arg: Any) -> str:
- return check_string_in_list(arg, "Keyboard output", ["usb", "ps2", ""])
+ return check_string_in_list(arg, "Keyboard output", ["usb", "ps2", "disabled"])
def valid_hid_mouse_output(arg: Any) -> str:
- return check_string_in_list(arg, "Mouse output", ["usb", "usb_rel", "ps2", ""])
+ return check_string_in_list(arg, "Mouse output", ["usb", "usb_rel", "ps2", "disabled"])
def valid_hid_key(arg: Any) -> str:
diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js
index dac36341..f5d02dec 100644
--- a/web/share/js/kvm/hid.js
+++ b/web/share/js/kvm/hid.js
@@ -118,9 +118,9 @@ export function Hid(__getResolution) {
for (let args of [
["USB", "usb"],
["PS/2", "ps2"],
- ["Off", ""],
+ ["Off", "disabled"],
]) {
- if (keyboard_outputs.includes(args[1]) || !args[1]) {
+ if (keyboard_outputs.includes(args[1])) {
html += tools.radioMakeItem("hid-outputs-keyboard-radio", args[0], args[1]);
}
}
@@ -138,9 +138,9 @@ export function Hid(__getResolution) {
["USB", "usb", false],
["USB Relative", "usb_rel", true],
["PS/2", "ps2", true],
- ["Off", ""],
+ ["Off", "disabled"],
]) {
- if (mouse_outputs.includes(args[1]) || !args[1]) {
+ if (mouse_outputs.includes(args[1])) {
html += tools.radioMakeItem("hid-outputs-mouse-radio", args[0], args[1]);
has_relative = (has_relative || args[2]);
}