Skip to content

Commit cf51a0e

Browse files
committed
more robust controller connection handling, just in case
1 parent 6abb648 commit cf51a0e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

arcade/gui/experimental/controller.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from dataclasses import dataclass
23

34
from pyglet.input import Controller
@@ -128,11 +129,19 @@ def __init__(self, ui: UIManager):
128129

129130
def on_connect(self, controller: Controller):
130131
controller.push_handlers(self)
131-
controller.open()
132+
133+
try:
134+
controller.open()
135+
except Exception as e:
136+
warnings.warn(f"Failed to open controller {controller}: {e}")
132137

133138
def on_disconnect(self, controller: Controller):
134139
controller.remove_handlers(self)
135-
controller.close()
140+
141+
try:
142+
controller.close()
143+
except Exception as e:
144+
warnings.warn(f"Failed to close controller {controller}: {e}")
136145

137146
# Controller event mapping
138147
def on_stick_motion(self, controller: Controller, name, value):

0 commit comments

Comments
 (0)