private void getNeutralPosition() { for (int i = 0; i < MainWindow.deviceControl.joyAssign.Length; i++) { neutralButtons[i] = new NeutralButtons(MainWindow.deviceControl.joyAssign[i]); } }
private void getNeutralPosition() { for (int i = 0; i < deviceControl.devList.Count; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]); } }
public void ReloadDevices() { try { // Get Devices deviceControl = new DeviceControl(appReg); deviceControl.SortDevice(); neutralButtons = new NeutralButtons[deviceControl.joyAssign.Length]; // Aquire joySticks AquireAll(true); ResortDevices(); } catch (Exception ex) { Diagnostics.WriteLogFile(ex); Close(); } }
/// <summary> /// You pressed a joystick button to search which callback is it assigned to? OK let's go there. /// </summary> public void JumptoAssignedKey() { string target = ""; switch (statusAssign) { case Status.GetNeutralPos: for (int i = 0; i < deviceControl.devList.Count; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]); } statusAssign = Status.WaitingforInput; break; case Status.WaitingforInput: for (int i = 0; i < deviceControl.devList.Count; i++) { buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons(); for (int ii = 0; ii < 32; ii++) { if (buttons[ii] == neutralButtons[i].buttons[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (buttons[ii] == 0) // RELEASE SHIFT { continue; } Pinky pinkyStatus = Pinky.UnShift; Behaviour behaviourStatus = Behaviour.Press; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } if (Select_DX_Release.IsChecked == false) { behaviourStatus = Behaviour.Release; } target = deviceControl.joyAssign[i].dx[ii].assign[(int)pinkyStatus + (int)behaviourStatus].GetCallback(); Label_AssgnStatus.Content = "DX" + (ii + 1) + "\t: " + deviceControl.joyAssign[i].GetProductName(); } povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView(); for (int ii = 0; ii < 4; ii++) { if (povs[ii] == neutralButtons[i].povs[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (povs[ii] == -1) { continue; } Pinky pinkyStatus = Pinky.UnShift; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } target = deviceControl.joyAssign[i].pov[ii].direction[povs[ii] / 4500].GetCallback(pinkyStatus); string direction = deviceControl.joyAssign[i].pov[ii].GetDirection(povs[ii]); Label_AssgnStatus.Content = "POV" + (ii + 1) + "." + direction + "\t: " + deviceControl.joyAssign[i].GetProductName(); } } break; } if (target == "") { return; } if (target == "SimDoNothing") { return; } // If the key assignment was found, jump to the mapping for it and highlight it. var key = keyFile.keyAssign.FirstOrDefault(x => x.GetCallback() == target); if (key != null) { Label_AssgnStatus.Content += " / " + key.Mapping; KeyMappingGrid.ScrollIntoView(key); KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key); } }
/// <summary> /// Check your keyboard/joysticks button behaviour every 60 frames per seconds. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void KeyMappingTimer_Tick(object sender, EventArgs e) { try { directInputDevice.GetCurrentKeyboardState(); for (int i = 1; i < 238; i++) { if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i]) { KeyMappingGrid_KeyDown(); } } int Rows = KeyMappingGrid.SelectedIndex; var selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem; if (Rows == -1 || statusSearch == Search.Search) { JumptoAssignedKey(); return; } if (KeyMappingGrid.CurrentColumn == null) { return; } if (selectedItem.GetVisibility() != "White") { return; } switch (statusAssign) { case Status.GetNeutralPos: for (int i = 0; i < deviceControl.devList.Count; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]); } statusAssign = Status.WaitingforInput; break; case Status.WaitingforInput: for (int i = 0; i < deviceControl.devList.Count; i++) { buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons(); for (int ii = 0; ii < 32; ii++) { if (buttons[ii] == neutralButtons[i].buttons[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (buttons[ii] == 0) { continue; } Pinky pinkyStatus = Pinky.UnShift; Behaviour behaviourStatus = Behaviour.Press; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } if (Select_DX_Release.IsChecked == false) { behaviourStatus = Behaviour.Release; } // Construct DX button instance. if (selectedItem.GetCallback() == "SimHotasPinkyShift") { deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), Pinky.UnShift, Behaviour.Press, Invoke.Default, 0); deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), Pinky.Shift, Behaviour.Press, Invoke.Default, 0); } else { deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), pinkyStatus, behaviourStatus, invokeStatus, 0); } KeyMappingGrid.Items.Refresh(); KeyMappingGrid.UnselectAllCells(); } povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView(); for (int ii = 0; ii < 4; ii++) { if (povs[ii] == neutralButtons[i].povs[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (povs[ii] == -1) { continue; } Pinky pinkyStatus = Pinky.UnShift; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } // Construct POV button instance. deviceControl.joyAssign[i].pov[ii].Assign(povs[ii], selectedItem.GetCallback(), pinkyStatus, 0); KeyMappingGrid.Items.Refresh(); KeyMappingGrid.UnselectAllCells(); } } break; } } catch (System.IO.FileNotFoundException ex) { System.Console.WriteLine(ex.Message); System.IO.StreamWriter sw = new System.IO.StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); MessageBox.Show("Error Log Saved To " + appReg.GetInstallDir() + "\\Error.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } }
/// <summary> /// Execute when launching this app. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { try { // load command line. string[] args = Environment.GetCommandLineArgs(); if (args.Length % 2 == 1) { Dictionary <string, string> option = new Dictionary <string, string>(); for (int index = 1; index < args.Length; index += 2) { option.Add(args[index], args[index + 1]); } if (option.ContainsKey("/yame")) { if (option["/yame"] == "true") { FLG_YAME64 = true; } } if (FLG_YAME64) { LargeTab.SelectedIndex = 1; Tab_Launcher.Visibility = Visibility.Collapsed; Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox1.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox2.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox3.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox4.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundImage.Opacity = 0; Button_Apply_YAME64.Visibility = Visibility.Visible; } else { Button_Apply_YAME64.Visibility = Visibility.Hidden; } } } catch (FileNotFoundException ex) { Console.WriteLine(ex.Message); StreamWriter sw = new StreamWriter("C:\\FBMSAltLauncherErrorLog.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); MessageBox.Show("Error Log Saved To C:\\FBMSAltLauncherErrorLog.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } // Load UI Properties(Like Button Status). appProperties = new AppProperties(this); // Read Registry appReg = new AppRegInfo(this); if (appReg.getBMSVersion() == BMS_Version.UNDEFINED) { Close(); return; } try { // Read Theater List TheaterList.Populate(appReg, Dropdown_TheaterList); // Get Devices deviceControl = new DeviceControl(appReg); neutralButtons = new NeutralButtons[deviceControl.devList.Count]; // Aquire joySticks AquireAll(true); // Reset All Axis Settings foreach (AxisName nme in axisNameList) { inGameAxis[nme.ToString()] = new InGameAxAssgn(); } joyAssign_2_inGameAxis(); ResetAssgnWindow(); // Read BMS-FULL.key string fname = appReg.GetInstallDir() + "\\User\\Config\\" + appReg.getKeyFileName(); keyFile = new KeyFile(fname, appReg); // Write Data Grid WriteDataGrid(); // Set Timer AxisMovingTimer.Tick += AxisMovingTimer_Tick; AxisMovingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); KeyMappingTimer.Tick += KeyMappingTimer_Tick; KeyMappingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); //System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical; } catch (FileNotFoundException ex) { Console.WriteLine(ex.Message); StreamWriter sw = new StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); MessageBox.Show("Error Log Saved To " + appReg.GetInstallDir() + "\\Error.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } }
/// <summary> /// You pressed a joystick button to search which callback is it assigned to? OK let's go there. /// </summary> public void JumptoAssignedKey() { string target = ""; switch (statusAssign) { case Status.GetNeutralPos: for (int i = 0; i < deviceControl.devList.Count; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]); } statusAssign = Status.WaitingforInput; break; case Status.WaitingforInput: for (int i = 0; i < deviceControl.devList.Count; i++) { buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons(); //Microsoft.DirectX.DirectInput.InputLostException: 'アプリケーションでエラーが発生しました。' for (int ii = 0; ii < 32; ii++) { if (buttons[ii] == neutralButtons[i].buttons[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (buttons[ii] == 0) // RELEASE SHIFT { continue; } Pinky pinkyStatus = Pinky.UnShift; Behaviour behaviourStatus = Behaviour.Press; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } if (Select_DX_Release.IsChecked == false) { behaviourStatus = Behaviour.Release; } target = deviceControl.joyAssign[i].dx[ii].assign[(int)pinkyStatus + (int)behaviourStatus].GetCallback(); Label_AssgnStatus.Content = "DX" + (ii + 1) + "\t: " + deviceControl.joyAssign[i].GetProductName(); } povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView(); for (int ii = 0; ii < 4; ii++) { if (povs[ii] == neutralButtons[i].povs[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (povs[ii] == -1) { continue; } Pinky pinkyStatus = Pinky.UnShift; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } target = deviceControl.joyAssign[i].pov[ii].direction[povs[ii] / 4500].GetCallback(pinkyStatus); string direction = deviceControl.joyAssign[i].pov[ii].GetDirection(povs[ii]); Label_AssgnStatus.Content = "POV" + (ii + 1) + "." + direction + "\t: " + deviceControl.joyAssign[i].GetProductName(); } } break; } if (target == "") { return; } if (target == "SimDoNothing") { return; } for (int i = 0; i < keyFile.keyAssign.Length; i++) { if (keyFile.keyAssign[i].GetCallback() == target) { Label_AssgnStatus.Content += " / " + keyFile.keyAssign[i].Mapping; KeyMappingGrid.UpdateLayout(); KeyMappingGrid.ScrollIntoView(KeyMappingGrid.Items[i]); KeyMappingGrid.SelectedIndex = i; statusSearch = Search.Search; } } }
/// <summary> /// Check your keyboard/joysticks button behaviour every 60 frames per seconds. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void KeyMappingTimer_Tick(object sender, EventArgs e) { directInputDevice.GetCurrentKeyboardState(); for (int i = 1; i < 238; i++) { if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i]) { KeyMappingGrid_KeyDown(); } } int Rows = KeyMappingGrid.SelectedIndex; if (Rows == -1 | statusSearch == Search.Search) { JumptoAssignedKey(); return; } if (KeyMappingGrid.CurrentColumn == null) { return; } if (keyFile.keyAssign[Rows].GetVisibility() != "White") { return; } switch (statusAssign) { case Status.GetNeutralPos: for (int i = 0; i < deviceControl.devList.Count; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]); } statusAssign = Status.WaitingforInput; break; case Status.WaitingforInput: for (int i = 0; i < deviceControl.devList.Count; i++) { buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons(); for (int ii = 0; ii < 32; ii++) { if (buttons[ii] == neutralButtons[i].buttons[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (buttons[ii] == 0) { continue; } Pinky pinkyStatus = Pinky.UnShift; Behaviour behaviourStatus = Behaviour.Press; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } if (Select_DX_Release.IsChecked == false) { behaviourStatus = Behaviour.Release; } // Construct DX button instance. deviceControl.joyAssign[i].dx[ii].Assign(keyFile.keyAssign[Rows].GetCallback(), pinkyStatus, behaviourStatus, invokeStatus, 0); KeyMappingGrid.Items.Refresh(); KeyMappingGrid.UnselectAllCells(); } povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView(); for (int ii = 0; ii < 4; ii++) { if (povs[ii] == neutralButtons[i].povs[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (povs[ii] == -1) { continue; } Pinky pinkyStatus = Pinky.UnShift; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } // Construct POV button instance. deviceControl.joyAssign[i].pov[ii].Assign(povs[ii], keyFile.keyAssign[Rows].GetCallback(), pinkyStatus, 0); KeyMappingGrid.Items.Refresh(); KeyMappingGrid.UnselectAllCells(); } } break; } }
/// <summary> /// Execute when launching this app. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { try { // Load UI Properties(Like Button Status). this.appProperties = new AppProperties(this); // Read Registry appReg = new AppRegInfo(this); // Read Theater List TheaterList theaterlist = new TheaterList(appReg, this.Dropdown_TheaterList); // Get Devices deviceControl = new DeviceControl(appReg); neutralButtons = new NeutralButtons[deviceControl.devList.Count]; // Aquire joySticks AquireAll(true); // Reset All Axis Settings foreach (AxisName nme in axisNameList) { inGameAxis[nme.ToString()] = new InGameAxAssgn(); } joyAssign_2_inGameAxis(); ResetAssgnWindow(); // Read BMS-FULL.key string fname = appReg.GetInstallDir() + "\\User\\Config\\BMS - Full.key"; keyFile = new KeyFile(fname, appReg); // Write Data Grid WriteDataGrid(); // Set Timer AxisMovingTimer.Tick += AxisMovingTimer_Tick; AxisMovingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); KeyMappingTimer.Tick += KeyMappingTimer_Tick; KeyMappingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); // Set VisualAcuity page graph and results. this.visualAcuity = new VisualAcuity(this); //System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical; } catch (System.IO.FileNotFoundException ex) { System.Console.WriteLine(ex.Message); System.IO.StreamWriter sw = new System.IO.StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); this.Close(); } // YAME 64 VERSION if (FLG_YAME64 == true) { LargeTab.SelectedIndex = 1; Tab_Launcher.Visibility = Visibility.Collapsed; Tab_VisualAcuity.Visibility = Visibility.Collapsed; Misc_SmartScalingOverride.IsChecked = false; this.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox1.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox2.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundImage.Opacity = 0; } else { Button_Apply_YAME64.Visibility = Visibility.Hidden; } }
/// <summary> /// You pressed a joystick button to search which callback is it assigned to? OK let's go there. /// </summary> public void JumptoAssignedKey() { string target = ""; switch (statusAssign) { case Status.GetNeutralPos: for (int i = 0; i < deviceControl.joyAssign.Length; i++) { neutralButtons[i] = new NeutralButtons(deviceControl.joyAssign[i]); } statusAssign = Status.WaitingforInput; break; case Status.WaitingforInput: for (int i = 0; i < deviceControl.joyAssign.Length; i++) { buttons = deviceControl.joyAssign[i].GetButtons(); for (int ii = 0; ii < CommonConstants.DX128; ii++) { if (buttons[ii] == CommonConstants.PRS128 && deviceControl.joyAssign[i].dx[ii].assign[CommonConstants.DX_PRESS].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false) { Select_PinkyShift.IsChecked = false; } if (buttons[ii] == CommonConstants.PRS0 && deviceControl.joyAssign[i].dx[ii].assign[CommonConstants.DX_PRESS].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false) { Select_PinkyShift.IsChecked = true; } if (neutralButtons[i] == null) { break; // KEY SEARCH WILL NOT WORK IF ENTER HERE } if (buttons[ii] == neutralButtons[i].buttons[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (buttons[ii] == CommonConstants.PRS0) // RELEASE SHIFT { Select_DX_Release.IsChecked = false; } else { Select_DX_Release.IsChecked = true; } if (deviceControl.joyAssign[i].dx[ii].assign[CommonConstants.DX_PRESS].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false) { continue; } Pinky pinkyStatus = Pinky.UnShift; Behaviour behaviourStatus = Behaviour.Press; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } if (Select_DX_Release.IsChecked == false) { behaviourStatus = Behaviour.Release; } target = deviceControl.joyAssign[i].dx[ii].assign[(int)pinkyStatus + (int)behaviourStatus].GetCallback(); if (target == "SimDoNothing" && behaviourStatus == Behaviour.Release) { } else { Label_AssgnStatus.Content = "DX" + (ii + 1) + "\t: " + deviceControl.joyAssign[i].GetProductName(); } } povs = deviceControl.joyAssign[i].GetPointOfView(); for (int ii = 0; ii < 4; ii++) { if (neutralButtons[i] == null) { break; // KEY SEARCH WILL NOT WORK IF ENTER HERE } if (povs[ii] == neutralButtons[i].povs[ii]) { continue; } statusAssign = Status.GetNeutralPos; if (povs[ii] == -1) { continue; } Pinky pinkyStatus = Pinky.UnShift; if (Select_PinkyShift.IsChecked == false) { pinkyStatus = Pinky.Shift; } target = deviceControl.joyAssign[i].pov[ii].direction[povs[ii] / CommonConstants.POV45].GetCallback(pinkyStatus); string direction = deviceControl.joyAssign[i].pov[ii].GetDirection(povs[ii]); Label_AssgnStatus.Content = "POV" + (ii + 1) + "." + direction + "\t: " + deviceControl.joyAssign[i].GetProductName(); } } break; } if (target == "") { return; } if (target == "SimDoNothing") { return; } // If the key assignment was found, jump to the mapping for it and highlight it. KeyAssgn key = keyFile.keyAssign.FirstOrDefault(x => x.GetCallback() == target); if (key != null) { Label_AssgnStatus.Content += " / " + key.Mapping; KeyMappingGrid.ScrollIntoView(key); KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key); } }