public static void Initialize() { for (var i = 0; i < MAX_GAMEPADS; i++) { OpenTKGamePad.GetState(i); // not sure if this is important to do at this time, but the processing which used to be done here included calls to OpenTK, so I left this no-op just in case --yoshi } initialized = true; }
public void Update() { // update both here just in case var tmpState = OpenTKGamePad.GetState(_deviceIndex); DebugState(tmpState); state = tmpState; var tmpJstate = Joystick.GetState(_deviceIndex); DebugState(tmpJstate); jState = tmpJstate; }
/// <remarks>Initialization is only called once when MainForm loads</remarks> public static void Initialize() { CloseAll(); var playerCount = 0; for (var i = 0; i < MAX_GAMEPADS; i++) { if (OpenTKGamePad.GetState(i).IsConnected || Joystick.GetState(i).IsConnected) { Console.WriteLine($"OTK GamePad/Joystick index: {i}"); Devices.Add(new OTK_GamePad(i, ++playerCount)); } } }
private OTK_GamePad(int index, int playerIndex) { _deviceIndex = index; _playerIndex = playerIndex; if (Joystick.GetState(_deviceIndex).IsConnected) { Guid = Joystick.GetGuid(_deviceIndex); _guidObtained = true; _joystickCapabilities = Joystick.GetCapabilities(_deviceIndex); } else { Guid = Guid.NewGuid(); _guidObtained = false; } if (OpenTKGamePad.GetState(_deviceIndex).IsConnected) { _name = OpenTKGamePad.GetName(_deviceIndex); _gamePadCapabilities = OpenTKGamePad.GetCapabilities(_deviceIndex); } else { _name = "OTK GamePad Undetermined Name"; } InputNamePrefix = $"{(MappedGamePad ? "X" : "J")}{_playerIndex} "; Update(); Console.WriteLine($"Initialising OpenTK GamePad: {Guid}"); Console.WriteLine($"OpenTK Mapping: {_name}"); InitializeMappings(); }
public static List <Buttons> GetPressedDPadButtons(int controllerIndex) { return(GetPressedDPadButtons(OTKGamePad.GetState(controllerIndex))); }
/// <summary> /// Sets the gamepad's left and right vibration /// We don't currently use this in Bizhawk - do we have any cores that support this? /// </summary> /// <param name="left"></param> /// <param name="right"></param> public void SetVibration(float left, float right) => OpenTKGamePad.SetVibration( _deviceIndex, _gamePadCapabilities?.HasLeftVibrationMotor == true ? left : 0, _gamePadCapabilities?.HasRightVibrationMotor == true ? right : 0 );