From a204c82577e00e10e0179c5574e316641b0ab36d Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Tue, 14 Nov 2023 19:57:38 +0800 Subject: [PATCH] sync pyglet --- libs/pyglet/input/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/pyglet/input/base.py b/libs/pyglet/input/base.py index c99f00f..4a4277d 100644 --- a/libs/pyglet/input/base.py +++ b/libs/pyglet/input/base.py @@ -4,6 +4,7 @@ """ import sys +import warnings from pyglet.event import EventDispatcher @@ -375,6 +376,9 @@ class Joystick(EventDispatcher): self.button_controls = [] def add_axis(control): + if not (control.min or control.max): + warnings.warn(f"Control('{control.name}') min & max values are both 0. Skipping.") + return name = control.name scale = 2.0 / (control.max - control.min) bias = -1.0 - control.min * scale @@ -610,6 +614,9 @@ class Controller(EventDispatcher): def _initialize_controls(self): def add_axis(control, axis_name): + if not (control.min or control.max): + warnings.warn(f"Control('{control.name}') min & max values are both 0. Skipping.") + return tscale = 1.0 / (control.max - control.min) scale = 2.0 / (control.max - control.min) bias = -1.0 - control.min * scale