// <summary> /// Gets the XCobraController object bound to the specified hand. /// </summary> public static XCobraController GetController(XCobraHands hand) { for (int i = 0; i < MAX_CONTROLLERS; i++) { if ((m_Controllers[i] != null) && (m_Controllers[i].Hand == hand)) { return(m_Controllers[i]); } } return(null); }
internal void Awake(XHawkInput context) { // m_XHawkInput = context; m_State = XCobraState.NOT_FOUND; // m_Hand = XCobraHands.UNKNOWN; m_HandBind = XCobraHands.UNKNOWN; m_Buttons = 0; m_ButtonsPrevious = 0; /*m_Trigger*/ m_Axes[k_Trigger] = 0.0f; /*m_JoystickX*/ m_Axes[k_JoystickX] = 0.0f; /*m_JoystickY*/ m_Axes[k_JoystickY] = 0.0f; m_Position.Set(0.0f, 0.0f, 0.0f); m_Rotation.Set(0.0f, 0.0f, 0.0f, 1.0f); }
internal void Update(ref LibXHawkAPI.joyinfo joy) { m_State = (XCobraState)joy.found_mask; m_Hand = (XCobraHands)joy.id; m_ButtonsPrevious = m_Buttons; m_Buttons = (XCobraButtons)joy.buttons; /*m_Trigger*/ m_Axes[k_Trigger] = joy.trigger; /*m_JoystickX*/ m_Axes[k_JoystickX] = joy.joystick_x; /*m_JoystickY*/ m_Axes[k_JoystickY] = joy.joystick_y; m_Position.Set(joy.position[0], joy.position[1], joy.position[2]); m_Rotation.Set(joy.rotation[0], joy.rotation[1], joy.rotation[2], joy.rotation[3]); if (/*m_Trigger*/ m_Axes[k_Trigger] > TriggerButtonThreshold) { m_Buttons |= XCobraButtons.Trigger; } // TODO // if (m_XHawkInput == null) { return; } if (/*m_JoystickX*/ m_Axes[k_JoystickX] * /*m_JoystickX*/ m_Axes[k_JoystickX] <= m_XHawkInput.axisDeadzone * m_XHawkInput.axisDeadzone) { /*m_JoystickX*/ m_Axes[k_JoystickX] = 0.0f; } if (/*m_JoystickY*/ m_Axes[k_JoystickY] * /*m_JoystickY*/ m_Axes[k_JoystickY] <= m_XHawkInput.axisDeadzone * m_XHawkInput.axisDeadzone) { /*m_JoystickY*/ m_Axes[k_JoystickY] = 0.0f; } if ((m_State & XCobraState.POSITION_FOUND) == 0 && // Hide? m_XHawkInput.autoHideXCobra) { m_Position.Set(-1024f, -1024f, -1024f); } else { m_Position.Scale(m_XHawkInput.sensitivity); } }