コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public override bool InitAllControllers()
        {
            //
            if (m_IsInited)
            {
                return(false);
            }
            m_IsInited = true;
            //
            int ret;

            ret = XDevicePlugin.Init();
            if (ret != 0)
            {
                return(false);
            }
            ret = SixensePluginLite.sixenseInit();
            if (ret != 0)
            {
                return(false);
            }
            //
            if (maxControllers <= 0)
            {
                maxControllers = SixensePluginLite.sixenseGetMaxControllers();
            }
            if (controllers == null)
            {
                if (inputTransforms.Length == 0)
                {
                    inputTransforms = new InputTransform[1] {
                        null
                    };
                }
                controllers = new SixenseController[maxControllers];
                for (int i = 0; i < maxControllers; ++i)
                {
                    controllers[i] = new SixenseController(
                        this,
                        string.Format(controllerFormat, i), i
                        );
                }
            }
            //
            m_Result = 0;
            return(true);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        public override int GetInputState(ref XDevicePlugin.ControllerState state)
        {
            int i;
            //
            int ret = SixensePluginLite.sixenseGetNewestData(index, ref rawData);

            if (ret == 0)
            {
                // Axes
                i = 0;
                state.axes[i++] = rawData.trigger;
                i++;
                state.axes[i++] = rawData.joystick_x;
                state.axes[i++] = rawData.joystick_y;
                // Buttons
                //
                if (inputTransform == null)
                {
                    state.buttons = rawData.buttons;
                }
                else
                {
                    state.buttons = inputTransform.TransformButtons(rawData.buttons);
                }
                // Position
                i = 3;
                while (i-- > 0)               // i==3
                {
                    state.position[i] = rawData.pos[i] * manager.sensitivity[i];
                }
                // Rotation
                i = 4;
                while (i-- > 0)
                {
                    state.rotation[i] = rawData.rot_quat[i];
                }
            }
            return(ret);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public override bool DeinitAllControllers()
        {
            if (!m_IsInited)
            {
                return(false);
            }
            m_IsInited = false;
            //
            int ret;

            ret = SixensePluginLite.sixenseExit();
            if (ret != 0)
            {
                return(false);
            }
            ret = XDevicePlugin.Exit();
            if (ret != 0)
            {
                return(false);
            }
            //
            m_Result = 0;
            return(true);
        }