internal void Update() { //See PSS GamePadSample for details try { var gamePadData = PssGamePad.GetData(0); //map the buttons foreach (var kvp in _buttonsMap) { if ((gamePadData.Buttons & kvp.Key) != 0) { _buttons |= (int)kvp.Value; } } //Analog sticks _leftStick = new Vector2(gamePadData.AnalogLeftX, -gamePadData.AnalogLeftY); _rightStick = new Vector2(gamePadData.AnalogRightX, -gamePadData.AnalogRightY); } catch (Sce.PlayStation.Core.InputSystemException exc) { if (exc.Message.ToLowerInvariant().Trim() == "native function returned error.") { throw new InvalidOperationException("GamePad must be listed in your features list in app.xml in order to use the GamePad API on PlayStation Mobile.", exc); } else { throw; } } }
private static GamePadState PlatformGetState(int index, GamePadDeadZone deadZoneMode) { // PSM only has a single player game pad. if (index != 0) { return(new GamePadState()); } //See PSS GamePadSample for details var buttons = 0; var leftStick = Vector2.Zero; var rightStick = Vector2.Zero; try { var gamePadData = PssGamePad.GetData(0); //map the buttons foreach (var kvp in _buttonsMap) { if ((gamePadData.Buttons & kvp.Key) != 0) { buttons |= (int)kvp.Value; } } //Analog sticks leftStick = new Vector2(gamePadData.AnalogLeftX, -gamePadData.AnalogLeftY); rightStick = new Vector2(gamePadData.AnalogRightX, -gamePadData.AnalogRightY); } catch (Sce.PlayStation.Core.InputSystemException exc) { if (exc.Message.ToLowerInvariant().Trim() == "native function returned error.") { throw new InvalidOperationException("GamePad must be listed in your features list in app.xml in order to use the GamePad API on PlayStation Mobile.", exc); } else { throw; } } var state = new GamePadState(new GamePadThumbSticks(leftStick, rightStick, deadZoneMode), new GamePadTriggers(), new GamePadButtons((Buttons)buttons), new GamePadDPad((Buttons)buttons)); return(state); }
internal void Update() { //See PSS GamePadSample for details var gamePadData = PssGamePad.GetData(0); //map the buttons foreach (var kvp in _buttonsMap) { if ((gamePadData.Buttons & kvp.Key) != 0) { _buttons |= (int)kvp.Value; } } //Analog sticks _leftStick = new Vector2(gamePadData.AnalogLeftX, gamePadData.AnalogLeftY); _rightStick = new Vector2(gamePadData.AnalogRightX, gamePadData.AnalogRightY); }