Ejemplo n.º 1
0
    static unsafe void Test(Guid initialGuid, GUID *result)
    {
        Guid g    = initialGuid;
        GUID guid = GetGUID(ref g);

        Unsafe.CopyBlock(result, &guid, (uint)sizeof(GUID));
    }
Ejemplo n.º 2
0
        public unsafe override bool SetEnableAutocenter(bool enable)
        {
            IDirectInputDevice8 *directInputDevice =
                ((DirectInputJoystickInputDevice)Device).directInputDevice;

            DIPROPDWORD dipdw = new DIPROPDWORD();

            dipdw.diph.dwSize       = (uint)sizeof(DIPROPDWORD);
            dipdw.diph.dwHeaderSize = (uint)sizeof(DIPROPHEADER);
            dipdw.diph.dwObj        = 0;
            dipdw.diph.dwHow        = DInput.DIPH_DEVICE;
            dipdw.dwData            = (uint)((enable) ? 1 : 0);

            GUID *centerProp = (GUID *)DInput.getDIPROP_AUTOCENTER();
            int   hr         = IDirectInputDevice8.SetProperty(directInputDevice, centerProp, ref dipdw.diph);

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputForceFeedbackController: " +
                            "Cannot change autocenter property for \"{0}\".", Device.Name);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
 unsafe int SoundCaptureCallback(void */*GUID*/ pGuid, string description,
                                 string module, void *pContext)
 {
     if (pGuid != null)
     {
         GUID *guid = (GUID *)pGuid;
         recordDriverGuids.Add(*guid);
         recordDriverNames.Add(description);
     }
     return(1);
 }
 private static extern unsafe Type[] GetImporterTypes_Internal([Span("guidsLength", isReadOnly: true)] GUID *guids, int guidsLength);
Ejemplo n.º 5
0
 public static extern unsafe int DllGetClassObject(GUID *clsid, GUID *iid, void **ppv);
Ejemplo n.º 6
0
 public static extern unsafe int ADsOpenObject(ushort *lpszPathName, ushort *lpszUserName, ushort *lpszPassword, uint dwReserved, GUID *riid, void **ppObject);
Ejemplo n.º 7
0
 public static extern unsafe int ADsGetObject(ushort *lpszPathName, GUID *riid, void **ppObject);
 public static extern unsafe uint DsReplicaGetInfo2W(void *hDS, DS_REPL_INFO_TYPE InfoType, ushort *pszObjectDN, GUID *puuidForSourceDsaObjGuid, ushort *pszAttributeName, ushort *pszValueDN, uint dwFlags, uint dwEnumerationContext, void **ppInfo);
 public static extern unsafe int DsCrackUnquotedMangledRdnW(ushort *pszRDN, uint cchRDN, GUID *pGuid, DS_MANGLE_FOR *peDsMangleFor);
Ejemplo n.º 10
0
 public static extern unsafe uint DsReplicaModifyW(void *hDS, ushort *NameContext, GUID *pUuidSourceDsa, ushort *TransportDn, ushort *SourceDsaAddress, SCHEDULE *pSchedule, uint ReplicaFlags, uint ModifyFields, uint Options);
Ejemplo n.º 11
0
 public static extern unsafe uint DsReplicaVerifyObjectsA(void *hDS, sbyte *NameContext, GUID *pUuidDsaSrc, uint ulOptions);
Ejemplo n.º 12
0
 public static extern unsafe uint DsMapSchemaGuidsW(void *hDs, uint cGuids, GUID *rGuids, DS_SCHEMA_GUID_MAPW **ppGuidMap);
Ejemplo n.º 13
0
 public static extern unsafe uint DsReplicaSyncW(void *hDS, ushort *NameContext, GUID *pUuidDsaSrc, uint Options);
Ejemplo n.º 14
0
 public static extern unsafe uint DsReplicaUpdateRefsA(void *hDS, sbyte *NameContext, sbyte *DsaDest, GUID *pUuidDsaDest, uint Options);
        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
        }
        internal unsafe bool Init()
        {
            GUID devGuid = deviceGuid;

            void */*IDirectInputDevice8*/ directInputDeviceTemp = null;

            int hr = IDirectInput.CreateDevice(
                WindowsInputDeviceManager.Instance.DirectInput,
                ref devGuid, out directInputDeviceTemp, null);

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot create device \"{0}\" ({1}).",
                            Name, DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                return(false);
            }

            directInputDevice = (IDirectInputDevice8 *)directInputDeviceTemp;

            // get capabilities

            DIDEVCAPS caps = new DIDEVCAPS();

            caps.dwSize = (uint)sizeof(DIDEVCAPS);

            hr = IDirectInputDevice8.GetCapabilities(directInputDevice, ref caps);
            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot get device capabilities \"{0}\".", Name);
                return(false);
            }

            //buttons
            Button[] buttons = new Button[caps.dwButtons];
            for (int n = 0; n < buttons.Length; n++)
            {
                buttons[n] = new Button((JoystickButtons)n, n);
            }

            //povs
            POV[] povs = new POV[caps.dwPOVs];
            for (int n = 0; n < povs.Length; n++)
            {
                povs[n] = new JoystickInputDevice.POV((JoystickPOVs)n);
            }

            // setup

            hr = IDirectInputDevice8.SetDataFormat(directInputDevice, DInput.Get_c_dfDIJoystick2());

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot set device data format \"{0}\".", Name);
                return(false);
            }

            hr = IDirectInputDevice8.SetCooperativeLevel(directInputDevice,
                                                         WindowsInputDeviceManager.Instance.WindowHandle,
                                                         DInput.DISCL_EXCLUSIVE | DInput.DISCL_FOREGROUND);

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot set device " +
                            "cooperative level \"{0}\".", Name);
                return(false);
            }

            //-------------------------------------------------------------------
            // setup size for buffered input

            DIPROPDWORD dibuf = new DIPROPDWORD();

            dibuf.diph.dwSize       = (uint)sizeof(DIPROPDWORD);
            dibuf.diph.dwHeaderSize = (uint)sizeof(DIPROPHEADER);
            dibuf.diph.dwHow        = DInput.DIPH_DEVICE;
            dibuf.diph.dwObj        = 0;
            dibuf.dwData            = BufferSize;

            GUID *bufferSizeGuid = (GUID *)DInput.getDIPROP_BUFFERSIZE();

            hr = IDirectInputDevice8.SetProperty(directInputDevice, bufferSizeGuid, ref dibuf.diph);
            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot set device buffer size \"{0}\".",
                            Name);
                return(false);
            }

            deviceDataBuffer = NativeUtility.Alloc(NativeUtility.MemoryAllocationType.Utility,
                                                   sizeof(DIDEVICEOBJECTDATA) * BufferSize);

            //--------------------------------------------------------------------

            temporarySliderCount = 0;

            temporaryAxisList = new List <JoystickInputDevice.Axis>();

            tempDeviceForEnumerate = this;
            hr = IDirectInputDevice8.EnumObjects(directInputDevice, EnumDeviceObjectsHandler,
                                                 null, DInput.DIDFT_ALL);
            tempDeviceForEnumerate = null;

            if (Wrapper.FAILED(hr))
            {
                Log.Warning("DirectInputJoystickDevice: Cannot enumerate device objects \"{0}\".",
                            Name);
                return(false);
            }

            //axes
            Axis[] axes = temporaryAxisList.ToArray();
            temporaryAxisList = null;

            //sliders
            Slider[] sliders = new Slider[temporarySliderCount];
            for (int n = 0; n < sliders.Length; n++)
            {
                sliders[n] = new JoystickInputDevice.Slider((JoystickSliders)n);
            }

            //forceFeedbackController
            ForceFeedbackController forceFeedbackController = null;

            if ((caps.dwFlags & DInput.DIDC_FORCEFEEDBACK) != 0)
            {
                forceFeedbackController = new DirectInputForceFeedbackController(directInputDevice, this);
            }

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

            return(true);
        }
Ejemplo n.º 17
0
 public static extern unsafe uint DsReplicaGetInfoW(void *hDS, DS_REPL_INFO_TYPE InfoType, ushort *pszObjectDN, GUID *puuidForSourceDsaObjGuid, void **ppInfo);
Ejemplo n.º 18
0
 virtual HRESULT STDMETHODCALLTYPE GetGUID(
     /* [out] */ GUID *pGUID) = 0;
Ejemplo n.º 19
0
 public static extern unsafe uint DsReplicaUpdateRefsW(void *hDS, ushort *NameContext, ushort *DsaDest, GUID *pUuidDsaDest, uint Options);