public void PollChanges(iGameClient GameCli) { //polls changes in this controller from the previous poll and raises //appropriate events in iGameClient depending on the differences. if (!haspolled) { haspolled=true; ourdevice.Poll(); laststate = ourdevice.CurrentJoystickState; return; } laststate = ourdevice.CurrentJoystickState; ourdevice.Poll(); byte[] prevbuttons = laststate.GetButtons(); byte[] currbuttons = ourdevice.CurrentJoystickState.GetButtons(); }
public void Initialize(iGameClient gamecli) { useClient = gamecli; DeviceList GameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); if (GameControllerList.Count > 0) { GameControllerList.MoveNext(); DeviceInstance deviceInstance = (DeviceInstance) GameControllerList.Current; // create a device from this controller. Device jDevice = new Device(deviceInstance.InstanceGuid); jDevice.SetCooperativeLevel(useClient.Handle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive); joysticks.Add(new JoystickDevice(jDevice)); } }