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


C++ SCA_Joystick类代码示例

本文整理汇总了C++中SCA_Joystick的典型用法代码示例。如果您正苦于以下问题:C++ SCA_Joystick类的具体用法?C++ SCA_Joystick怎么用?C++ SCA_Joystick使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SCA_Joystick类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pyattr_get_hat_single

PyObject* SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
	SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
	
	return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1));
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: pyattr_get_axis_single

PyObject* SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
	SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
	
	if (self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) {
		PyErr_SetString(PyExc_TypeError, "val = sensor.axisSingle: Joystick Sensor, not 'Single Axis' type");
		return NULL;
	}
	
	return PyLong_FromSsize_t(joy->GetAxisPosition(self->m_axis-1));
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例3: PyGetButtonStatus

PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* args ) {
	SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
	int index;
	
	if(!PyArg_ParseTuple(args, "i:getButtonStatus", &index)){
		return NULL;
	}
	if(joy && index >= 0 && index < joy->GetNumberOfButtons()) {
		return PyBool_FromLong(joy->aButtonPressIsPositive(index) ? 1 : 0);
	}
	return PyBool_FromLong(0);
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例4: pyattr_get_hat_values

PyObject* SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
	SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
	
	int hat_index= joy->GetNumberOfHats();
	PyObject *list= PyList_New(hat_index);
	
	while(hat_index--) {
		PyList_SET_ITEM(list, hat_index, PyLong_FromSsize_t(joy->GetHat(hat_index)));
	}
	
	return list;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例5: PyGetButtonActiveList

PyObject* SCA_JoystickSensor::PyGetButtonActiveList( ) {
	SCA_Joystick *joy = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
	PyObject *ls = PyList_New(0);
	PyObject *value;
	int i;
	
	if(joy) {
		for (i=0; i < joy->GetNumberOfButtons(); i++) {
			if (joy->aButtonPressIsPositive(i)) {
				value = PyLong_FromSsize_t(i);
				PyList_Append(ls, value);
				Py_DECREF(value);
			}
		}
	}
	return ls;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例6: pyattr_get_connected

PyObject* SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
	SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
	return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例7: pyattr_get_num_buttons

PyObject* SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v);
	SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex);
	return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 );
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例8: Evaluate

bool SCA_JoystickSensor::Evaluate()
{
	SCA_Joystick *js = ((SCA_JoystickManager *)m_eventmgr)->GetJoystickDevice(m_joyindex);
	bool result = false;
	bool reset = m_reset && m_level;
	
	if (js==NULL) /* no joystick - don't do anything */
		return false;
	
	m_reset = false;
	switch(m_joymode)
	{
	case KX_JOYSENSORMODE_AXIS:
		{
		/* what is what!
			m_axisf == JOYAXIS_RIGHT, JOYAXIS_UP, JOYAXIS_DOWN, JOYAXIS_LEFT
			m_axisf == 1 == up
			m_axisf == 2 == left
			m_axisf == 3 == down
			
			numberof== m_axis (1-4), range is half of JOYAXIS_MAX since 
				it assumes the axis joysticks are axis parirs (0,1), (2,3), etc
				also note that this starts at 1 where functions its used
				with expect a zero index.
			*/
			
			if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */
				return false;
			
			js->cSetPrecision(m_precision);
			if (m_bAllEvents) {
				if (js->aAxisPairIsPositive(m_axis-1)) { /* use zero based axis index internally */
					m_istrig = 1;
					result = true;
				}else{
					if (m_istrig) {
						m_istrig = 0;
						result = true;
					}
				}
			}
			else {
				if (js->aAxisPairDirectionIsPositive(m_axis-1, m_axisf)) { /* use zero based axis index internally */
					m_istrig = 1;
					result = true;
				}else{
					if (m_istrig) {
						m_istrig = 0;
						result = true;
					}
				}
			}
			break;
		}
	case KX_JOYSENSORMODE_AXIS_SINGLE:
		{
			/* Like KX_JOYSENSORMODE_AXIS but don't pair up axis */
			if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */
				return false;
			
			/* No need for 'm_bAllEvents' check here since were only checking 1 axis */
			js->cSetPrecision(m_precision);
			if (js->aAxisIsPositive(m_axis-1)) { /* use zero based axis index internally */
				m_istrig = 1;
				result = true;
			}else{
				if (m_istrig) {
					m_istrig = 0;
					result = true;
				}
			}
			break;
		}
		
	case KX_JOYSENSORMODE_BUTTON:
		{
		/* what is what!
			m_button = the actual button in question
			*/
			if (!js->IsTrigButton() && !reset) /* No events from SDL? - don't bother */
				return false;
			
			if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) {
				m_istrig = 1;
				result = true;
			}else {
				if (m_istrig) {
					m_istrig = 0;
					result = true;
				}
			}
			break;
		}
	case KX_JOYSENSORMODE_HAT:
		{
		/* what is what!
			numberof = m_hat  -- max 4
			direction= m_hatf -- max 12
			*/
			
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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