本文整理汇总了C++中Joystick::getAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ Joystick::getAxis方法的具体用法?C++ Joystick::getAxis怎么用?C++ Joystick::getAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joystick
的用法示例。
在下文中一共展示了Joystick::getAxis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main () {
Joystick joystick;
std::cout << joystick.init();
while(1) {
std::cout << "Update:";
std::cout << joystick.update();
std::cout << " Axis0:";
std::cout << joystick.getAxis(0);
std::cout << " Axis1:";
std::cout << joystick.getAxis(1);
std::cout << " Button0:";
std::cout << joystick.getButton(0);
std::cout << "\n";
}
return 0;
}
示例2: w_Joystick_getAxis
int w_Joystick_getAxis(lua_State *L)
{
Joystick *j = luax_checkjoystick(L, 1);
int axisindex = luaL_checkint(L, 2) - 1;
lua_pushnumber(L, j->getAxis(axisindex));
return 1;
}
示例3: main
int main() {
Joystick *myStick = new Joystick("/dev/input/js0");
while (true) {
for (int i = 0; i<myStick->numberOfAxis(); i++) {
printf("%.2f\t", myStick->getAxis(i));
}
// for (int i = 0; i<myStick->numberOfButtons(); i++) {
// printf("%d\t", myStick->getButton(i));
// }
printf("\n");
usleep(10000);
}
}
示例4: EnumAxesCallback
/*
* Callback function for enumerating the axes on a joystick.
*/
BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE * pdidoi,
void * pJoystickAsVoid )
{
BW_GUARD;
Joystick * pJoystick = reinterpret_cast<Joystick *>( pJoystickAsVoid );
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYOFFSET;
diprg.diph.dwObj = pdidoi->dwOfs; // Specify the enumerated axis
diprg.lMin = -DIRECT_INPUT_AXIS_MAX;
diprg.lMax = +DIRECT_INPUT_AXIS_MAX;
// Set the range for the axis
if( FAILED( pJoystick->pDIJoystick()->
SetProperty( DIPROP_RANGE, &diprg.diph ) ) )
{
return DIENUM_STOP;
}
// Set the UI to reflect what axes the joystick supports
AxisEvent::Axis amap = AxisEvent::NUM_AXES;
switch( pdidoi->dwOfs )
{
// these are PlayStation mappings
case DIJOFS_X: amap = AxisEvent::AXIS_LX; break;
case DIJOFS_Y: amap = AxisEvent::AXIS_LY; break;
case DIJOFS_Z: amap = AxisEvent::AXIS_RX; break;
// case DIJOFS_RX: amap = AxisEvent::AXIS_; break;
// case DIJOFS_RY: amap = AxisEvent::AXIS_; break;
case DIJOFS_RZ: amap = AxisEvent::AXIS_RY; break;
// case DIJOFS_SLIDER(0): amap = AxisEvent::AXIS_; break;
// case DIJOFS_SLIDER(1): amap = AxisEvent::AXIS_; break;
}
if (amap != AxisEvent::NUM_AXES)
pJoystick->getAxis( amap ).enabled( true );
return DIENUM_CONTINUE;
}