using evdev instead of string constants

This commit is contained in:
Maxim Devaev
2025-05-01 03:03:25 +03:00
parent 1624b0cbf8
commit ebbd55ee17
29 changed files with 692 additions and 539 deletions

View File

@@ -1,35 +0,0 @@
# ========================================================================== #
# #
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2024 Maxim Devaev <mdevaev@gmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
# ========================================================================== #
import pytest
from kvmd.keyboard.mappings import KEYMAP
# =====
def test_ok__keymap() -> None:
assert KEYMAP["KeyA"].mcu.code == 1
def test_fail__keymap() -> None:
with pytest.raises(KeyError):
print(KEYMAP["keya"])

View File

@@ -24,7 +24,7 @@ from typing import Any
import pytest
from kvmd.keyboard.mappings import KEYMAP
from kvmd.keyboard.mappings import WEB_TO_EVDEV
from kvmd.validators import ValidatorError
from kvmd.validators.hid import valid_hid_key
@@ -35,7 +35,7 @@ from kvmd.validators.hid import valid_hid_mouse_delta
# =====
def test_ok__valid_hid_key() -> None:
for key in KEYMAP:
for key in WEB_TO_EVDEV:
print(valid_hid_key(key))
print(valid_hid_key(key + " "))