mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-04-30 18:06:35 +08:00
better ui
This commit is contained in:
@@ -56,6 +56,14 @@ class Hid(multiprocessing.Process):
|
||||
|
||||
# TODO: add reset or power switching
|
||||
|
||||
def get_state(self) -> Dict:
|
||||
return {
|
||||
"features": {
|
||||
"keyboard": True, # Always
|
||||
"mouse": False, # TODO
|
||||
},
|
||||
}
|
||||
|
||||
async def send_key_event(self, key: str, state: bool) -> None:
|
||||
if not self.__stop_event.is_set():
|
||||
async with self.__lock:
|
||||
|
||||
@@ -121,6 +121,8 @@ class Server: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
app.router.add_get("/ws", self.__ws_handler)
|
||||
|
||||
app.router.add_get("/hid", self.__hid_state_handler)
|
||||
|
||||
app.router.add_get("/atx", self.__atx_state_handler)
|
||||
app.router.add_post("/atx/click", self.__atx_click_handler)
|
||||
|
||||
@@ -170,6 +172,9 @@ class Server: # pylint: disable=too-many-instance-attributes
|
||||
break
|
||||
return ws
|
||||
|
||||
async def __hid_state_handler(self, _: aiohttp.web.Request) -> aiohttp.web.Response:
|
||||
return _json(self.__hid.get_state())
|
||||
|
||||
async def __atx_state_handler(self, _: aiohttp.web.Request) -> aiohttp.web.Response:
|
||||
return _json(self.__atx.get_state())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user