50 #include "rnr/rnrconfig.h" 56 #include <gtest/gtest.h> 78 LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
82 if( (rc = pXbox->
open()) < 0 )
84 LOGERROR(
"Failed to open Xbox360 controller.");
87 else if( !pXbox->
ping() )
89 LOGERROR(
"Failed to ping Xbox360 controller.");
116 int bttnFail = bttnSuccess + 1;
120 LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
124 if( (rc = xbox.
open()) < 0 )
126 LOGERROR(
"Failed to open Xbox360 controller.");
134 "\nTesting Xbox360 Input Interface.\n" 135 " Press the Xbox 'X' button to terminate test with success.\n" 136 " Press the Xbox 'Y' button to terminate test with failure.\n\n");
142 if( (rc = xbox.
update()) < 0 )
144 LOGERROR(
"Failed to update Xbox360 controller state.");
162 fprintf(stderr,
"\n\n");
175 int bttnFail = bttnSuccess + 1;
176 int nLeftTrigger = 0;
177 int nRightTrigger = 0;
179 int nRightRumble = 0;
183 LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
187 if( (rc = xbox.
open()) < 0 )
189 LOGERROR(
"Failed to open Xbox360 controller.");
197 "\nTesting Xbox360 Rumble Interface.\n" 198 " Squeeze left (right) trigger for left (right) rumble motor.\n" 199 " Press the Xbox 'X' button to terminate test with success.\n" 200 " Press the Xbox 'Y' button to terminate test with failure.\n\n");
206 if( (rc = xbox.
update()) < 0 )
208 LOGERROR(
"Failed to update Xbox360 controller state.");
231 if( (nLeftTrigger != nLeftRumble) || (nRightTrigger != nRightRumble) )
233 xbox.
setRumble(nLeftTrigger, nRightTrigger);
238 fprintf(stderr,
"\n\n");
251 int bttnFail = bttnSuccess + 1;
258 LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
262 if( (rc = xbox.
open()) < 0 )
264 LOGERROR(
"Failed to open Xbox360 controller.");
272 "\nTesting Xbox360 LED Interface.\n" 273 " Press left (right) bumper to increment (decrement) the LED pattern.\n" 274 " Press the Xbox 'X' button to terminate test with success.\n" 275 " Press the Xbox 'Y' button to terminate test with failure.\n\n");
281 if( (rc = xbox.
update()) < 0 )
283 LOGERROR(
"Failed to update Xbox360 controller state.");
321 fprintf(stderr,
"\n\n");
virtual int close()
Close connection to an opened USB Xbox360 controller.
virtual int open()
Open connection to an USB Xbox360 controller.
void debugPrintState()
Simple debug print state.
Xbox360 Controller C interface.
virtual bool ping()
Ping device if it is connected and is responding.
Common Human Interface Device Interface.
static int testXboxRumble()
Tactically test Xbox rumble interface.
void debugPrintHdr()
Simple debug print header.
int setRumble(int nLeftMot, int nRightMot)
Set the rumble instensity.
#define HID_BTTN_DOWN
button/key state is down or pressed
right hi-freq rumble motor [0-255]
virtual int getFeatureVal(int iMnem)
Get the value associated with the mapped user mnemonic.
Xbox360 controller HID input class.
virtual int update(uint_t uMSec=T_UPDATE_DFT)
Read device and update HID state.
int setLED(int nPattern)
Set the LED pattern.
left bump (left shoulder) [0,1]
static int testXboxInput()
Test Xbox input interface.
static int testXboxLED()
Visually test Xbox LED interface.
#define XBOX_LIBUSB_DEBUG_WARN
log libusb warnings and errors
left low-freq rumble motor [0-255]
right bump (right shoulder) [0,1]
#define XBOX360_LED_PAT_NUMOF
number of patterns
static int testXboxSanity()
Sanity test Xbox interface.
RoadNarrows Robotics standard namespace.
TEST(Xbox360, XboxSanity)
Sanity test Xbox360 controller interface.