コード例 #1
0
				public IDevice ResolveDevice (IHIDDevice hidDevice)
				{
						if (hidDevice.PID == 46675 && hidDevice.VID == 1103) {
								this.__hidInterface = hidDevice.hidInterface;

								//check for profile
								DeviceProfile profile = hidDevice.loadProfile();;




								JoystickDevice device = new ThrustmasterRGTFFDDevice (hidDevice.index, hidDevice.PID, hidDevice.VID, hidDevice.ID, 8, 10, this);
								device.Name = hidDevice.Name;
                                device.profile = profile;
								//JoystickDevice joystick = new JoystickDevice(hidDevice.index, hidDevice.PID, hidDevice.VID, 8, 10, this);

               






								int index = 0;
								for (; index < 10; index++) {
										device.Buttons [index] = new ButtonDetails ();

										if (profile != null && profile.buttonNaming.Length > index) {
												device.Buttons [index].name = profile.buttonNaming [index];
										}
								}


								for (index = 0; index < 8; index++) {

										device.Axis [index] = new AxisDetails ();
										if (profile != null && profile.axisNaming.Length > index && device.Axis [index] != null) {
												device.Axis [index].name = profile.axisNaming [index];
						
										}

								}


           

								return device;
						}

						return null;
				}
コード例 #2
0
        void OnGUI()
        {
            //			if (InputManager.Devices.ContainsIndex(0))
            //				XDevice = InputManager.Devices.GetDeviceAt(0) as XInputDevice;
            //
            //			if (GUI.Button(new Rect(150, 590, 100, 130), "Rumble"))
            //			{
            //
            //
            //
            //				XDevice.SetMotor(0x80,0xFF);
            //
            //
            //
            //
            //
            //
            //			}

            //don't take device here in the loop this is just for demo

            //don't take device here in the loop this is just for demo
            List<ThrustmasterRGTFFDDevice> devices = InputManager.GetDevices<ThrustmasterRGTFFDDevice> ();
            if (devices.Count>0)
                TTFFDDevice = devices[0];

            if (TTFFDDevice == null)
                return;

            //#if UNITY_ANDROID

            vSliderValue = GUI.HorizontalSlider(new Rect(25, 520, 400, 100), vSliderValue, 255.0F, 0.0F);
            // #endif

            if (vSliderValue != vSliderValuePrev)
                // device.SetMotor(Convert.ToByte(vSliderValue), 0xA7, onMotorSet);
                TTFFDDevice.SetMotor(Convert.ToByte(vSliderValue), Convert.ToByte(vSliderValue), onMotorSet);

            vSliderValuePrev = vSliderValue;

            if (GUI.Button(new Rect(25, 590, 100, 130), "Stop Motor"))
            {
                //timer.Stop();
                if (runEffectEnumerator != null)
                    StopCoroutine(runEffectEnumerator);
                TTFFDDevice.StopMotor(onMotorStop);
                vSliderValue = 128;
            }

            if (GUI.Button(new Rect(150, 590, 100, 130), "Rumble"))
            {

                runEffectEnumerator = runEffect();

                TTFFDDevice.StopMotor(onMotorStop);

                StartCoroutine(runEffectEnumerator);

                //char buf[] = {0x00, 0x01, 0x0f, 0xc0, 0x00, large, small, 0x00, 0x00, 0x00, 0x00, 0x00};

            }
        }