// Construct new GameSettings instance using values loaded from file public GameSettings(XElement data) { _screenWidth = Loader.loadInt(data.Element("ScreenWidth"), 800); _screenHeight = Loader.loadInt(data.Element("ScreenHeight"), 600); _fullscreen = Loader.loadBool(data.Element("Fullscreen"), false); _controllerType = (ControllerType)Loader.loadEnum(typeof(ControllerType), data.Element("ControllerType"), (int)ControllerType.KeyboardAndMouse); }
Boolean IInputManager.actionTapped(InputAction action) { if(keyInput.actionTapped(action)) { lastControllerTapped = ControllerType.Keyboard; return true; } if(padOneInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadOne; return true; } if(padTwoInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadTwo; return true; } if(padThreeInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadThree; return true; } if(padFourInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadFour; return true; } return false; }
// Construct new GameSettings instance using default values public GameSettings(LoderGame game) { // Find suitable screen size int screenWidth = 1024; int screenHeight = 768; int maxScreenWidth = game.GraphicsDevice.DisplayMode.Width - 100; int maxScreenHeight = game.GraphicsDevice.DisplayMode.Height - 100; /* DisplayDevice currentDisplayDevice = DisplayDevice.GetDisplay(DisplayIndex.Primary); List<DisplayResolution> availableResolutions = currentDisplayDevice.AvailableResolutions as List<DisplayResolution>; foreach (DisplayResolution displayResolution in availableResolutions) { if (displayResolution.Width < maxScreenWidth && displayResolution.Height < maxScreenHeight && displayResolution.Width >= screenWidth && displayResolution.Height >= screenHeight) { screenWidth = displayResolution.Width; screenHeight = displayResolution.Height; } } */ _screenWidth = screenWidth; _screenHeight = screenHeight; _fullscreen = false; _controllerType = GamePad.GetState(PlayerIndex.One).IsConnected ? ControllerType.Gamepad : ControllerType.KeyboardAndMouse; }
public void controller_types_are_mapped_correctly_in_collection(Type type, ControllerType controllerType) { _sut.Collection .Single(x => x.Name == type.FullName) .ControllerType .ShouldEqual(controllerType); }
/// <summary> /// Save all data for a specific controller. Does not save Player data. /// </summary> /// <param name="controllerType">Controller type</param> /// <param name="controllerId">Controller id</param> public override void SaveControllerData(ControllerType controllerType, int controllerId) { if(!isEnabled) { Debug.LogWarning("UserDataStore_PlayerPrefs is disabled and will not save any data.", this); return; } SaveControllerDataNow(controllerType, controllerId); }
public void AddPlayer(int number, PlayerIndex playerIndex, ControllerType controllerType) { Debug.Log("Add player : " + number + ", controller: " + playerIndex); players.Add(new PlayerList(number, playerIndex, controllerType)); uiPlayers[number-1].sprite = GameManager.instance.playerSkins[number-1].ui; UIManager.instance.Shake(50f, 10f, Vector2.zero); }
public void SetControllerType(string type) { if (type == "local") { controllerType = ControllerType.Local; } else { controllerType = ControllerType.Remote; } }
public override void LoadControllerData(int playerId, ControllerType controllerType, int controllerId) { if (!this.isEnabled) { Debug.LogWarning("UserDataStore_PlayerPrefs is disabled and will not load any data.", this); return; } this.LoadControllerDataNow(playerId, controllerType, controllerId); }
public static void selectType(ControllerType type) { if (type == ControllerType.GAMEPAD) { instance = new KeyboardControl(); } else if (type == ControllerType.KEYBOARD) { instance = new GamepadControl(); } }
public Keybind(Keybinds keys, ControllerType portOne, ControllerType portTwo, ControllerType expansion, bool fourScore, bool filterIllegalInput, string inputMode) { this.keys = keys; this.fourScore = fourScore; this.portOne = portOne; this.portTwo = portTwo; this.expansion = expansion; this.inputMode = inputMode; InitializeComponent(); chkFourScore.Checked = fourScore; chkFilter.Checked = filterIllegalInput; switch (portOne) { case ControllerType.Controller: cboPortOne.SelectedIndex = 0; break; case ControllerType.Zapper: cboPortOne.SelectedIndex = 1; break; case ControllerType.Paddle: cboPortOne.SelectedIndex = 2; break; default: case ControllerType.Empty: cboPortOne.SelectedIndex = 3; break; } switch (portTwo) { case ControllerType.Controller: cboPortTwo.SelectedIndex = 0; break; case ControllerType.Zapper: cboPortTwo.SelectedIndex = 1; break; case ControllerType.Paddle: cboPortTwo.SelectedIndex = 2; break; default: case ControllerType.Empty: cboPortTwo.SelectedIndex = 3; break; } switch (expansion) { case ControllerType.FamiPaddle: cboExpansion.SelectedIndex = 0; break; default: case ControllerType.Empty: cboExpansion.SelectedIndex = 1; break; } }
/// <summary> /// Save all data for a specific controller. Does not save Player data. /// </summary> /// <param name="controllerType">Controller type</param> /// <param name="controllerId">Controller id</param> public override void SaveControllerData(ControllerType controllerType, int controllerId) { if(!isEnabled) { Debug.LogWarning(thisScriptName + " is disabled and will not save any data.", this); return; } SaveControllerDataNow(controllerType, controllerId); #if UNITY_EDITOR Debug.Log("Rewired: " + thisScriptName + " saved " + controllerType + " " + controllerId + " data to XML."); #endif }
public Controller(string name, ControllerType controllerType, string definition, Csrf csrfProtection, bool authorise) { if (name == null) throw new ArgumentNullException("name"); if (definition == null) throw new ArgumentNullException("definition"); Name = name; ControllerType = controllerType; Definition = definition; CsrfProtection = csrfProtection; Authorise = authorise; }
/// <inheritdoc/> public override void ResetData() { m_initialized = false; m_type = ControllerType.None; m_rawValue = 0; m_value = 0.0; m_periodScale = 0; m_zeroLatch = false; base.ResetData(); }
public AAngularController createController(ControllerType controllerType) { switch (controllerType) { case ControllerType.NoHttp: return new AngularController(angularView); case ControllerType.GetHttp: return new AngularController(angularView); default: return new AngularController(angularView); } }
/// <summary> /// Constructor /// </summary> private InputManager() { if (GamePad.GetState(PlayerIndex.One).IsConnected) { controllerType = ControllerType.GamePad; gamePadMapping = new Dictionary<string, Buttons[]>(); } else { controllerType = ControllerType.Keyboard; keyboardMapping = new Dictionary<string, Keys[]>(); } #region Button Mappings // Assign the various actions to the mapping dictionaries // ex: gamePadMapping.Add("MenuSelection", new Buttons[2] {Buttons.A, Buttons.Start}); switch (controllerType) { case ControllerType.GamePad: gamePadMapping.Add("MenuSelection", new Buttons[2] { Buttons.A, Buttons.Start }); gamePadMapping.Add("Pause", new Buttons[1] { Buttons.Start }); gamePadMapping.Add("MenuBack", new Buttons[1] { Buttons.B }); gamePadMapping.Add("Down", new Buttons[2] { Buttons.DPadDown, Buttons.LeftThumbstickDown }); gamePadMapping.Add("Up", new Buttons[2] { Buttons.DPadUp, Buttons.LeftThumbstickUp }); gamePadMapping.Add("Right", new Buttons[2] { Buttons.DPadRight, Buttons.LeftThumbstickRight }); gamePadMapping.Add("Left", new Buttons[2] { Buttons.DPadLeft, Buttons.LeftThumbstickLeft }); gamePadMapping.Add("Dance", new Buttons[1] { Buttons.A }); gamePadMapping.Add("Superflash", new Buttons[1] { Buttons.X }); break; case ControllerType.Keyboard: keyboardMapping.Add("MenuSelection", new Keys[2] { Keys.Enter, Keys.Space }); keyboardMapping.Add("Pause", new Keys[2] { Keys.Pause, Keys.P }); keyboardMapping.Add("MenuBack", new Keys[1] { Keys.Escape }); keyboardMapping.Add("Down", new Keys[1] { Keys.Down }); keyboardMapping.Add("Up", new Keys[1] { Keys.Up }); keyboardMapping.Add("Right", new Keys[1] { Keys.Right }); keyboardMapping.Add("Left", new Keys[1] { Keys.Left }); keyboardMapping.Add("Dance", new Keys[1] { Keys.D }); keyboardMapping.Add("Superflash", new Keys[1] { Keys.S }); break; } #endregion }
/// <summary> /// Get input for local player controller /// </summary> /// <returns>Raw input direction</returns> Vector3 GetInputDirection(ControllerType controller = ControllerType.Keyboard) { Vector3 inputDirection = Vector3.zero; switch (controller) { case ControllerType.Keyboard: // keyboard bool inputRegistered = false; if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.Q)) { inputRegistered = true; inputDirection += Vector3.left; } if (Input.GetKey(KeyCode.D)) { inputRegistered = true; inputDirection += Vector3.right; } if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.Z)) { inputRegistered = true; inputDirection += Vector3.forward; } if (Input.GetKey(KeyCode.S)) { inputRegistered = true; inputDirection += Vector3.back; } if (inputRegistered) inputDirection.Normalize(); break; case ControllerType.Gamepad: Debug.LogWarning("Controller: Assigned to gamepad but no code has been written."); break; case ControllerType.SteamController: Debug.LogWarning("Controller: Assigned to SteamController but no code has been written."); break; default: break; } // controller return inputDirection; }
public static bool CheckForAuthorise(this TypeViewer typeViewer, ControllerType controllerType) { var webApiAuthorizeAttributeName = typeof(System.Web.Http.AuthorizeAttribute).Name; var mvcAuthorizeAttributeName = typeof(System.Web.Mvc.AuthorizeAttribute).Name; var attributeToDetect = (controllerType == ControllerType.MVC) ? mvcAuthorizeAttributeName : webApiAuthorizeAttributeName; var classValidation = typeViewer.HasClassAttribute(attributeToDetect); var methodValidation = typeViewer.HasMethodAttribute(attributeToDetect); return classValidation || methodValidation; }
// private CameraController camCont; void Awake() { anim=gameObject.GetComponentInChildren<Animator>(); attacking=false; attacked=false; jmp=false; jumpButton=false; attackButton=false; jumpForce=Mathf.Abs (jumpForce); buttonOffset=Mathf.Abs (buttonOffset); attackWaitTime=Mathf.Abs (attackWaitTime); controllerSelection=ControllerType.Computer; attackTimer=0; b1=0; b2=0; }
public static Csrf CheckForMitigations(this TypeViewer typeViewer, ControllerType controllerType) { const string webApiAntiForgeryAttributeName = "ValidateHttpAntiForgeryTokenAttribute"; var mvcAntiForgeryAttributeName = typeof(System.Web.Mvc.ValidateAntiForgeryTokenAttribute).Name; var attributeToDetect = (controllerType == ControllerType.MVC) ? mvcAntiForgeryAttributeName : webApiAntiForgeryAttributeName; var classValidation = typeViewer.HasClassAttribute(attributeToDetect); var methodValidation = typeViewer.HasMethodAttribute(attributeToDetect); return classValidation ? Csrf.Class : methodValidation ? Csrf.Method : Csrf.None; }
public VSPController(ControllerMode controller_mode, ControllerType controller_type) : base() { BorderStyle = BorderStyle.Fixed3D; //Size = new System.Drawing.Size(340,164); c_VspView = new vspView(c_ScrollBar,controller_mode,controller_type); c_VspView.Size = new System.Drawing.Size(Global.VSP_SIZE_PIXELS,Height-4); c_VspView.Location = new System.Drawing.Point(0,0); c_ScrollBar.Size = new System.Drawing.Size(16,Height-4); c_ScrollBar.Location = new System.Drawing.Point(Global.VSP_SIZE_PIXELS,0); c_ScrollBar.ValueChanged += new EventHandler(c_VspView.OnScroll); Controls.Add(c_VspView); Controls.Add(c_ScrollBar); }
public IInputManager getNewIInputManager(ControllerType type) { switch (type) { case ControllerType.PadOne: return new PadInputManager(PlayerIndex.One); case ControllerType.PadTwo: return new PadInputManager(PlayerIndex.Two); case ControllerType.PadThree: return new PadInputManager(PlayerIndex.Three); case ControllerType.PadFour: return new PadInputManager(PlayerIndex.Four); case ControllerType.Keyboard: default: return new KeyInputManager(); } }
public Controller(ControllerType controllerType) { this.controllerType = controllerType; switch (controllerType) { case ControllerType.PC: this.keyboardControlScheme = new Dictionary<Keys, Controls>(); this.keyboardControlScheme.Add(Keys.Up, Controls.Up); this.keyboardControlScheme.Add(Keys.Down, Controls.Down); this.keyboardControlScheme.Add(Keys.Left, Controls.Left); this.keyboardControlScheme.Add(Keys.Right, Controls.Right); this.keyboardControlScheme.Add(Keys.Escape, Controls.Exit); this.keyboardControlScheme.Add(Keys.Space, Controls.SpeedUp); break; case ControllerType.PC2: this.keyboardControlScheme = new Dictionary<Keys, Controls>(); this.keyboardControlScheme.Add(Keys.W, Controls.Up); this.keyboardControlScheme.Add(Keys.S, Controls.Down); this.keyboardControlScheme.Add(Keys.A, Controls.Left); this.keyboardControlScheme.Add(Keys.D, Controls.Right); this.keyboardControlScheme.Add(Keys.Escape, Controls.Exit); this.keyboardControlScheme.Add(Keys.LeftShift, Controls.SpeedUp); break; case ControllerType.Xbox360: this.xbox360ControlScheme = new Dictionary<Buttons, Controls>(); this.xbox360ControlScheme.Add(Buttons.DPadUp, Controls.Up); this.xbox360ControlScheme.Add(Buttons.DPadDown, Controls.Down); this.xbox360ControlScheme.Add(Buttons.DPadLeft, Controls.Left); this.xbox360ControlScheme.Add(Buttons.DPadRight, Controls.Right); this.xbox360ControlScheme.Add(Buttons.Back, Controls.Exit); this.xbox360ControlScheme.Add(Buttons.RightTrigger, Controls.SpeedUp); break; } this.controlState = new Dictionary<Controls, bool>(); this.controlState.Add(Controls.Up, false); this.controlState.Add(Controls.Down, false); this.controlState.Add(Controls.Left, false); this.controlState.Add(Controls.Right, false); this.controlState.Add(Controls.Exit, false); this.controlState.Add(Controls.SpeedUp, false); }
private void DoBindings(string[] controllerNames) { string name = controllerNames[controllerPort - 1]; if (name.ToLower().Contains("xbox")) { controllerType = ControllerType.Xbox; //Log.Weikie("Assigned xbox controller"); XboxBindings(); } else if (name == "Wireless Controller") { controllerType = ControllerType.Playstation; //commented because seems to work pretty good after 5 hours of testing //Log.Weikie("Assigned playstation controller"); PlaystationBinding(); } else { controllerType = ControllerType.Unknown; Log.Weikie("Unknown controller, go fix. Name is \"" + name + "\""); } }
/// <summary> /// Gets the current up state of the given raw near touch mask with the given controller mask. /// Returns true if any masked near touch was released this frame on any masked controller and no other masked near touch is still down this frame. /// </summary> public static bool GetUp(RawNearTouch rawMask, ControllerType controllerMask) { return OVRManager.input.GetResolvedNearTouchUp(NearTouch.None, rawMask, controllerMask); }
public void SetCharSelected(ControllerType playerController, CharacterSelectionType selection) { LoadingOrSelectionChar(playerController, LastSelectedD[playerController], false); LastSelectedD[playerController] = selection; LoadingOrSelectionChar(playerController, selection, true); }
public NodeController(ControllerType type, short nodeIndex, string nodeName) : this() { Type = type; NodeIndex = nodeIndex; NodeName = nodeName; }
/// <summary> /// Ignores the controller. The controller has no effect on this body. /// </summary> /// <param name="controller">The controller type.</param> public void IgnoreController(ControllerType controller) { ControllerFlags |= controller; }
// Update is called once per frame void Update() { if (this.pv <= 0) { Destroy(gameObject); } if (mining) { if (Time.time - tempsMine > 0.5) { StopMine(); } } if (input.gamepads.Count <= number) { //Debug.Log("No gamepad connected"); this.type = ControllerType.KEYBORD; } else { this.type = ControllerType.CONTROLLER; gamepad = input.gamepads[number]; } //Debug.Log(input.gamepads.Count + " gamepads connected"); HandleMovement(); switch (this.type) { case ControllerType.CONTROLLER: if (gamepad.GetButton(GamepadButton.Action3)) { Mine(); } else if (gamepad.GetTrigger(GamepadTrigger.Right) > 0.8) { Focus(); } else if ((gamepad.GetTrigger(GamepadTrigger.Right) <= 0.8) && focusing) { focusing = false; Shoot(); } if (gamepad.GetButton(GamepadButton.DpadLeft) && !this.previousDLeft) { this.ItemLeft(); } else if (gamepad.GetButton(GamepadButton.DpadRight) && !this.previousDRight) { this.ItemRight(); } this.previousDLeft = gamepad.GetButton(GamepadButton.DpadLeft); this.previousDRight = gamepad.GetButton(GamepadButton.DpadRight); break; case ControllerType.KEYBORD: if (Input.GetMouseButton(1)) { Mine(); } else if (Input.GetMouseButton(0)) { Focus(); } else if (Input.GetMouseButtonUp(0) && focusing) { focusing = false; Shoot(); } if (Input.GetAxis("Mouse ScrollWheel") > 0f) { this.ItemRight(); } else if (Input.GetAxis("Mouse ScrollWheel") < 0f) { this.ItemLeft(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { this.projectilesIndex = 0; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { this.projectilesIndex = 1; } else if (Input.GetKeyDown(KeyCode.Alpha3)) { this.projectilesIndex = 2; } else if (Input.GetKeyDown(KeyCode.Alpha4)) { this.projectilesIndex = 3; } else if (Input.GetKeyDown(KeyCode.Alpha5)) { this.projectilesIndex = 4; } break; } }
private float GetResolvedAxis1D(Axis1D virtualMask, RawAxis1D rawMask, ControllerType controllerMask) { if (!OVRManager.instance.isVRPresent) return 0.0f; float maxAxis = 0.0f; if ((controllerMask & ControllerType.Active) != 0) controllerMask |= activeControllerType; for (int i = 0; i < controllers.Count; i++) { OVRControllerBase controller = controllers[i]; RawAxis1D resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask); if (ShouldResolveController(controller.controllerType, controllerMask)) { if ((RawAxis1D.LIndexTrigger & resolvedMask) != 0) { maxAxis = CalculateMax(maxAxis, controller.currentInputState.LIndexTrigger); } if ((RawAxis1D.RIndexTrigger & resolvedMask) != 0) { maxAxis = CalculateMax(maxAxis, controller.currentInputState.RIndexTrigger); } if ((RawAxis1D.LHandTrigger & resolvedMask) != 0) { maxAxis = CalculateMax(maxAxis, controller.currentInputState.LHandTrigger); } if ((RawAxis1D.RHandTrigger & resolvedMask) != 0) { maxAxis = CalculateMax(maxAxis, controller.currentInputState.RHandTrigger); } } } return maxAxis; }
private bool ContainsType(ControllerType target) { return(((ControllerType)commandTypeProp.intValue & target) == target); }
/// <summary> /// Determines whether this body ignores the the specified controller. /// </summary> /// <param name="controller">The controller type.</param> /// <returns> /// <c>true</c> if the body has the specified flag; otherwise, <c>false</c>. /// </returns> public bool IsControllerIgnored(ControllerType controller) { return((ControllerFlags & controller) == controller); }
// Use this for initialization void Start() { trackedObj = GetComponent <SteamVR_TrackedObject>(); controllerType = Helper.GetControllerType(rightController); }
public SlipController(string id, ControllerType controllerType, PlayStatusType playStatusType) : base(id, controllerType, playStatusType) { this.rnd = new Random(); }
public Controller(ControllerManager manager, ControllerType type = ControllerType.xbox, int index = 0) { this.manager = manager; this.type = type; this.index = index; }
/// <summary> /// This needs to be setup for each joystick type being supported. I have not setup the USB controller or the I:Droid:CON /// For the most part you won't need to modify this section. /// </summary> /// <param name="player"></param> /// <param name="axis"></param> /// <param name="joystick"></param> /// <param name="atype"></param> /// <returns></returns> private static string CheckInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, JoystickType joystick, AnalogTypes atype) { //Debug.Log(string.Format("Player:{0} Axis:{1} Joystick:{2} AnalogType:{3}",player,axis,joystick,atype)); //REF: player1, DPadH, PS3, Dpad //Note: It is your responsibility to make sure that Unity Inputs are setup correctly or you will get an error on your controller. int axisNumber = 0; switch (joystick) { case JoystickType.ps3: //Get The Joystick name from Project Settings --> Input for Controllers #region PS3 Controller if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; case JoystickType.xbox: #region xbox ( usually 360 / untested with normal xbox ) if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.LTRT)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); axisNumber = cType.triggers; return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; case JoystickType.ouya: #region OUYA - Not Tested until I get a bluetooth dongle if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; } //most likely we will never reach here, but If we do Return basic Horizontal Axis return("Horizontal"); }
/// <summary> /// Activates vibration with the given frequency and amplitude with the given controller mask. /// Ignored on controllers that do not support vibration. Expected values range from 0 to 1. /// </summary> public static void SetControllerVibration(float frequency, float amplitude, ControllerType controllerMask) { OVRManager.input.SetControllerVibrationInternal(frequency, amplitude, controllerMask); }
/// <summary> /// Updates the internal state of the OVRInput. Called by OVRManager. /// </summary> public void Update() { if (!OVRManager.instance.isVRPresent) return; connectedControllerTypes = ControllerType.None; for (int i = 0; i < controllers.Count; i++) { connectedControllerTypes |= controllers[i].Update(); if (Get(RawButton.Any, controllers[i].controllerType)) { activeControllerType = controllers[i].controllerType; } } if ((activeControllerType == ControllerType.LTouch) || (activeControllerType == ControllerType.RTouch)) { // If either Touch controller is Active, set both to Active. activeControllerType = ControllerType.Touch; } if ((connectedControllerTypes & activeControllerType) == 0) { activeControllerType = ControllerType.None; } }
/// <summary> /// Restore the controller. The controller affects this body. /// </summary> /// <param name="controller">The controller type.</param> public void RestoreController(ControllerType controller) { ControllerFlags &= ~controller; }
private Vector2 GetResolvedAxis2D(Axis2D virtualMask, RawAxis2D rawMask, ControllerType controllerMask) { if (!OVRManager.instance.isVRPresent) return Vector2.zero; Vector2 maxAxis = Vector2.zero; if ((controllerMask & ControllerType.Active) != 0) controllerMask |= activeControllerType; for (int i = 0; i < controllers.Count; i++) { OVRControllerBase controller = controllers[i]; RawAxis2D resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask); if (ShouldResolveController(controller.controllerType, controllerMask)) { if ((RawAxis2D.LThumbstick & resolvedMask) != 0) { Vector2 axis = new Vector2( controller.currentInputState.LThumbstick.x, controller.currentInputState.LThumbstick.y); maxAxis = CalculateMax(maxAxis, axis); } if ((RawAxis2D.RThumbstick & resolvedMask) != 0) { Vector2 axis = new Vector2( controller.currentInputState.RThumbstick.x, controller.currentInputState.RThumbstick.y); maxAxis = CalculateMax(maxAxis, axis); } } } return maxAxis; }
private bool GetResolvedButtonUp(Button virtualMask, RawButton rawMask, ControllerType controllerMask) { if (!OVRManager.instance.isVRPresent) return false; bool up = false; if ((controllerMask & ControllerType.Active) != 0) controllerMask |= activeControllerType; for (int i = 0; i < controllers.Count; i++) { OVRControllerBase controller = controllers[i]; if (ShouldResolveController(controller.controllerType, controllerMask)) { RawButton resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask); if (((RawButton)controller.currentInputState.Buttons & resolvedMask) != 0) { return false; } if ((((RawButton)controller.currentInputState.Buttons & resolvedMask) == 0) && (((RawButton)controller.previousInputState.Buttons & resolvedMask) != 0)) { up = true; } } } return up; }
private bool GetResolvedNearTouchDown(NearTouch virtualMask, RawNearTouch rawMask, ControllerType controllerMask) { if (!OVRManager.instance.isVRPresent) return false; bool down = false; if ((controllerMask & ControllerType.Active) != 0) controllerMask |= activeControllerType; for (int i = 0; i < controllers.Count; i++) { OVRControllerBase controller = controllers[i]; if (ShouldResolveController(controller.controllerType, controllerMask)) { RawNearTouch resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask); if (((RawNearTouch)controller.previousInputState.NearTouches & resolvedMask) != 0) { return false; } if ((((RawNearTouch)controller.currentInputState.NearTouches & resolvedMask) != 0) && (((RawNearTouch)controller.previousInputState.NearTouches & resolvedMask) == 0)) { down = true; } } } return down; }
private static void SearchWiiController(WiiControllerFoundDelegate wiiControllerFound, ControllerType controllerType, bool breakIfFoundOne = false) { int index = 0; bool found = false; Guid guid; SafeFileHandle handle; // get the GUID of the HID class HIDImports.HidD_GetHidGuid(out guid); // get a handle to all devices that are part of the HID class // Fun fact: DIGCF_PRESENT worked on my machine just fine. I reinstalled Vista, and now it no longer finds the WiiController with that parameter enabled... IntPtr hDevInfo = HIDImports.SetupDiGetClassDevs(ref guid, null, IntPtr.Zero, HIDImports.DIGCF_DEVICEINTERFACE);// | HIDImports.DIGCF_PRESENT); // create a new interface data struct and initialize its size HIDImports.SP_DEVICE_INTERFACE_DATA diData = new HIDImports.SP_DEVICE_INTERFACE_DATA(); diData.cbSize = Marshal.SizeOf(diData); // get a device interface to a single device (enumerate all devices) while (HIDImports.SetupDiEnumDeviceInterfaces(hDevInfo, IntPtr.Zero, ref guid, index, ref diData)) { UInt32 size; // get the buffer size for this device detail instance (returned in the size parameter) HIDImports.SetupDiGetDeviceInterfaceDetail(hDevInfo, ref diData, IntPtr.Zero, 0, out size, IntPtr.Zero); // create a detail struct and set its size HIDImports.SP_DEVICE_INTERFACE_DETAIL_DATA diDetail = new HIDImports.SP_DEVICE_INTERFACE_DETAIL_DATA(); // on Win x86, cbSize must be 5 for some reason. On x64, apparently 8 is what it wants. diDetail.cbSize = (uint)(IntPtr.Size == 8 ? 8 : 5); // actually get the detail struct if (HIDImports.SetupDiGetDeviceInterfaceDetail(hDevInfo, ref diData, ref diDetail, size, out size, IntPtr.Zero)) { Debug.WriteLine(string.Format("{0}: {1} - {2}", index, diDetail.DevicePath, Marshal.GetLastWin32Error())); // open a read/write handle to our device using the DevicePath returned bool closeHandle = true; handle = HIDImports.CreateFile(diDetail.DevicePath, FileAccess.ReadWrite, FileShare.ReadWrite, IntPtr.Zero, FileMode.Open, HIDImports.EFileAttributes.Overlapped, IntPtr.Zero); // create an attributes struct and initialize the size HIDImports.HIDD_ATTRIBUTES attrib = new HIDImports.HIDD_ATTRIBUTES(); attrib.Size = Marshal.SizeOf(attrib); // get the attributes of the current device if (HIDImports.HidD_GetAttributes(handle.DangerousGetHandle(), ref attrib)) { // if the vendor and product IDs match up if (attrib.VendorID == WiiInputManager.VID) { if (attrib.ProductID == WiiInputManager.PID_old || attrib.ProductID == WiiInputManager.PID_new) { found = CheckWiiControllerType(handle, controllerType, diDetail, wiiControllerFound); if (found) { // it's the right WiiController Debug.WriteLine("Found one and open!"); } // stop at first found if (breakIfFoundOne) { break; } // dont close the handle closeHandle = false; } } } if (closeHandle) { handle.Close(); } } else { // failed to get the detail struct throw new WiiControllerException("SetupDiGetDeviceInterfaceDetail failed on index " + index); } // move to the next device index++; } // clean up our list HIDImports.SetupDiDestroyDeviceInfoList(hDevInfo); // if we didn't find a WiiController, throw an exception if (!found) { throw new WiiControllerNotFoundException("No WiiControllers found in HID device list."); } }