Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
                }
            }
        }
Ejemplo n.º 6
0
        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);
                }
            }
        }
Ejemplo n.º 7
0
 private void InvokeNewInputDeviceEvent(GenericInput input)
 {
     if (NewInputDevice != null)
         {
              NewInputDeviceEventArgs eventArgs = new NewInputDeviceEventArgs(input.DeviceInstanceId, input.DeviceName, input);
              NewInputDevice.Invoke(this, eventArgs);
         }
 }
        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();
            }
        }
Ejemplo n.º 11
0
        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();
                }
            }
        }
Ejemplo n.º 12
0
 private void InvokeNewInputDeviceEvent(String deviceId, GenericInput input)
 {
     if (NewInputDevice != null)
     {
         NewInputDeviceEventArgs eventArgs = new NewInputDeviceEventArgs(deviceId, input);
         NewInputDevice.Invoke(this, eventArgs);
     }
 }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 public NewInputDeviceEventArgs(String deviceId, GenericInput input)
     : base(deviceId)
 {
     this.input = input;
 }
Ejemplo n.º 15
0
        private void InitInputDevice(GenericInput input)
        {
            input.InitDevice();
                if (currentInputMode == InputMode.ControlInput)
                     input.StartControlInput();
                else if (currentInputMode == InputMode.RawInput)
                     input.StartRawInput();

                InvokeNewInputDeviceEvent(input);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
 public NewInputDeviceEventArgs(String deviceId, GenericInput input)
     : base(deviceId)
 {
     this.input = input;
 }
Ejemplo n.º 18
0
 public void CopyMappingFrom(GenericInput input)
 {
     mapping = input.mapping.Clone();
     backupMapping = input.backupMapping.Clone();
 }
Ejemplo n.º 19
0
 public void CopyMappingFrom(GenericInput input)
 {
     mapping       = input.mapping.Clone();
     backupMapping = input.backupMapping.Clone();
 }