Ejemplo n.º 1
0
        static public Dictionary <Guid, DeviceInstance> EnumerateAllAttachedGameDevices(IDirectInput8 directInput)
        {
            Dictionary <Guid, DeviceInstance> connectedDeviceList_ = new Dictionary <Guid, DeviceInstance>();

            foreach (DeviceInstance deviceInstance_ in directInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly))
            {
                if (deviceInstance_.Type == Vortice.DirectInput.DeviceType.Gamepad || deviceInstance_.Type == Vortice.DirectInput.DeviceType.Joystick)
                {
                    connectedDeviceList_.Add(deviceInstance_.InstanceGuid, deviceInstance_);
                }
                else
                {
                    Console.WriteLine(deviceInstance_.ProductName + " does not match input type, ignored.");
                }
            }

            return(connectedDeviceList_);
        }
Ejemplo n.º 2
0
    public static Dictionary <Guid, DeviceInstance> EnumerateAllAttachedKeyboardDevices(IDirectInput8 directInput)
    {
        Dictionary <Guid, DeviceInstance> result = new();

        foreach (DeviceInstance deviceInstance in directInput.GetDevices(DeviceClass.Keyboard, DeviceEnumerationFlags.AttachedOnly))
        {
            if (deviceInstance.Type == DeviceType.Keyboard)
            {
                result.Add(deviceInstance.InstanceGuid, deviceInstance);
            }
            else
            {
                Console.WriteLine(deviceInstance.ProductName + " does not match input type, ignored.");
            }
        }

        return(result);
    }