How to Use

Setting up

First thing you'll have to do is to add the DLL to your references. You can do that by right clicking on "References" in the project explorer, selecting "Add Reference," and then browsing to the DLL. Now you can add the using directive ("using OXClib;") to the classes you want to use the controller in.

Initialization and Configuration

To initialize the OldGamePad controller, add "OldGamePad.Initialize(this) to the game's Initialize()-method.

Initialize() { .Initialize(); ... .Initialize(); }

After that the controller is ready to go and works very similar to the normal GamePad. But depending on the codec and controller settings, the button mapping might differ from user to user. This controller configuration can be set by accessing the config directly through OldGamePad.Config or by loading a config file.

Initialize() { .Initialize(); .Config.DPadUp = 13; .Config.DPadDown = 14; .Config.DPadLeft = 15; .Config.DPadRight = 16; .Config = (); config = (); .Initialize(, config); ... .Initialize(); }

The config file's structure is pretty simple:

A:1 B:2 X:3 Y:4 Black:5 White:6 Start:9 Back:10 LeftStick:11 RightStick:12 DPadUp:13 DPadDown:14 DPadLeft:15 DPadRight:16 LeftShoulder:0 RightShoulder:0 LeftThumbStickUp:0 LeftThumbStickDown:0 LeftThumbStickLeft:0 LeftThumbStickRight:0 RightThumbStickUp:0 RightThumbStickDown:0 RightThumbStickLeft:0 RightThumbStickRight:0

All values not specified will be set to zero, so you don't have to include items that don't have a digital button state. This, by the way, is the standard configuration, which will be used if you don't change anything.

Using the Controller

The OldGamePad works pretty much the same way the normal GamePad does, so this part should be rather intuitive. Still, here's an example:

previousState, currentState; position; Update( gameTime) { previousState = currentState; currentState = .GetState(.One, .IndependentAxes); (currentState.Buttons.Back == .Pressed && previousState.Buttons.Back == .Released) .Exit(); position += .GetState(.One).ThumbSticks.Left; ... }

Vibration

The vibration works slightly different than the GamePad's. For one thing, you currently can't apply individual speeds to the two motors, but you can set the duration of the vibration (in milliseconds). The default duration is 250ms.

previousState, currentState; Update( gameTime) { previousState = currentState; currentState = .GetState(.One); (currentState.Buttons.A == .Pressed) .SetVibration(.One, 0.5f); (currentState.Buttons.B == .Pressed && previousState.Buttons.B == .Released) .SetVibration(.One, 1f, 1000); ... }

Updating the Devices

In order for the OldGamePad to recognize new connections, it has to be updated. That happens automatically by default, but since this is a rather slow process, it only happens every 20 calls. This is a value that worked more than well for me, but if it should slow your game down or you want to shorten the delay, you can adjust it easily to your own value by specifing OldGamePad().UpdateInterval.

Initialize() { .Initialize(); .UpdateInterval = 10; ... }

You can also disable automatic connection recognition and check manually by calling OldGamePad.Update() whenever you see fit.

Initialize() { .Initialize(); .UpdateInterval = 0; ... } Update( gameTime) { (!.GetState(.One).IsConnected) { .Update(); } ... }