コード例 #1
0
ファイル: NeuronPlugin.cpp プロジェクト: PhilipRosedale/hifi
bool NeuronPlugin::activate() {
    InputPlugin::activate();

    // register with userInputMapper
    auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
    userInputMapper->registerDevice(_inputDevice);

    // register c-style callbacks
    BRRegisterFrameDataCallback((void*)this, FrameDataReceivedCallback);
    BRRegisterCommandDataCallback((void*)this, CommandDataReceivedCallback);
    BRRegisterSocketStatusCallback((void*)this, SocketStatusChangedCallback);

    // TODO: Pull these from prefs dialog?
    // localhost is fine for now.
    _serverAddress = "localhost";
    _serverPort = 7001;  // default port for TCP Axis Neuron server.

    _socketRef = BRConnectTo((char*)_serverAddress.c_str(), _serverPort);
    if (!_socketRef) {
        // error
        qCCritical(inputplugins) << "NeuronPlugin: error connecting to " << _serverAddress.c_str() << ":" << _serverPort << ", error = " << BRGetLastErrorMessage();
        return false;
    } else {
        qCDebug(inputplugins) << "NeuronPlugin: success connecting to " << _serverAddress.c_str() << ":" << _serverPort;

        BRRegisterAutoSyncParmeter(_socketRef, Cmd_CombinationMode);
        return true;
    }
}
コード例 #2
0
ファイル: ofxNeuron.cpp プロジェクト: naus3a/ofxNeuron
void ofxNeuron::registerCallbacks(){
	bool bBVH=false;
	bool bCmd=false;
	bool bSSt=false;
	void * ptr = NULL;
	cout<<"ofxNeuron: registering callbacks: "<<endl;
	cout<<"- BVHDataReceived... ";
	_DataReceived = FrameDataReceived(bvhDataReceived);
	if(_DataReceived){
		BRRegisterFrameDataCallback(ptr, _DataReceived);
		bBVH=true;
		cout<<"done."<<endl;
	}else{
		cout<<"failed."<<endl;
	}
	cout<<"- CMDDataReceived... ";
	_CmdDataReceived = CommandDataReceived(cmdDataReceived);
	if(_CmdDataReceived){
		BRRegisterCommandDataCallback(ptr, _CmdDataReceived);
		bCmd=true;
		cout<<"done."<<endl;
	}else{
		cout<<"failed."<<endl;
	}
	cout<<"- SocketStatusChanged... ";
	_SocketStatusChanged = SocketStatusChanged(socketStatusChanged);
	if(_SocketStatusChanged){
		BRRegisterSocketStatusCallback(ptr, _SocketStatusChanged);
		bSSt=true;
		cout<<"done."<<endl;
	}else{
		cout<<"failed."<<endl;
	}

	bCallbacks = bBVH&&bCmd&&bSSt;
}