Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ElluIFX committed Jun 7, 2024
1 parent 583bba2 commit 28e42c0
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions Client/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import datetime
import os
import random
import re
import sys
import tempfile
import time
from typing import List, Tuple, Union
from typing import Tuple

import hid_def
import pythoncom
import pyWinhook as pyHook
import server_simple
import yaml # type: ignore
import yaml
from default import default_config
from loguru import logger
from PySide6 import *
Expand Down Expand Up @@ -58,7 +57,7 @@
config = yaml.safe_load(load_f)["config"]
dark_theme = config["dark_theme"]
translation = config["translation"]
except Exception as e:
except Exception:
pass


Expand Down Expand Up @@ -845,7 +844,7 @@ def device_config(self):
self.video_config["resolution_Y"] = (
self.device_setup_dialog.comboBox_2.currentText().split("x")[1]
)
except:
except IndexError:
self.video_config["resolution_X"] = 0
self.video_config["resolution_Y"] = 0
self.video_config["format"] = (
Expand Down Expand Up @@ -887,7 +886,7 @@ def device_config(self):
self.audio_config["audio_device_out"] = (
self.device_setup_dialog.comboBox_5.currentText()
)
except:
except Exception:
self.video_alert(self.tr("Selected invalid device"))
return
logger.debug(self.video_config)
Expand Down Expand Up @@ -1416,8 +1415,8 @@ def shortcut_key_handle(self, s):
keysequence = keysequence_list[-1]
try:
mapcode = self.keyboard_code[keysequence.upper()]
except Exception as e:
logger.error(f"Hid query error")
except Exception:
logger.error("Hid query error")
return
self.shortcut_buffer[4] = int(mapcode, 16) # 功能位

Expand Down Expand Up @@ -1469,7 +1468,7 @@ def shortcut_key_handle(self, s):
def shortcut_key_action(self, s):
try:
get = self.configfile["shortcut_key"]["shortcut_key_hidcode"][s]
except Exception as e:
except Exception:
return
self._hid_signal.emit(get)
self.qt_sleep(10)
Expand Down Expand Up @@ -2179,14 +2178,14 @@ def mouseMoveEvent(self, event):
y_res = self.disconnect_label.height()
width = self.disconnect_label.width()
height = self.disconnect_label.height()
x_pos = self.disconnect_label.pos().x()
# x_pos = self.disconnect_label.pos().x()
y_pos = self.disconnect_label.pos().y()
else:
x_res = self.video_config["resolution_X"]
y_res = self.video_config["resolution_Y"]
width = self.videoWidget.width()
height = self.videoWidget.height()
x_pos = self.videoWidget.pos().x()
# x_pos = self.videoWidget.pos().x()
y_pos = self.videoWidget.pos().y()
x_diff = 0
y_diff = 0
Expand Down Expand Up @@ -2344,26 +2343,6 @@ def update_kb_hid(self, hid: int, state: bool):
self._hid_signal.emit(kb_buffer)
return 0

def update_kb_hid(self, hid: int, state: bool):
if state:
for i in range(4, 10):
if kb_buffer[i] == hid:
return
if kb_buffer[i] == 0:
kb_buffer[i] = hid
break
else:
logger.error("Buffer overflow")
else:
for i in range(4, 10):
if kb_buffer[i] == hid:
kb_buffer[i] = 0
break
else:
logger.error("Key not found in buffer")
self._hid_signal.emit(kb_buffer)
return 0

# 键盘按下事件
def keyPressEvent(self, event):
if self.ignore_event:
Expand Down Expand Up @@ -2413,7 +2392,8 @@ def keyRelease(self, scancode: int):
self.shortcut_status(kb_buffer)

def closeEvent(self, event):
os._exit(0)
# os._exit(0)
pass

@Slot()
def on_btnServerSwitch_clicked(self):
Expand Down Expand Up @@ -2762,7 +2742,7 @@ def main():
myWin.show()
QTimer.singleShot(100, myWin.shortcut_status)
clear_splash()
sys.exit(app.exec())
return app.exec()


if __name__ == "__main__":
Expand Down

0 comments on commit 28e42c0

Please sign in to comment.