void AMCPDevice::parseHeader(const QString& line) { if (line.length() == 0) return; QStringList tokens = line.split(QRegExp("\\s")); this->code = tokens.at(0).toInt(); switch (this->code) { case 200: // The command has been executed and several lines of data are being returned. this->state = AMCPDevice::ExpectingMultiline; break; case 201: // The command has been executed and a line of data is being returned. case 400: // Command not understood. this->state = AMCPDevice::ExpectingTwoline; break; default: this->state = AMCPDevice::ExpectingOneline; break; } this->command = translateCommand(tokens.at(1)); if (tokens.count() > 3) this->command = translateCommand(QString("%1 %2").arg(tokens.at(1)).arg(tokens.at(2))); this->response.append(line); }
void AMCPDevice::parseHeader(const QString& line) { if (line.length() == 0) return; QStringList tokens = line.split(QRegExp("\\s")); this->code = tokens.at(0).toInt(); this->command = translateCommand(tokens.at(1)); if (tokens.count() == 3) this->command = translateCommand(tokens.at(1)); else this->command = translateCommand(QString("%1 %2").arg(tokens.at(1)).arg(tokens.at(2))); switch (this->code) { case 200: this->state = AMCPDevice::ExpectingMultiline; break; case 201: this->state = AMCPDevice::ExpectingTwoline; break; default: this->state = AMCPDevice::ExpectingOneline; break; } this->response.append(line); }
void InputHandler::_processKeyPress( int nativeKeyCode, int64_t timestamp ) { // Verify that this key isn't already pressed for( auto i : m_keysDown ) { if( i.nativeKeyCode == nativeKeyCode ) return; } // Key translatedKeyCode = translateKey(nativeKeyCode); // Create and fill in the info-structure. KeyDownInfo info; info.nativeKeyCode = nativeKeyCode; info.translatedKeyCode = translatedKeyCode; info.pressTimestamp = timestamp; info.pWidget = _focusedWidget(); m_keysDown.push_back( info ); // Post KEY_PRESS message Widget * pWidget = _focusedWidget(); Base::msgRouter()->post( new KeyPressMsg( m_inputId, nativeKeyCode, translatedKeyCode, pWidget, m_modKeys, m_pointerPos, timestamp ) ); // Post an EditCommand if that is associated with the key-combo. EditCmd cmd = translateCommand( nativeKeyCode, m_modKeys ); if( cmd != EditCmd::None ) Base::msgRouter()->post( new EditCommandMsg( m_inputId, cmd, pWidget )); // Update modkeys switch( translatedKeyCode ) { case Key::Shift: m_modKeys = (ModifierKeys) (m_modKeys | MODKEY_SHIFT); break; case Key::Control: m_modKeys = (ModifierKeys) (m_modKeys | MODKEY_CTRL); break; case Key::Alt: m_modKeys = (ModifierKeys) (m_modKeys | MODKEY_ALT); break; case Key::Super: m_modKeys = (ModifierKeys) (m_modKeys | MODKEY_SUPER); break; default: break; } }
CAsyncHttp::CHttpCommand::CHttpCommand(String strCmd, rho_param *p) : m_params(p) { m_eCmd = translateCommand(strCmd); m_strCallback = m_params.getString("callback"); m_strCallbackParams = m_params.getString("callback_param"); m_params.getHash("headers", m_mapHeaders); if(m_params.has("ssl_verify_peer")) m_NetRequest.setSslVerifyPeer(m_params.getBool("ssl_verify_peer")); }
CAsyncHttp::CHttpCommand::CHttpCommand(String strCmd, rho_param *p) : m_params(p) { m_eCmd = translateCommand(strCmd); m_strCallback = m_params.getString("callback"); m_strCallbackParams = m_params.getString("callback_param"); m_params.getHash("headers", m_mapHeaders); m_pNetRequest = rho_get_RhoClassFactory()->createNetRequest(); m_pNetRequest->sslVerifyPeer(m_params.getBool("ssl_verify_peer")); }
void makeCommand(libusb_device_handle *handle,char* cmd,int delay){ fprintf(stderr, "Moving %s for %d Ms\n",cmd,delay); int command = translateCommand(cmd); sendCMD(handle,command); // Bei Feuern: Kein Zeitlimit. if(command == LAUNCHER_FIRE){ delay=0; } // Nur bei Bewegungskommandos pollen: if(command!=LAUNCHER_STOP && command!=LAUNCHER_POLL){ waituntil(handle,command,delay); sendCMD(handle,LAUNCHER_STOP); } }
void InputHandler::_handleKeyRepeats( int64_t timestamp ) { for( auto key : m_keysDown ) { int64_t firstRepeat = key.pressTimestamp + m_keyRepeatDelay; int64_t repeatPos; // Next timestamp where a key repeat should occur. if( m_timeStamp < firstRepeat ) repeatPos = firstRepeat; else repeatPos = firstRepeat + ((m_timeStamp - firstRepeat) / m_keyRepeatRate) * m_keyRepeatRate + m_keyRepeatRate; while( repeatPos <= timestamp ) { Base::msgRouter()->post( new KeyRepeatMsg( m_inputId, key.nativeKeyCode, key.translatedKeyCode, key.pWidget.rawPtr(), m_modKeys, m_pointerPos, repeatPos )); EditCmd cmd = translateCommand( key.nativeKeyCode, m_modKeys ); if( cmd != EditCmd::None ) Base::msgRouter()->post( new EditCommandMsg( m_inputId, cmd, key.pWidget.rawPtr() )); repeatPos += m_keyRepeatRate; } } }