当前位置: 首页>>代码示例>>C++>>正文


C++ Joystick::getAxis方法代码示例

本文整理汇总了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;

}
开发者ID:saurabhd14,项目名称:tinyos-1.x,代码行数:26,代码来源:testJoystick.cpp

示例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;
}
开发者ID:Ghor,项目名称:LoveEngineCore,代码行数:7,代码来源:wrap_Joystick.cpp

示例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);
	}
}
开发者ID:Kheirouben,项目名称:lucas-research,代码行数:13,代码来源:main.cpp

示例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;
}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:44,代码来源:input.cpp


注:本文中的Joystick::getAxis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。