/// <summary> /// Update joysticks with a timer /// </summary> public static void UpdateJoysticks() { #if !UNITY_ANDROID || UNITY_EDITOR return; #else if (m_timerJoysticks < DateTime.Now) { //check for new joysticks every N seconds m_timerJoysticks = DateTime.Now + TimeSpan.FromSeconds(3); string[] joysticks = null; List <string> devices = new List <string>(); for (int deviceId = 0; deviceId < OuyaController.MAX_CONTROLLERS; ++deviceId) { string deviceName = getDeviceName(deviceId); //Debug.Log(string.Format("Device={0} name={1}", deviceId, deviceName)); devices.Add(deviceName); } joysticks = devices.ToArray(); // look for changes bool detectedChange = false; if (null == Joysticks) { detectedChange = true; } else if (joysticks.Length != Joysticks.Length) { detectedChange = true; } else { for (int index = 0; index < joysticks.Length; ++index) { if (joysticks[index] != Joysticks[index]) { detectedChange = true; break; } } } Joysticks = joysticks; if (detectedChange) { foreach (OuyaSDK.IJoystickCalibrationListener listener in OuyaSDK.getJoystickCalibrationListeners()) { //Debug.Log("OuyaGameObject: Invoke OuyaOnJoystickCalibration"); listener.OuyaOnJoystickCalibration(); } } } #endif }
/// <summary> /// Update joysticks with a timer /// </summary> public static void UpdateJoysticks() { #if !UNITY_WP8 if (!m_EnableUnityInput) { return; } if (m_timerJoysticks < DateTime.Now) { //check for new joysticks every N seconds m_timerJoysticks = DateTime.Now + TimeSpan.FromSeconds(3); string[] joysticks = Input.GetJoystickNames(); // look for changes bool detectedChange = false; if (null == Joysticks) { detectedChange = true; } else if (joysticks.Length != Joysticks.Length) { detectedChange = true; } else { for (int index = 0; index < joysticks.Length; ++index) { if (joysticks[index] != Joysticks[index]) { detectedChange = true; break; } } } Joysticks = joysticks; if (detectedChange) { foreach (OuyaSDK.IJoystickCalibrationListener listener in OuyaSDK.getJoystickCalibrationListeners()) { //Debug.Log("OuyaGameObject: Invoke OuyaOnJoystickCalibration"); listener.OuyaOnJoystickCalibration(); } } } #endif }