Пример #1
0
 /// <summary>
 /// Gets the specified controller.
 /// </summary>
 /// <returns>The specified controller.</returns>
 /// <param name="index">The index of the controller.</param>
 public MergeController GetController(int controllerIndex)
 {
     //check if mergecontroller object is defined for this controller
     if (controllerList.Count > controllerIndex && controllerList[controllerIndex] != null)
     {
         // controller already exists so return it
         return(controllerList[controllerIndex]);
     }
     else
     {
         // The controller doesn't exist in the list.  Let's see if we have one
         // actually connected.
         var controllerCount = ControllerCount;
         if (controllerCount >= (controllerIndex + 1))
         {
             // Yes, we have real controllers available for use.
             MergeController newController = new MergeController(controllerIndex);
             controllerList.Add(newController);
             Debug.Log("Controller added: " + controllerIndex);
             return(newController);
         }
         else
         {
             // We don't have any real controllers connected.  Return a "placeholder"
             // MergeController object, instead.
             if (placeholderController == null)
             {
                 placeholderController = new MergeController(-1);
             }
             return(placeholderController);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Go through all the controllers, calling UpdateController with their latest data.
        /// </summary>
        static public void Update()
        {
            if (IsControllerConnected(0))
            {
                int curControllerCount = QueryNumControllersConnected();

                // For each connected controller...
                for (int i = 0; i < curControllerCount; i++)
                {
                    // Update the controller data.
                    MergeController controller = Merge.MSDK.Instance.controllerList[i];
                    ControllerData  dat        = QueryControllerData(i);
                    controller.UpdateController(dat);

                    // Question - can controllers become UN-calibrated?
                    if (dat.calibration_status == 0)
                    {
                        dat.calibrated = true;
                    }
                }
            }
        }