Esempio n. 1
0
    private void InitializeJoystickDevice(IDirectInput8 directInput, Guid guid, IntPtr windowhandle)
    {
        IDirectInputDevice8 inputDevice = directInput.CreateDevice(guid);

        inputDevice.SetCooperativeLevel(windowhandle, CooperativeLevel.NonExclusive | CooperativeLevel.Foreground);

        // Play the values back to see that buffersize is working correctly
        inputDevice.Properties.BufferSize = 16;

        if (directInput.IsDeviceAttached(guid))
        {
            Result result = inputDevice.SetDataFormat <RawJoystickState>();

            if (result.Success)
            {
                _joystickDevices.Add(guid, inputDevice);
            }
        }
    }
Esempio n. 2
0
        void InitialiseKeyboardDevice(IDirectInput8 directInput, Guid guid, IntPtr windowhandle)
        {
            IDirectInputDevice8 inputDevice_ = directInput.CreateDevice(guid);

            Result result_ = inputDevice_.SetCooperativeLevel(windowhandle, CooperativeLevel.NonExclusive | CooperativeLevel.Foreground);

            // play the values back to see that buffersize is working correctly
            inputDevice_.Properties.BufferSize = 16;

            int size = inputDevice_.Properties.BufferSize;

            if (directInput.IsDeviceAttached(guid))
            {
                result_ = inputDevice_.SetDataFormat <RawKeyboardState>();

                if (result_.Success)
                {
                    _keyboardDevices.Add(guid, inputDevice_);
                }
            }
        }