/// <summary>
        /// Initialize the device
        /// </summary>
        /// <returns>Returns true if initializng was successfully</returns>
        internal bool Init()
        {
            //buttons
            Button[] buttons = new Button[2];
            buttons[0] = new Button(JoystickButtons.Button1, 0);
            buttons[1] = new Button(JoystickButtons.Button2, 1);

            //axes
            Axis[] axes = new Axis[1];
            axes[0] = new JoystickInputDevice.Axis(JoystickAxes.X, new Range(-1, 1), false);

            //povs
            POV[] povs = new POV[0];
            //povs[ 0 ] = new JoystickInputDevice.POV( JoystickPOVs.POV1 );

            //sliders
            Slider[] sliders = new Slider[0];
            //sliders[ 0 ] = new Slider( JoystickSliders.Slider1 );

            //forceFeedbackController
            ForceFeedbackController forceFeedbackController = null;

            //initialize data
            InitDeviceData(buttons, axes, povs, sliders, forceFeedbackController);

            return(true);
        }
        internal bool Init()
        {
            //buttons
            Button[] buttons = new Button[ 2 ];
            buttons[ 0 ] = new Button( JoystickButtons.Button1, 0 );
            buttons[ 1 ] = new Button( JoystickButtons.Button2, 1 );

            //axes
            Axis[] axes = new Axis[ 1 ];
            axes[ 0 ] = new JoystickInputDevice.Axis( JoystickAxes.X, new Range( -1, 1 ), false );

            //povs
            POV[] povs = new POV[ 0 ];
            //povs[ 0 ] = new JoystickInputDevice.POV( JoystickPOVs.POV1 );

            //sliders
            Slider[] sliders = new Slider[ 0 ];
            //sliders[ 0 ] = new Slider( JoystickSliders.Slider1 );

            //forceFeedbackController
            ForceFeedbackController forceFeedbackController = null;

            //initialize data
            InitDeviceData( buttons, axes, povs, sliders, forceFeedbackController );

            return true;
        }
        unsafe static bool EnumDeviceObjectsHandler(IntPtr /*DIDEVICEOBJECTINSTANCE*/ lpddoi, void *pvRef)
        {
            DirectInputJoystickInputDevice device = tempDeviceForEnumerate;

            DIDEVICEOBJECTINSTANCE *deviceObjectInstance = (DIDEVICEOBJECTINSTANCE *)lpddoi;

            if ((deviceObjectInstance->dwType & DInput.DIDFT_AXIS) != 0)
            {
                int hr;

                // set range

                DIPROPRANGE diPropRange = new DIPROPRANGE();
                diPropRange.diph.dwSize       = (uint)sizeof(DIPROPRANGE);
                diPropRange.diph.dwHeaderSize = (uint)sizeof(DIPROPHEADER);
                diPropRange.diph.dwHow        = DInput.DIPH_BYID;
                diPropRange.diph.dwObj        = deviceObjectInstance->dwType;
                diPropRange.lMin = -(int)MaxRange;
                diPropRange.lMax = +(int)MaxRange;

                GUID *propRangeGuid = (GUID *)DInput.getDIPROP_RANGE();

                hr = IDirectInputDevice8.SetProperty_DIPROPRANGE(device.directInputDevice,
                                                                 propRangeGuid, ref diPropRange);
                //hr = IDirectInputDevice8.SetProperty( device.directInputDevice,
                //   propRangeGuid, ref diPropRange.diph );

                if (Wrapper.FAILED(hr))
                {
                    Log.Warning("DirectInputJoystickInputDevice: Cannot set axis range for \"{0}\" ({1}).",
                                device.Name, DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                }

                // set axis type

                //uint userData = 0xFFFFFFFF;

                if (deviceObjectInstance->guidType == DInput.GUID_Slider)
                {
                    device.temporarySliderCount++;
                }

                if (deviceObjectInstance->guidType == DInput.GUID_XAxis ||
                    deviceObjectInstance->guidType == DInput.GUID_YAxis ||
                    deviceObjectInstance->guidType == DInput.GUID_ZAxis ||
                    deviceObjectInstance->guidType == DInput.GUID_RxAxis ||
                    deviceObjectInstance->guidType == DInput.GUID_RyAxis ||
                    deviceObjectInstance->guidType == DInput.GUID_RzAxis)
                {
                    // set dead zone

                    //DIPROPDWORD deadZone = new DIPROPDWORD();
                    //deadZone.diph.dwSize = (uint)sizeof( DIPROPDWORD );
                    //deadZone.diph.dwHeaderSize = (uint)sizeof( DIPROPHEADER );
                    //deadZone.diph.dwHow = DInput.DIPH_BYID;
                    //deadZone.diph.dwObj = deviceObjectInstance->dwType; // Specify the enumerated axis
                    //deadZone.dwData = 500;	// dead zone of 5%

                    //GUID* propDeadZone = (GUID*)DInput.getDIPROP_DEADZONE();

                    //hr = IDirectInputDevice8.SetProperty( joystickDevice,
                    //   propDeadZone, ref deadZone.diph );
                    //if( Wrapper.FAILED( hr ) )
                    //{
                    //   Log.Error( "Cannot set axis dead zone for '" + Name + "'" );
                    //}

                    // type settings

                    //userData = 0x80000000 | (uint)device.temporaryAxisList.Count;

                    JoystickAxes axisName = GetJoystickAxisNameByGUID(deviceObjectInstance->guidType);

                    RangeF range = new RangeF(-1, 1);

                    bool forceFeedbackSupported =
                        (deviceObjectInstance->dwFlags & DInput.DIDOI_FFACTUATOR) != 0;

                    JoystickInputDevice.Axis axis = new JoystickInputDevice.Axis(
                        axisName, range, forceFeedbackSupported);

                    device.temporaryAxisList.Add(axis);
                }

                //// set user data

                //DIPROPPOINTER diptr = new DIPROPPOINTER();
                //diptr.diph.dwSize = (uint)sizeof( DIPROPPOINTER );
                //diptr.diph.dwHeaderSize = (uint)sizeof( DIPROPHEADER );
                //diptr.diph.dwHow = DInput.DIPH_BYID;
                //diptr.diph.dwObj = deviceObjectInstance->dwType;
                ////if( IntPtr.Size == 8 )
                ////{
                ////   UInt64 v64 = userData;
                ////   NativeUtils.CopyMemory( (IntPtr)( &diptr.uData ), (IntPtr)( &v64 ), IntPtr.Size );
                ////}
                ////else
                ////{
                ////   NativeUtils.CopyMemory( (IntPtr)( &diptr.uData ), (IntPtr)( &userData ), IntPtr.Size );
                ////}
                //diptr.uData = IntPtr.Zero;
                ////diptr.uData = (IntPtr)userData;

                //GUID* appDataGuid = (GUID*)DInput.getDIPROP_APPDATA();

                //hr = IDirectInputDevice8.SetProperty( device.directInputDevice,
                //   appDataGuid, ref diptr.diph );
                //if( Wrapper.FAILED( hr ) )
                //{
                //   Log.InvisibleInfo( "DirectInputJoystickDevice: Cannot set appData for \"{0}\".",
                //      device.Name );
                //   //Log.Warning( "DirectInputJoystickDevice: Cannot set appData for \"{0}\".",
                //   //   device.Name );
                //}
            }
            return(true);            // continue
        }