private void connectBtn_Click(object sender, RoutedEventArgs e) { bool result = false; if (Ninty != null) { result = Ninty.Connect(); var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DevicePath); if (prefs != null && !string.IsNullOrEmpty(prefs.defaultProfile)) { Ninty.LoadProfile(prefs.defaultProfile); } } else if (Joy != null) { result = Joy.Connect(); var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DeviceID); if (prefs != null && !string.IsNullOrEmpty(prefs.defaultProfile)) { Joy.LoadProfile(prefs.defaultProfile); } } if (result) { connectBtn.IsEnabled = false; status.Content = "Connected"; } ConnectClick?.Invoke(this, result); }
public void UpdateType(ControllerType type) { // TODO: Default to unknown icon string img = "ProController_black_24.png"; string deviceName = ""; switch (type) { case ControllerType.ProController: img = "ProController_black_24.png"; deviceName = "Pro Controller"; break; case ControllerType.Wiimote: img = "wiimote_black_24.png"; deviceName = "Wiimote"; extIndex = 0; break; case ControllerType.Nunchuk: case ControllerType.NunchukB: img = "Wiimote+Nunchuck_black_24.png"; deviceName = "Nunchuk"; extIndex = 1; break; case ControllerType.ClassicController: img = "Classic_black_24.png"; deviceName = "Classic Controller"; extIndex = 2; break; case ControllerType.ClassicControllerPro: img = "ClassicPro_black_24.png"; deviceName = "Classic Controller Pro"; extIndex = 3; break; case ControllerType.Guitar: extIndex = 4; break; case ControllerType.TaikoDrum: extIndex = 5; break; case ControllerType.Other: // TODO deviceName = "GCN Adapter"; break; } var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DevicePath); if (prefs != null) { if (!string.IsNullOrWhiteSpace(prefs.nickname)) { deviceName = prefs.nickname; } prefs.icon = img; AppPrefs.Instance.SaveDevicePrefs(prefs); if (extIndex != -1 && !string.IsNullOrEmpty(prefs.extensionProfiles[extIndex])) { Ninty.LoadProfile(prefs.extensionProfiles[extIndex]); } else if (!string.IsNullOrEmpty(prefs.defaultProfile)) { Ninty.LoadProfile(prefs.defaultProfile); } } icon.Source = new BitmapImage(new Uri("../Images/Icons/" + img, UriKind.Relative)); #if DEBUG if (Info.DevicePath != null && Info.DevicePath.StartsWith("Dummy")) { nickname.Content = Info.DevicePath; } else #endif nickname.Content = deviceName; }