Esempio n. 1
0
        private static void ControllerUpdatePositions(
            PSMoveWorkerSettings WorkerSettings,
            IntPtr psmove_tracker, // PSMoveTracker*
            IntPtr psmove_fusion,  // PSMoveFusion*
            IntPtr psmove,         // PSMove*
            PSMoveRawControllerData_Base controllerData)
        {
            // Find the sphere position in the camera
            PSMoveAPI.psmove_tracker_update(psmove_tracker, psmove);

            PSMoveTracker_Status curr_status =
                PSMoveAPI.psmove_tracker_get_status(psmove_tracker, psmove);

            // Can we actually see the controller this frame?
            controllerData.IsSeenByTracker = curr_status == PSMoveTracker_Status.Tracker_TRACKING;

            // Update the position of the controller
            if (controllerData.IsSeenByTracker)
            {
                float xcm = 0.0f, ycm = 0.0f, zcm = 0.0f;

                PSMoveAPI.psmove_fusion_get_transformed_location(psmove_fusion, psmove, ref xcm, ref ycm, ref zcm);

                // [Store the controller position]
                // Remember the position the ps move controller in either its native space
                // or in a transformed space if a transform file existed.
                controllerData.PSMovePosition =
                    new Vector3(
                        xcm + WorkerSettings.PSMoveOffset.X,
                        ycm + WorkerSettings.PSMoveOffset.Y,
                        zcm + WorkerSettings.PSMoveOffset.Z);
            }
        }
Esempio n. 2
0
        private static void ControllerUpdateButtonState(
            IntPtr psmove, // PSMove*
            PSMoveRawControllerData_Base controllerData)
        {
            // Get the controller button state
            controllerData.Buttons = PSMoveAPI.psmove_get_buttons(psmove); // Bitwise; tells if each button is down.

            // Get the controller trigger value (uint8; 0-255)
            controllerData.TriggerValue = (byte)PSMoveAPI.psmove_get_trigger(psmove);
        }
Esempio n. 3
0
        private static void ControllerUpdateOrientations(
            IntPtr psmove, // PSMove*
            PSMoveRawControllerData_Base controllerData)
        {
            float oriw = 1.0f, orix = 0.0f, oriy = 0.0f, oriz = 0.0f;

            // Get the controller orientation (uses IMU).
            PSMoveAPI.psmove_get_orientation(psmove, ref oriw, ref orix, ref oriy, ref oriz);

            //NOTE: This orientation is in the PSMoveApi coordinate system
            controllerData.PSMoveOrientation = new Quaternion(orix, oriy, oriz, oriw);
        }