private void AddInputDevice(GenericInput input) { Type typeToSearchFor; if (input.GetType() == typeof(KeyboardInput)) { typeToSearchFor = typeof(JoystickInput); } else if (input.GetType() == typeof(JoystickInput)) { typeToSearchFor = typeof(WiimoteInput); } else { Console.WriteLine("Added " + input.DeviceName + " at last position"); inputDevices.Add(input); return; } for (int i = 0; i < inputDevices.Count; i++) { if (inputDevices[i].GetType() == typeof(JoystickInput)) { Console.WriteLine("Added " + input.DeviceName + " at position " + i); inputDevices.Insert(i, input); return; } } Console.WriteLine("Added " + input.DeviceName + " at last position"); inputDevices.Add(input); }
private void InvokeNewInputDeviceEvent(String deviceId, GenericInput input) { if (NewInputDevice != null) { NewInputDeviceEventArgs eventArgs = new NewInputDeviceEventArgs(deviceId, input); NewInputDevice.Invoke(this, eventArgs); } }
private void InvokeNewInputDeviceEvent(GenericInput input) { if (NewInputDevice != null) { NewInputDeviceEventArgs eventArgs = new NewInputDeviceEventArgs(input.DeviceInstanceId, input.DeviceName, input); NewInputDevice.Invoke(this, eventArgs); } }
private void InitInputDevice(GenericInput input) { input.InitDevice(); if (currentInputMode == InputMode.ControlInput) { input.StartControlInput(); } else if (currentInputMode == InputMode.RawInput) { input.StartRawInput(); } InvokeNewInputDeviceEvent(input); }
private void UpdateRawInput() { for (int i = 0; i < inputDevices.Count; i++) { if (!IsListeningToDevice(inputDevices[i].DeviceInstanceId)) { continue; } bool isAxis; GenericInput input = inputDevices[i]; String inputString = input.GetCurrentRawInput(out isAxis); if (inputString != null && inputString != "") { InvokeRawInputReceivedEvent(input.DeviceInstanceId, inputString, isAxis); } } }
private void UpdateRawInput() { Dictionary <String, String> rawOutput = new Dictionary <String, String>(); GenericInput input = null; String deviceId; String inputString; bool isAxis; for (int i = 0; i < inputDevices.Count; i++) { input = inputDevices[i]; deviceId = input.DeviceInstanceId; inputString = input.GetCurrentlyInvokedInput(out isAxis); if (inputString != null && inputString != "") { InvokeRawInputReceivedEvent(deviceId, inputString, isAxis); } } }
private void ChangeInputDevice() { String comboBoxContent = (String)comboBoxDevices.Items[comboBoxDevices.SelectedIndex]; if (comboBoxDevices.SelectedIndex != 0 && (String)comboBoxDevices.Items[0] == "-- No device selected --") { comboBoxDevices.Items.Remove(0); } if (comboBoxContent != "-- No device selected --" && comboBoxContent != null) { RemoveSelectedButNotPresentDevice(); SetMappingEnabledState(true); String selectedDeviceName = comboBoxContent.ToString(); for (int i = 0; i < devices.Count; i++) { if (devices[i].DeviceName == selectedDeviceName) { selectedDevice = devices[i]; } } if (selectedDevice != null) { TakeOverMapping(selectedDevice.Mapping); isSelectedDevicePresent = true; UpdateCurrentDeviceDescription(); } } }
private void AddDeviceToDeviceList(GenericInput inputDevice) { bool foundReplacement = false; for (int i = 0; i < devices.Count; i++) { if (devices[i].DeviceInstanceId == inputDevice.DeviceInstanceId) { inputDevice.CopyMappingFrom(devices[i]); devices[i] = inputDevice; foundReplacement = true; break; } } if (!foundReplacement) { devices.Add(inputDevice); comboBoxDevices.Items.Add(inputDevice.DeviceName); } }
private void HandleNewDevice(String deviceId, GenericInput inputDevice) { AddDeviceToDeviceList(inputDevice); if (selectedDevice != null && selectedDevice.DeviceInstanceId == inputDevice.DeviceInstanceId) { inputDevice.CopyMappingFrom(selectedDevice); selectedDevice = inputDevice; isSelectedDevicePresent = true; UpdateCurrentDeviceDescription(); } }
private void ChangeInputDevice() { object comboBoxContent = ((ComboBoxItem)comboBoxDevices.SelectedValue).Content; if (comboBoxContent != null) { RemoveSelectedButNotPresentDevice(); SetMappingEnabledState(true); String selectedDeviceName = comboBoxContent.ToString(); for (int i = 0; i < devices.Count; i++) { if (devices[i].DeviceName == selectedDeviceName) { selectedDevice = devices[i]; } } if (selectedDevice != null) { TakeOverMapping(selectedDevice.Mapping); isSelectedDevicePresent = true; UpdateCurrentDeviceDescription(); } } }
public NewInputDeviceEventArgs(String deviceId, GenericInput input) : base(deviceId) { this.input = input; }
private void InitInputDevice(GenericInput input) { input.InitDevice(); if (currentInputMode == InputMode.ControlInput) input.StartControlInput(); else if (currentInputMode == InputMode.RawInput) input.StartRawInput(); InvokeNewInputDeviceEvent(input); }
private void AddInputDevice(GenericInput input) { Type typeToSearchFor; if (input.GetType() == typeof(CAVEDirectInput)) InputManager.CAVEInput = (CAVEDirectInput)input; if (input.GetType() == typeof(CheckInController)) InputManager.CheckInController = (CheckInController)input; if (input.GetType() == typeof(DatabaseController)) InputManager.DatabaseController = (DatabaseController)input; if (input.GetType() == typeof(VideoController)) InputManager.VideoController = (VideoController)input; if (input.GetType() == typeof(KeyboardInput)) typeToSearchFor = typeof(JoystickInput); else if (input.GetType() == typeof(JoystickInput)) typeToSearchFor = typeof(SpeechInput); else if (input.GetType() == typeof(SpeechInput)) typeToSearchFor = typeof(WiiMoteInput); else { Console.WriteLine("Added " + input.DeviceName + " at last position"); inputDevices.Add(input); return; } for (int i = 0; i < inputDevices.Count; i++) { if (inputDevices[i].GetType() == typeToSearchFor) { Console.WriteLine("Added " + input.DeviceName + " at position " + i); inputDevices.Insert(i, input); return; } } Console.WriteLine("Added " + input.DeviceName + " at last position"); inputDevices.Add(input); }
public void CopyMappingFrom(GenericInput input) { mapping = input.mapping.Clone(); backupMapping = input.backupMapping.Clone(); }