diff --git a/configs/local_logger.toml b/configs/local_logger.toml index 52dc0e6..75bd786 100644 --- a/configs/local_logger.toml +++ b/configs/local_logger.toml @@ -1,4 +1,4 @@ -version = 1.0 +logger_version = '1.0.0' [Loggers] @@ -58,3 +58,11 @@ long_time = '%Y-%m-%d %H-%M-%S:%%S' message = '\u001b[0m' logger = '\u001b[0m' marker = '\u001b[0m' + TRACE.info = '\u001b[38;2;138;173;244m' + FINE.info = '\u001b[35;48;2;44;44;54m' + DEBUG.info = '\u001b[38;2;133;138;149m' + INFO.info = '\u001b[0m' + WARNING.info = '\u001b[33m' + ERROR.info = '\u001b[31m' + FATAL.info = '\u001b[38;2;255;255;0;48;2;120;10;10m' + FATAL.logger = '\u001b[38;2;245;189;230m' diff --git a/libs/pyglet/gui/widgets.py b/libs/pyglet/gui/widgets.py index daaddfa..392f4f8 100644 --- a/libs/pyglet/gui/widgets.py +++ b/libs/pyglet/gui/widgets.py @@ -327,6 +327,10 @@ class Slider(WidgetBase): self._value = 0 self._in_update = False + def _update_position(self): + self._base_spr.position = self._x, self._y, 0 + self._knob_spr.position = self._x + self._edge, self._y + self._base_img.height / 2, 0 + @property def value(self): return self._value @@ -477,8 +481,6 @@ class TextEntry(WidgetBase): def on_mouse_motion(self, x, y, dx, dy): if not self.enabled: return - if not self._check_hit(x, y): - self._set_focus(False) def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): if not self.enabled: @@ -497,6 +499,7 @@ class TextEntry(WidgetBase): if not self.enabled: return if self._focus: + # Commit on Enter/Return: if text in ('\r', '\n'): self.dispatch_event('on_commit', self._layout.document.text) self._set_focus(False) diff --git a/libs/pyglet/input/darwin_hid.py b/libs/pyglet/input/darwin_hid.py index 2e33d38..cbaf63e 100644 --- a/libs/pyglet/input/darwin_hid.py +++ b/libs/pyglet/input/darwin_hid.py @@ -313,6 +313,31 @@ class HIDDevice: return (self.manufacturer, self.product, self.vendorID, self.productID, self.versionNumber, self.primaryUsage, self.primaryUsagePage) + def get_guid(self): + """Generate an SDL2 style GUID from the product guid.""" + + if self.transport == 'USB': + bustype = 0x03 + vendor = self.vendorID or 0 + product = self.productID or 0 + version = self.versionNumber or 0 + # Byte swap (ABCD --> CDAB): + bustype = ((bustype << 8) | (bustype >> 8)) & 0xFFFF + vendor = ((vendor << 8) | (vendor >> 8)) & 0xFFFF + product = ((product << 8) | (product >> 8)) & 0xFFFF + version = ((version << 8) | (version >> 8)) & 0xFFFF + return "{:04x}0000{:04x}0000{:04x}0000{:04x}0000".format(bustype, vendor, product, version) + + elif self.transport == 'BLUETOOTH': + bustype = 0x05 + # Byte swap (ABCD --> CDAB): + bustype = ((bustype << 8) | (bustype >> 8)) & 0xFFFF + + # TODO: test fallback to vendor id if no product name: + name = self.product or str(self.vendorID) + name = name.encode().hex() + return "{:04x}0000{:0<24}".format(bustype, name) + def get_property(self, name): cfname = CFSTR(name) cfvalue = c_void_p(iokit.IOHIDDeviceGetProperty(self.deviceRef, cfname)) @@ -598,27 +623,7 @@ class PygletDevice(Device): return list(self._controls.values()) def get_guid(self): - """Generate an SDL2 style GUID from the product guid.""" - - if self.device.transport == 'USB': - bustype = 0x03 - vendor, product, version = self.device_identifier[2:5] - # Byte swap (ABCD --> CDAB): - bustype = ((bustype << 8) | (bustype >> 8)) & 0xFFFF - vendor = ((vendor << 8) | (vendor >> 8)) & 0xFFFF - product = ((product << 8) | (product >> 8)) & 0xFFFF - version = ((version << 8) | (version >> 8)) & 0xFFFF - return "{:04x}0000{:04x}0000{:04x}0000{:04x}0000".format(bustype, vendor, product, version) - - elif self.device.transport == 'BLUETOOTH': - bustype = 0x05 - # Byte swap (ABCD --> CDAB): - bustype = ((bustype << 8) | (bustype >> 8)) & 0xFFFF - - # TODO: test fallback to vendor id if no product name: - name = self.device.product or str(self.device.vendorID) - name = name.encode().hex() - return "{:04x}0000{:0<24}".format(bustype, name) + return self.device.get_guid() def device_removed(self, hid_device): # Called by device when it is unplugged. @@ -721,10 +726,11 @@ def get_apple_remote(display=None): def _create_controller(device, display): - mapping = get_mapping(device.get_guid()) - if not mapping: - return - return Controller(PygletDevice(display, device, _hid_manager), mapping) + if device.transport in ('USB', 'BLUETOOTH'): + mapping = get_mapping(device.get_guid()) + if not mapping: + return + return Controller(PygletDevice(display, device, _hid_manager), mapping) def get_controllers(display=None): diff --git a/libs/utils/logger.py b/libs/utils/logger.py index 60b4dd8..e95dd73 100644 --- a/libs/utils/logger.py +++ b/libs/utils/logger.py @@ -24,6 +24,8 @@ from collections import namedtuple from logging import NOTSET, DEBUG from typing import NamedTuple, Optional, Type, Union, Dict, Iterable, Any, List +Version = '1.0.0' + os.system('') # print(os.path.abspath(os.curdir)) # TODO 这个文件就是个大TODO @@ -47,7 +49,7 @@ color_reset_suffix = "\033[0m" re_find_color_code = r'\033\[[^\f\n\r\t\vm]*m' re_color_code = re.compile(re_find_color_code) -re_find_level_code = r'[INFO]||' +re_find_level_code = r'' """ OFF > FATAL > ERROR > WARN > INFO > FINE > FINER > DEBUG > TRACE > ALL diff --git a/libs/utils/parse_toml.py b/libs/utils/parse_toml.py index e855947..f65e43a 100644 --- a/libs/utils/parse_toml.py +++ b/libs/utils/parse_toml.py @@ -2,11 +2,13 @@ import json import pprint import sys -import tomlkit +import rtoml as toml with open(sys.argv[1], encoding='utf-8', mode='r') as f: if sys.argv[2] == 'parse': - a = tomlkit.load(f) + a = toml.load(f) + b = json.dumps(a) + print(b) else: a = json.load(f) print(a)