sync pyglet add module define
This commit is contained in:
parent
e38b75a15e
commit
21eab0e582
@ -98,7 +98,7 @@ class Game(Options):
|
|||||||
|
|
||||||
def init_mods(self) -> None:
|
def init_mods(self) -> None:
|
||||||
"""验证/加载 mod"""
|
"""验证/加载 mod"""
|
||||||
print(self)
|
self.mod_module = []
|
||||||
mods = []
|
mods = []
|
||||||
mod_path = Path(DR_runtime.mod_path)
|
mod_path = Path(DR_runtime.mod_path)
|
||||||
if not mod_path.exists():
|
if not mod_path.exists():
|
||||||
|
@ -506,21 +506,27 @@ class XInputDeviceManager(EventDispatcher):
|
|||||||
if device.xinput_state.dwPacketNumber == device.packet_number:
|
if device.xinput_state.dwPacketNumber == device.packet_number:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for button, name in controller_api_to_pyglet.items():
|
# Post in main thread to avoid potential GL state issues
|
||||||
device.controls[name].value = device.xinput_state.Gamepad.wButtons & button
|
pyglet.app.platform_event_loop.post_event(self, '_on_state_change', device)
|
||||||
|
|
||||||
device.controls['lefttrigger'].value = device.xinput_state.Gamepad.bLeftTrigger
|
|
||||||
device.controls['righttrigger'].value = device.xinput_state.Gamepad.bRightTrigger
|
|
||||||
device.controls['leftx'].value = device.xinput_state.Gamepad.sThumbLX
|
|
||||||
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()
|
self._dev_lock.release()
|
||||||
time.sleep(polling_rate)
|
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
|
||||||
|
|
||||||
|
device.controls['lefttrigger'].value = device.xinput_state.Gamepad.bLeftTrigger
|
||||||
|
device.controls['righttrigger'].value = device.xinput_state.Gamepad.bRightTrigger
|
||||||
|
device.controls['leftx'].value = device.xinput_state.Gamepad.sThumbLX
|
||||||
|
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
|
||||||
|
|
||||||
def on_connect(self, device):
|
def on_connect(self, device):
|
||||||
"""A device was connected."""
|
"""A device was connected."""
|
||||||
|
|
||||||
@ -530,6 +536,7 @@ class XInputDeviceManager(EventDispatcher):
|
|||||||
|
|
||||||
XInputDeviceManager.register_event_type('on_connect')
|
XInputDeviceManager.register_event_type('on_connect')
|
||||||
XInputDeviceManager.register_event_type('on_disconnect')
|
XInputDeviceManager.register_event_type('on_disconnect')
|
||||||
|
XInputDeviceManager.register_event_type('_on_state_change')
|
||||||
|
|
||||||
|
|
||||||
_device_manager = XInputDeviceManager()
|
_device_manager = XInputDeviceManager()
|
||||||
|
@ -26,7 +26,7 @@ $arg += @("--msvc=latest")
|
|||||||
$arg += @("--clang")
|
$arg += @("--clang")
|
||||||
$arg += @("--lto=no")
|
$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 += @("--follow-import-to=pyglet")
|
||||||
# 数据配置
|
# 数据配置
|
||||||
$arg += @("--include-data-dir=./libs/fonts=./libs/fonts")
|
$arg += @("--include-data-dir=./libs/fonts=./libs/fonts")
|
||||||
|
Loading…
Reference in New Issue
Block a user