Gateware Libraries  R6.5A
Beta Build
GController.h
1 #ifndef GCONTROLLER_H
2 #define GCONTROLLER_H
3 
15 #include "../G_Core/GBroadcasting.h"
17 #include "../G_System/GControllerInputDefines.h"
18 
20 namespace GW
21 {
23  namespace SYSTEM
24  {
25 
26 
28 #pragma pack(push, 1)
29 
31  /*
32  * If the corresponding event is an Input Event inputCode and inputValue will contain the input code and value
33  * respectively for the detected input. If the corresponding event is an Connection event inputCode and inputValue will be 0.
34  * isConnected will be 0 for false and 1 for true.
35  *
36  */
38  {
41  int inputCode;
42  float inputValue;
44  };
45 #pragma pack(pop)
46 
49  {
54  };
55 
58  {
61  };
62 
64  static const GUUIID GControllerUUIID =
65  {
66  0xdff7eebf, 0xc333, 0x4606,{ 0x95, 0x0, 0xbd, 0xe0, 0x1c, 0xe7, 0xc1, 0xcb }
67  };
68 
69 
71 
78  {
79  public:
81  /*
82  * Use an Inputcode to check the state of a button or axis on the controller
83  * at the selected index. If a button is being checked the _outState will be 0 for
84  * up and 1 for down. If a axis is being checked the _outState will be between -1 and 1 inclusively.
85  *
86  * \param [in] _controllerIndex The controller index to check
87  * \param [in] _inputCode The input code for the button/axis to check
88  * \param [out] _outState Is a reference to a float to store the state.
89  *
90  * \retval SUCCESS The button/axis state was was successfully stored in the out-param
91  * \retval FAILURE No controller is connected at the chosen index.
92  * \retval INVALID_ARGUMENT Ether _controllerIndex is out of range or _inputCode is invaild.
93  */
94  virtual GReturn GetState(int _controllerIndex, int _inputCode, float& _outState) = 0;
95 
97  /*
98  * \param [in] _controllerIndex The controller index to check.
99  * \param [out] _outIsConnected Is a reference to a bool to store whether a controller is at the index.
100  *
101  * \retval SUCCESS The out-param was successfully filled out
102  * \retval INVALID_ARGUMENT _controllerIndex was out of range.
103  */
104  virtual GReturn IsConnected(int _controllerIndex, bool& _outIsConnected) = 0;
105 
107  /*
108  * The controllers will be stored in a constant array where the size of the array
109  * is the maxium amnout of supported controllers.
110  *
111  * \param [out] _outMax is a reference to a int to store the max index.
112  *
113  * \retval SUCCESS The max index was successfully stored in the out-param
114  */
115  virtual GReturn GetMaxIndex(int &_outMax) = 0;
116 
118  /*
119  * The number returned will be how many controllers are currently stored in the
120  * controller array.
121  *
122  * \param [out] _outConnectedCount is a reference to a int to store the count of connected controllers
123  *
124  * \retval SUCCESS The count of connected controllers was successfully stored in the out-param
125  */
126  virtual GReturn GetNumConnected(int &_outConnectedCount) = 0;
127 
129  /*
130  * Default deadzone is _type = DEADZONESQUARE, _deadzonePercentage = .2f
131  *
132  * \param [in] _type Specifies the dead zone calculation to be used.
133  * \param [in] _deadzonePercentage The size of the deadzone.
134  *
135  * \retval SUCCESS The deadzone was set to the new parameters
136  * \retval INVALID_ARGUMENT _deadzonePercentage is invaild
137  */
138  virtual GReturn SetDeadZone(GControllerDeadzoneTypes _type, float _deadzonePercentage) = 0;
139 
141  /*
142  * This will not replace a currently running vibration, the previous vibration must end or be stopped first.
143  * Controllers have diffrent start up times and strengths this method does not account for this.
144  *
145  * \param [in] _pan is a -1 to 1 ratio where -1 is full left motor, 1 is full right motor.
146  * \param [in] _duration In seconds how long the vibration will run.
147  * \param [in] _strength 0 to 1 ratio of how strong the vibration will be.
148  * \param [in] _controllerIndex The controller to vibrate.
149  *
150  * \retval SUCCESS The vibration has been started in the selected controller.
151  * \retval INVALID_ARGUMENT One or more arguments are out of range.
152  * \retval FAILURE Controller is currently vibrating.
153  * \retval FEATURE_UNSUPPORTED Vibration for the current controller type is not supported.
154  */
155  virtual GReturn StartVibration(float _pan, float _duration, float _strength, unsigned int _controllerIndex) = 0;
156 
158  /*
159  * \param [in] _controllerIndex The controller index to check.
160  * \param [out] _outIsVibrating Is a reference to a bool to store whether a controller is vibrating.
161  *
162  * \retval SUCCESS The out-param was successfully filled out
163  * \retval INVALID_ARGUMENT _controllerIndex was out of range.
164  * \retval FEATURE_UNSUPPORTED Vibration for the current controller type is not supported.
165  */
166  virtual GReturn IsVibrating(unsigned int _controllerIndex, bool& _outIsVibrating) = 0;
167 
169  /*
170  * \param [in] _controllerIndex The controller index to stop
171  *
172  * \retval SUCCESS The virbration was stop
173  * \retval INVALID_ARGUMENT _controllerIndex was out of range.
174  * \retval REDUNDANT_OPERATION The controller was not vibrating.
175  * \retval FEATURE_UNSUPPORTED Vibration for the current controller type is not supported.
176  */
177  virtual GReturn StopVirbration(unsigned int _controllerIndex) = 0;
178 
180  /*
181  * \retval SUCCESS All vibrations were stopped
182  * \retval FEATURE_UNSUPPORTED Vibration for the current controller type is not supported.
183  */
184  virtual GReturn StopAllVirbrations() = 0;
185 
186  }; //end GController class
187 
189  /*
190  * Initializes a handle to a GConntroller object of the type specified.
191  * Created GConntroller object will have its reference count initialized to one.
192  *
193  * \param [in] _controllerType The type of Controller to be supported
194  * \param [out] _outController Will contain GConntroller object if successfully created.
195  *
196  * \retval SUCCESS GConntroller was successfully created
197  * \retval FAILURE GConntroller was not created. _outController will be NULL.
198  * \retval INVALID_ARGUMENT _controllerType is invaild or GController is NULL.
199  * \retval FEATURE_UNSUPPORTED _controllerType is not currently supported. _outController will be NULL.
200  */
201  GATEWARE_EXPORT_IMPLICIT GReturn CreateGController(int _controllerType, GController** _outController);
202  } // end of SYSTEM namespace
203 } // end of GW namespace
204 #endif
205 
The GBroadcasting Interface is capable of registering & deregistering GListener interfaces.
Definition: GBroadcasting.h:36
virtual GReturn StopAllVirbrations()=0
Stops all currently vibrating controllers.
A multi-threaded controller input library.
Definition: GController.h:77
GATEWARE_EXPORT_IMPLICIT GReturn CreateGController(int _controllerType, GController **_outController)
Creates a new GController object.
GControllerDeadzoneTypes
GControllerDeadzoneTypes holds the diffrent type of deadzone calculations.
Definition: GController.h:57
virtual GReturn IsVibrating(unsigned int _controllerIndex, bool &_outIsVibrating)=0
Used to check if a controller is currently vibrating.
float inputValue
Definition: GController.h:42
virtual GReturn GetNumConnected(int &_outConnectedCount)=0
Outputs the number of controllers connected.
virtual GReturn GetState(int _controllerIndex, int _inputCode, float &_outState)=0
Used to poll the current state of a button or axis on a controller.
virtual GReturn StopVirbration(unsigned int _controllerIndex)=0
Used to stop a controller from vibrating.
Definition: GController.h:52
virtual GReturn SetDeadZone(GControllerDeadzoneTypes _type, float _deadzonePercentage)=0
Set how the stick deadzones should be calculated.
int isConnected
Definition: GController.h:43
int inputCode
Definition: GController.h:41
Gateware Universally Unique Interface IDentifier.
Definition: GDefines.h:25
virtual GReturn GetMaxIndex(int &_outMax)=0
Outputs the max index of the array of controllers.
virtual GReturn IsConnected(int _controllerIndex, bool &_outIsConnected)=0
Used to check if a controller is connected at a specified index.
Definition: GController.h:59
Definition: GController.h:51
virtual GReturn StartVibration(float _pan, float _duration, float _strength, unsigned int _controllerIndex)=0
Start vibration in selected controller.
Definition: GController.h:53
GControllerEvents
GControllerEvents holds the possible events that can be sent from GController.
Definition: GController.h:48
int controllerID
Definition: GController.h:40
int controllerIndex
Definition: GController.h:39
Ensure identical binary padding for structures on all platforms.
Definition: GController.h:37
The core namespace to which all Gateware interfaces/structures/defines must belong.
Definition: GAudio.h:20
Definition: GController.h:60
Definition: GController.h:50
GReturn
Listing of common error codes returned by Gateware functions.
Definition: GDefines.h:53