![]() |
Angel
A 2D Game Prototyping Engine
|
A class representing a gamepad controller. More...
#include <Controller.h>
Public Member Functions | |
| void | Setup () |
| void | UpdateState () |
| const ControllerInput | GetState () |
| const Vector2 | GetLeftThumbVec2 () |
| const Vector2 | GetRightThumbVec2 () |
| const Vec2i | GetLeftThumbstick () |
| const Vec2i | GetRightThumbstick () |
| const int | GetRightTrigger () |
| const int | GetLeftTrigger () |
| const bool | IsButtonDown (int buttonMask) |
| const bool | IsAButtonDown () |
| const bool | IsBButtonDown () |
| const bool | IsXButtonDown () |
| const bool | IsYButtonDown () |
| const bool | IsLeftThumbstickButtonDown () |
| const bool | IsRightThumbstickButtonDown () |
| const bool | IsStartButtonDown () |
| const bool | IsBackButtonDown () |
| const bool | IsLeftBumperDown () |
| const bool | IsRightBumperDown () |
| const bool | IsLeftTriggerPressed () |
| const bool | IsRightTriggerPressed () |
| void | SetLeftVibrationRaw (unsigned int vibration) |
| void | SetRightVibrationRaw (unsigned int vibration) |
| void | SetLeftVibration (unsigned int vibration) |
| void | SetRightVibration (unsigned int vibration) |
| const unsigned int | GetLeftVibration () |
| const unsigned int | GetRightVibration () |
| const bool | IsConnected () |
| const int | GetControllerID () |
Static Protected Attributes | |
| static Controller * | s_Controller = NULL |
Friends | |
| class | ControllerManager |
This class is your means of getting data from a controller. At the moment we only test and support the Xbox 360 controller over USB, but this interface could be abstracted to support other controllers.
On Windows you'll need DirectX installed to play a game made with Angel, and the DirectX SDK to develop one. A pretty big download/install just to get access to a controller, but we figure most gamers/developers have already done so anyway.
On the Mac both players and developers need to install a kernel extension (sorry!) included in the Tools directory. We'd be more than happy to remove this requirement, but unless someone who knows more about how to use IOKit and raw USB values wants to help, this is what we've got.
Definition at line 163 of file Controller.h.
| void Controller::Setup | ( | ) |
Sets the controller up to read data every frame. If it's successful, the Controller::IsConnected function will return true.
Definition at line 139 of file Controller.cpp.
| void Controller::UpdateState | ( | ) |
Called once per frame to read the data in from the controller. Called automatically by the ControllerManager.
Definition at line 292 of file Controller.cpp.
| const ControllerInput Controller::GetState | ( | ) |
Directly access all current input on the controller.
Definition at line 492 of file Controller.cpp.
| const Vector2 Controller::GetLeftThumbVec2 | ( | ) |
Get the X and Y positions of the left thumbstick as a Vector2.
Definition at line 497 of file Controller.cpp.
| const Vector2 Controller::GetRightThumbVec2 | ( | ) |
Get the X and Y positions of the right thumbstick as a Vector2.
Definition at line 505 of file Controller.cpp.
| const Vec2i Controller::GetLeftThumbstick | ( | ) |
Get the raw values of the left thumbstick as an integer vector.
Definition at line 513 of file Controller.cpp.
| const Vec2i Controller::GetRightThumbstick | ( | ) |
Get the raw values of the right thumbstick as an integer vector.
Definition at line 520 of file Controller.cpp.
| const int Controller::GetRightTrigger | ( | ) |
Get the current value of the right trigger.
Definition at line 528 of file Controller.cpp.
| const int Controller::GetLeftTrigger | ( | ) |
Get the current value of the left trigger.
Definition at line 533 of file Controller.cpp.
| const bool Controller::IsButtonDown | ( | int | buttonMask | ) |
Pass a button mask to find out if a combination of buttons is depressed at the same time. Here are the mask values:
#define XINPUT_GAMEPAD_DPAD_UP 0x00000001 #define XINPUT_GAMEPAD_DPAD_DOWN 0x00000002 #define XINPUT_GAMEPAD_DPAD_LEFT 0x00000004 #define XINPUT_GAMEPAD_DPAD_RIGHT 0x00000008 #define XINPUT_GAMEPAD_START 0x00000010 #define XINPUT_GAMEPAD_BACK 0x00000020 #define XINPUT_GAMEPAD_LEFT_THUMB 0x00000040 #define XINPUT_GAMEPAD_RIGHT_THUMB 0x00000080 #define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 #define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 #define XINPUT_GAMEPAD_A 0x1000 #define XINPUT_GAMEPAD_B 0x2000 #define XINPUT_GAMEPAD_X 0x4000 #define XINPUT_GAMEPAD_Y 0x8000
| buttonMask | The values you care about, combined as a bitmask |
Definition at line 538 of file Controller.cpp.
| const bool Controller::IsAButtonDown | ( | ) |
Find out if the A button is currently pressed.
Definition at line 543 of file Controller.cpp.
| const bool Controller::IsBButtonDown | ( | ) |
Find out if the B button is currently pressed.
Definition at line 555 of file Controller.cpp.
| const bool Controller::IsXButtonDown | ( | ) |
Find out if the X button is currently pressed.
Definition at line 567 of file Controller.cpp.
| const bool Controller::IsYButtonDown | ( | ) |
Find out if the Y button is currently pressed.
Definition at line 579 of file Controller.cpp.
| const bool Controller::IsLeftThumbstickButtonDown | ( | ) |
Find out if the left thumbstick is currently pressed down.
Definition at line 591 of file Controller.cpp.
| const bool Controller::IsRightThumbstickButtonDown | ( | ) |
Find out if the right thumbstick is currently pressed down.
Definition at line 603 of file Controller.cpp.
| const bool Controller::IsStartButtonDown | ( | ) |
Find out if the start button is currently pressed.
Definition at line 615 of file Controller.cpp.
| const bool Controller::IsBackButtonDown | ( | ) |
Find out if the back button is currently pressed.
Definition at line 627 of file Controller.cpp.
| const bool Controller::IsLeftBumperDown | ( | ) |
Find out if the left shoulder button is currently pressed.
Definition at line 639 of file Controller.cpp.
| const bool Controller::IsRightBumperDown | ( | ) |
Find out if the right shoulder button is currently pressed.
Definition at line 651 of file Controller.cpp.
| const bool Controller::IsLeftTriggerPressed | ( | ) |
Find out if the left trigger is pressed down. Since it's an analog trigger, there's a driver-defined threshold that this function will use to determine when it can be considered "activated."
Definition at line 663 of file Controller.cpp.
| const bool Controller::IsRightTriggerPressed | ( | ) |
Find out if the left trigger is pressed down. Since it's an analog trigger, there's a driver-defined threshold that this function will use to determine when it can be considered "activated."
Definition at line 675 of file Controller.cpp.
| void Controller::SetLeftVibrationRaw | ( | unsigned int | vibration | ) |
Set the rumble of the controller's lower frequencies. This sets the raw driver value.
Not available on Mac OS X. :-(
| frequencies | The desired intensity, ranging from 0 to 65535. |
Definition at line 698 of file Controller.cpp.
| void Controller::SetRightVibrationRaw | ( | unsigned int | vibration | ) |
Set the rumble of the controller's higher frequencies. This sets the raw driver value.
Not available on Mac OS X. :-(
| frequencies | The desired intensity, ranging from 0 to 65535. |
Definition at line 724 of file Controller.cpp.
| void Controller::SetLeftVibration | ( | unsigned int | vibration | ) |
Set the rumble of the controller's lower frequencies. This uses more manageable numbers if you don't feel like dealing with INT_MAX.
Not available on Mac OS X. :-(
| frequencies | The desired intensity, ranging from 0 to 255. |
Definition at line 750 of file Controller.cpp.
| void Controller::SetRightVibration | ( | unsigned int | vibration | ) |
Set the rumble of the controller's higher frequencies. This uses more manageable numbers if you don't feel like dealing with INT_MAX.
Not available on Mac OS X. :-(
| frequencies | The desired intensity, ranging from 0 to 255. |
Definition at line 763 of file Controller.cpp.
| const unsigned int Controller::GetLeftVibration | ( | ) |
Get the current vibration setting for the lower frequencies.
Definition at line 688 of file Controller.cpp.
| const unsigned int Controller::GetRightVibration | ( | ) |
Get the current vibration setting for the higher frequencies.
Definition at line 693 of file Controller.cpp.
| const bool Controller::IsConnected | ( | ) | [inline] |
Find out if this controller object is currently mapped to a real-world controller and receiving input.
Definition at line 414 of file Controller.h.
| const int Controller::GetControllerID | ( | ) | [inline] |
Get the index this controller corresponds to in the ControllerManager.
Definition at line 421 of file Controller.h.


1.7.5.1