mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 02:21:53 +08:00
Compatibility with old vanilla kernels (#88)
This commit is contained in:
@@ -78,8 +78,11 @@ def _unlink(path: str, optional: bool=False) -> None:
|
|||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
|
|
||||||
def _write(path: str, value: Union[str, int]) -> None:
|
def _write(path: str, value: Union[str, int], optional: bool=False) -> None:
|
||||||
get_logger().info("WRITE --- %s", path)
|
get_logger().info("WRITE --- %s", path)
|
||||||
|
if optional and not os.access(path, os.F_OK):
|
||||||
|
get_logger().info("SKIP ---- %s", path)
|
||||||
|
return
|
||||||
with open(path, "w") as param_file:
|
with open(path, "w") as param_file:
|
||||||
param_file.write(str(value))
|
param_file.write(str(value))
|
||||||
|
|
||||||
@@ -158,9 +161,9 @@ class _GadgetConfig:
|
|||||||
func = f"hid.usb{self.__hid_instance}"
|
func = f"hid.usb{self.__hid_instance}"
|
||||||
func_path = join(self.__gadget_path, "functions", func)
|
func_path = join(self.__gadget_path, "functions", func)
|
||||||
_mkdir(func_path)
|
_mkdir(func_path)
|
||||||
_write(join(func_path, "no_out_endpoint"), "1")
|
_write(join(func_path, "no_out_endpoint"), "1", optional=True)
|
||||||
if remote_wakeup:
|
if remote_wakeup:
|
||||||
_write(join(func_path, "wakeup_on_write"), "1")
|
_write(join(func_path, "wakeup_on_write"), "1", optional=True)
|
||||||
_write(join(func_path, "protocol"), hid.protocol)
|
_write(join(func_path, "protocol"), hid.protocol)
|
||||||
_write(join(func_path, "subclass"), hid.subclass)
|
_write(join(func_path, "subclass"), hid.subclass)
|
||||||
_write(join(func_path, "report_length"), hid.report_length)
|
_write(join(func_path, "report_length"), hid.report_length)
|
||||||
|
|||||||
Reference in New Issue
Block a user