Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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 );
}