Game Development Reference
In-Depth Information
DrawButtonPoint(_controller.ButtonX.Held, 260);
DrawButtonPoint(_controller.ButtonY.Held, 240);
DrawButtonPoint(_controller.ButtonLB.Held, 220);
DrawButtonPoint(_controller.ButtonRB.Held, 200);
DrawButtonPoint(_controller.ButtonBack.Held, 180);
DrawButtonPoint(_controller.ButtonStart.Held, 160);
DrawButtonPoint(_controller.ButtonL3.Held, 140);
DrawButtonPoint(_controller.ButtonR3.Held, 120);
Run the test state and the now the buttons and axes are both displayed on the
screen. Each button pressed will be represented visually on screen.
There are only two types of controls left that need to be handled—the
trigger buttons and the D-pad. The triggers are actually represented by a single
axis—the left trigger represents 0 to 1 on the axis and the right trigger represents
0 to -1. This means the code to wrap the trigger can be quite similar to the
control pad.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tao.Sdl;
namespace Engine
{
public class ControlTrigger
{
IntPtr _joystick;
int _index;
bool _top = false; // The triggers are treated as axes and need split-
ting up
float _deadZone = 0.24f;
public float Value { get; private set; }
public ControlTrigger(IntPtr joystick, int index, bool top)
{
_joystick = joystick;
_index = index;
_top = top;
}
 
Search WWH ::




Custom Search