better ui

This commit is contained in:
Devaev Maxim
2018-07-13 20:43:45 +00:00
parent e118d270df
commit 73ec9d853e
5 changed files with 117 additions and 65 deletions

View File

@@ -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:

View File

@@ -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())