mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
outputs api
This commit is contained in:
parent
6490c8835c
commit
3ffbc7554a
@ -38,6 +38,8 @@ from ....validators import raise_error
|
|||||||
from ....validators.basic import valid_bool
|
from ....validators.basic import valid_bool
|
||||||
from ....validators.basic import valid_int_f0
|
from ....validators.basic import valid_int_f0
|
||||||
from ....validators.os import valid_printable_filename
|
from ....validators.os import valid_printable_filename
|
||||||
|
from ....validators.kvm import valid_hid_keyboard_output
|
||||||
|
from ....validators.kvm import valid_hid_mouse_output
|
||||||
from ....validators.kvm import valid_hid_key
|
from ....validators.kvm import valid_hid_key
|
||||||
from ....validators.kvm import valid_hid_mouse_move
|
from ....validators.kvm import valid_hid_mouse_move
|
||||||
from ....validators.kvm import valid_hid_mouse_button
|
from ....validators.kvm import valid_hid_mouse_button
|
||||||
@ -67,6 +69,16 @@ class HidApi:
|
|||||||
async def __state_handler(self, _: Request) -> Response:
|
async def __state_handler(self, _: Request) -> Response:
|
||||||
return make_json_response(await self.__hid.get_state())
|
return make_json_response(await self.__hid.get_state())
|
||||||
|
|
||||||
|
@exposed_http("POST", "/hid/keyboard/set_params")
|
||||||
|
async def __keyboard_set_params_handler(self, request: Request) -> Response:
|
||||||
|
self.__hid.set_keyboard_output(valid_hid_keyboard_output(request.query.get("output")))
|
||||||
|
return make_json_response()
|
||||||
|
|
||||||
|
@exposed_http("POST", "/hid/mouse/set_params")
|
||||||
|
async def __mouse_set_params_handler(self, request: Request) -> Response:
|
||||||
|
self.__hid.set_mouse_output(valid_hid_mouse_output(request.query.get("output")))
|
||||||
|
return make_json_response()
|
||||||
|
|
||||||
@exposed_http("POST", "/hid/reset")
|
@exposed_http("POST", "/hid/reset")
|
||||||
async def __reset_handler(self, _: Request) -> Response:
|
async def __reset_handler(self, _: Request) -> Response:
|
||||||
await self.__hid.reset()
|
await self.__hid.reset()
|
||||||
|
|||||||
@ -83,6 +83,14 @@ def valid_stream_resolution(arg: Any) -> str:
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
def valid_hid_keyboard_output(arg: Any) -> str:
|
||||||
|
return check_string_in_list(arg, "Keyboard output", ["usb", "ps2", ""])
|
||||||
|
|
||||||
|
|
||||||
|
def valid_hid_mouse_output(arg: Any) -> str:
|
||||||
|
return check_string_in_list(arg, "Mouse output", ["usb", "usb_rel", "ps2", ""])
|
||||||
|
|
||||||
|
|
||||||
def valid_hid_key(arg: Any) -> str:
|
def valid_hid_key(arg: Any) -> str:
|
||||||
return check_string_in_list(arg, "HID key", KEYMAP, lower=False)
|
return check_string_in_list(arg, "HID key", KEYMAP, lower=False)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user