コード例 #1
0
ファイル: LinuxJoystick.cs プロジェクト: albfan/Opentk
        private void CloseJoystick(LinuxJoystickDetails js)
        {
            Sticks.Remove(js.FileDescriptor);

            Libc.close(js.FileDescriptor);
            js.FileDescriptor = -1;
            js.State          = new JoystickState(); // clear joystick state
            js.Caps           = new JoystickCapabilities();
        }
コード例 #2
0
ファイル: Xd100eProcessor.cs プロジェクト: wpmyj/c3
 private void RemoveUnknownPlaceDevice(DeviceCollection devices)
 {
     for (int i = devices.Count - 1; i >= 0; i--)
     {
         IDevice device = devices[i];
         if (device is PlaceDeviceBase)
         {
             PlaceDeviceBase placeDevice = device as PlaceDeviceBase;
             if (placeDevice.Place == FluxPlace.Unknown)
             {
                 devices.Remove(device);
             }
         }
     }
 }
コード例 #3
0
ファイル: Xd100eProcessor.cs プロジェクト: hkiaipc/C3
 private void RemoveUnknownPlaceDevice(DeviceCollection devices)
 {
     for (int i = devices.Count -1; i >= 0; i--)
     {
         IDevice device = devices[i];
         if (device is PlaceDeviceBase)
         {
             PlaceDeviceBase placeDevice = device as PlaceDeviceBase;
             if (placeDevice.Place == FluxPlace.Unknown)
             {
                 devices.Remove(device);
             }
         }
     }
 }
コード例 #4
0
ファイル: WinRawJoystick.cs プロジェクト: guusw/opentk
        public void RefreshDevices()
        {
            // Mark all devices as disconnected. We will check which of those
            // are connected below.
            foreach (var device in Devices)
            {
                device.SetConnected(false);
            }

            // Discover joystick devices
            int xinput_device_count = 0;

            foreach (RawInputDeviceList dev in WinRawInput.GetDeviceList())
            {
                // Skip non-joystick devices
                if (dev.Type != RawInputDeviceType.HID)
                {
                    continue;
                }

                // We use the device handle as the hardware id.
                // This works, but the handle will change whenever the
                // device is unplugged/replugged. We compensate for this
                // by checking device GUIDs, below.
                // Note: we cannot use the GUID as the hardware id,
                // because it is costly to query (and we need to query
                // that every time we process a device event.)
                IntPtr handle      = dev.Device;
                bool   is_xinput   = IsXInput(handle);
                Guid   guid        = GetDeviceGuid(handle);
                long   hardware_id = handle.ToInt64();

                Device device = Devices.FromHardwareId(hardware_id);
                if (device != null)
                {
                    // We have already opened this device, mark it as connected
                    device.SetConnected(true);
                }
                else
                {
                    device = new Device(handle, guid, is_xinput,
                                        is_xinput ? xinput_device_count++ : 0);

                    // This is a new device, query its capabilities and add it
                    // to the device list
                    if (!QueryDeviceCaps(device) && !is_xinput)
                    {
                        continue;
                    }
                    device.SetConnected(true);

                    // Check if a disconnected device with identical GUID already exists.
                    // If so, replace that device with this instance.
                    Device match = null;
                    foreach (Device candidate in Devices)
                    {
                        if (candidate.GetGuid() == guid && !candidate.GetCapabilities().IsConnected)
                        {
                            match = candidate;
                        }
                    }
                    if (match != null)
                    {
                        Devices.Remove(match.Handle.ToInt64());
                    }

                    Devices.Add(hardware_id, device);

                    Debug.Print("[{0}] Connected joystick {1} ({2})",
                                GetType().Name, device.GetGuid(), device.GetCapabilities());
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Rem ove this device from the collection if present
 /// </summary>
 /// <param name="device"></param>
 /// <returns></returns>
 public bool RemoveDevice(PlaybackDevice device) => DeviceCollection.Remove(device);