HTML5-JavaScript-Gamepad-Controller-Library icon indicating copy to clipboard operation
HTML5-JavaScript-Gamepad-Controller-Library copied to clipboard

gamepad.bind(Gamepad.Event.BUTTON_UP) not working

Open djneils opened this issue 5 years ago • 3 comments

the BUTTON_DOWN one works but the BUTTON_UP one does nothing

djneils avatar Dec 19 '20 19:12 djneils

2023 The problem is relevant

pryzhanov avatar Jan 09 '23 21:01 pryzhanov

Maybe the problem is here need to fix

updater = function() {
			var value = getter();
			var lastValue = gamepad.lastState[controlName];
			var isDown = value > 0.5;
			var wasDown = lastValue > 0.5;

			gamepad.state[controlName] = value;

			if (isDown && !wasDown) {
				that._fire(Gamepad.Event.BUTTON_DOWN, Object.create(buttonEventData));
			} else if (!isDown && wasDown) {
				that._fire(Gamepad.Event.BUTTON_UP, Object.create(buttonEventData));
			}

			if ((value !== 0) && (value !== 1) && (value !== lastValue)) {
				that._fireAxisChangedEvent(gamepad, controlName, value);
			}

			gamepad.lastState[controlName] = value;
		};

pryzhanov avatar Jan 09 '23 21:01 pryzhanov

Autor please fix that

pryzhanov avatar Jan 10 '23 14:01 pryzhanov