diff options
author | Devaev Maxim <[email protected]> | 2019-04-08 04:58:32 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-04-08 04:58:32 +0300 |
commit | 9243d2a00c86aa9b5df2b1df20d2ba57be0bed47 (patch) | |
tree | 4d86bf39d432af121fff66a863864719c885d84d /kvmd/validators/kvm.py | |
parent | 7eca51f17b7c2c95b54d4c2b77caa6c8554ef4f4 (diff) |
refactoring
Diffstat (limited to 'kvmd/validators/kvm.py')
-rw-r--r-- | kvmd/validators/kvm.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py index 034587ef..40f5ced1 100644 --- a/kvmd/validators/kvm.py +++ b/kvmd/validators/kvm.py @@ -22,6 +22,8 @@ from typing import Any +from .. import keymap + from . import check_string_in_list from .basic import valid_number @@ -46,3 +48,22 @@ def valid_stream_quality(arg: Any) -> int: def valid_stream_fps(arg: Any) -> int: return int(valid_number(arg, min=0, max=30, name="stream FPS")) + + +# ===== +def valid_hid_key(arg: Any) -> str: + return check_string_in_list(arg, "HID key", keymap.KEYMAP, lower=False) + + +def valid_hid_mouse_move(arg: Any) -> int: + arg = valid_number(arg, name="HID mouse move") + return min(max(-32768, arg), 32767) + + +def valid_hid_mouse_button(arg: Any) -> str: + return check_string_in_list(arg, "HID mouse button", ["left", "right"]) + + +def valid_hid_mouse_wheel(arg: Any) -> int: + arg = valid_number(arg, name="HID mouse wheel") + return min(max(-128, arg), 127) |