sync pyglet add module define

This commit is contained in:
shenjack 2023-06-08 23:01:09 +08:00
parent e38b75a15e
commit 21eab0e582
3 changed files with 20 additions and 13 deletions

View File

@ -98,7 +98,7 @@ class Game(Options):
def init_mods(self) -> None:
"""验证/加载 mod"""
print(self)
self.mod_module = []
mods = []
mod_path = Path(DR_runtime.mod_path)
if not mod_path.exists():

View File

@ -506,6 +506,16 @@ class XInputDeviceManager(EventDispatcher):
if device.xinput_state.dwPacketNumber == device.packet_number:
continue
# Post in main thread to avoid potential GL state issues
pyglet.app.platform_event_loop.post_event(self, '_on_state_change', device)
self._dev_lock.release()
time.sleep(polling_rate)
@staticmethod
def _on_state_change(device):
# Handler to ensure Controller events are dispatched in the main thread.
# The _get_state method dispatches this by posting to the platform event loop.
for button, name in controller_api_to_pyglet.items():
device.controls[name].value = device.xinput_state.Gamepad.wButtons & button
@ -515,12 +525,8 @@ class XInputDeviceManager(EventDispatcher):
device.controls['lefty'].value = device.xinput_state.Gamepad.sThumbLY
device.controls['rightx'].value = device.xinput_state.Gamepad.sThumbRX
device.controls['righty'].value = device.xinput_state.Gamepad.sThumbRY
device.packet_number = device.xinput_state.dwPacketNumber
self._dev_lock.release()
time.sleep(polling_rate)
def on_connect(self, device):
"""A device was connected."""
@ -530,6 +536,7 @@ class XInputDeviceManager(EventDispatcher):
XInputDeviceManager.register_event_type('on_connect')
XInputDeviceManager.register_event_type('on_disconnect')
XInputDeviceManager.register_event_type('_on_state_change')
_device_manager = XInputDeviceManager()

View File

@ -26,7 +26,7 @@ $arg += @("--msvc=latest")
$arg += @("--clang")
$arg += @("--lto=no")
# 包配置
$arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi")
$arg += @("--nofollow-import-to=objprint,pillow,PIL,cffi,pydoc")
$arg += @("--follow-import-to=pyglet")
# 数据配置
$arg += @("--include-data-dir=./libs/fonts=./libs/fonts")