Пример #1
0
int main(int argc, char **argv) {
	if (!openController()) {
		fprintf(stderr, "Could not open controller.\r\n");
		return(-1);
	}
	unsigned int last=0;
	while (true) {
		if (controllerHasData()) {
			unsigned int c = readController();
			if (c & P1_LEFT) printf("P1_LEFT ");
			if (c & P1_RIGHT) printf("P1_RIGHT ");
			if (c & P1_UP) printf("P1_UP ");
			if (c & P1_DOWN) printf("P1_DOWN ");
			if (c & P2_LEFT) printf("P2_LEFT ");
			if (c & P2_RIGHT) printf("P2_RIGHT ");
			if (c & P2_UP) printf("P2_UP ");
			if (c & P2_DOWN) printf("P2_DOWN ");
			if (c & START) printf("START ");
			if (c & SELECT) printf("SELECT ");
			if (c & P1_FIRE) printf("P1_FIRE ");
			if (c & P2_FIRE) printf("P2_FIRE ");
			printf("%i (%i)\n", c, c-last);
			fflush(stdout);
			last = c;
		}
	}
}
    //---------------------------------------------------------------
    void LibraryControllers::openSkin ( 
        const String &controllerId, const String &controllerName, const URI &skinSource )
    {
        openController ( controllerId, controllerName );

        mSkinCloser = mSW->openElement ( CSWC::CSW_ELEMENT_SKIN );

        mSW->appendURIAttribute ( CSWC::CSW_ATTRIBUTE_SOURCE, skinSource );
    }
Пример #3
0
        bool reopenJoystick(int j) {
#ifdef CURRENT_PLATFORM
            closeController();
            cid = j;
            return openController();
#else
            cid = j;
            return true;
#endif
        }
    //---------------------------------------------------------------
    void LibraryControllers::openMorph ( 
        const String &controllerId, 
        const String &controllerName, 
        const URI &morphSource, 
        const String &morphMethod )
    {
        openController ( controllerId, controllerName );

        mMorphCloser = mSW->openElement ( CSWC::CSW_ELEMENT_MORPH );

        mSW->appendURIAttribute ( CSWC::CSW_ATTRIBUTE_SOURCE, morphSource );

        // Which blending technique to use. Valid values are NORMALIZED and
        // RELATIVE. The default is NORMALIZED.
        mSW->appendAttribute( CSWC::CSW_ATTRIBUTE_METHOD, morphMethod );
    }
Пример #5
0
	void Joystick::open() {
		if (m_joystickHandle) {
			close();
		}

		m_joystickHandle = SDL_JoystickOpen(m_deviceIndex);
		if (m_joystickHandle) {
			m_instanceId = SDL_JoystickInstanceID(m_joystickHandle);

			char tmp[33];
			SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(m_deviceIndex);
			SDL_JoystickGetGUIDString(guid, tmp, sizeof(tmp));
			m_guidStr = std::string(tmp);

			openController();
			const char* name = SDL_JoystickNameForIndex(m_deviceIndex);
			if (isController() && !name) {
				name = SDL_GameControllerNameForIndex(m_deviceIndex);
			}
			m_name = std::string(name);
		} else {
			throw SDLException(SDL_GetError());
		}
	}
Пример #6
0
void DlgPrefController::enableDevice() {
    emit(openController(m_pController));
    //TODO: Should probably check if open() actually succeeded.
}