void _SignalThumbState(float oldState, float newState, float threshold, bool wasConnected, bool isConnected, GamePadObjects thumb, GamePadObjects negButton, GamePadObjects posButton) { if (!wasConnected) oldState = 0; if (!isConnected) newState = 0; bool posWasDown = oldState > threshold; bool posIsDown = newState > threshold; bool negWasDown = oldState < -threshold; bool negIsDown = newState < -threshold; if (oldState != newState) { TorqueInputDevice.InputEventData data = _getEventData((int)thumb); // data fill in data.Value = newState; data.EventAction = Action.Move; TorqueEventManager.PostEvent(GamepadEvent, data); } // Positive axis direction button if (posWasDown != posIsDown) { TorqueInputDevice.InputEventData data = _getEventData((int)posButton); // data fill in data.Value = posIsDown ? 1.0f : 0.0f; data.EventAction = posIsDown ? Action.Make : Action.Break; TorqueEventManager.PostEvent(GamepadEvent, data); } // Negative axis direction button if (negWasDown != negIsDown) { TorqueInputDevice.InputEventData data = _getEventData((int)negButton); // data fill in data.Value = negIsDown ? 1.0f : 0.0f; data.EventAction = negIsDown ? Action.Make : Action.Break; TorqueEventManager.PostEvent(GamepadEvent, data); } }
void _SignalTriggerState(float oldState, float newState, float threshold, bool wasConnected, bool isConnected, GamePadObjects trigger, GamePadObjects button) { if (!wasConnected) oldState = 0; if (!isConnected) newState = 0; bool wasDown = oldState > threshold; bool isDown = newState > threshold; if (oldState != newState) { TorqueInputDevice.InputEventData data = _getEventData((int)trigger); // data fill in data.Value = newState; data.EventAction = Action.Move; TorqueEventManager.PostEvent(GamepadEvent, data); } if (wasDown != isDown) { TorqueInputDevice.InputEventData data = _getEventData((int)button); // data fill in data.Value = isDown ? 1.0f : 0.0f; data.EventAction = isDown ? Action.Make : Action.Break; TorqueEventManager.PostEvent(GamepadEvent, data); } }
void _SignalButtonState(bool wasDown, bool isDown, bool wasConnected, bool isConnected, GamePadObjects button) { // treat dis-connected as up (and assume ill-defined coming in) if (!isConnected) isDown = false; if (!wasConnected) wasDown = false; if (isDown != wasDown) { TorqueInputDevice.InputEventData data = _getEventData((int)button); // data fill in data.Value = isDown ? 1.0f : 0.0f; data.EventAction = isDown ? Action.Make : Action.Break; TorqueEventManager.PostEvent(GamepadEvent, data); } }