Statistics::StatisticItem Statistics::readStatisticsItem(std::string const& str) { StatisticItem item; std::string::size_type posStart = std::string::npos; std::string::size_type posEnd = std::string::npos; posStart = str.find(STAT_ITEM_OPEN); posEnd = str.find(STAT_ITEM_CLOSE, ++posStart); if(posStart == std::string::npos || posEnd == std::string::npos) throw utils::Exception("cannot find key item boundaries!"); std::string raw_key(str, posStart, posEnd - posStart); std::string::size_type posTStart = raw_key.find(STAT_TYPE_OPEN); std::string::size_type posTEnd = raw_key.find(STAT_TYPE_CLOSE, ++posTStart); if(posTStart == std::string::npos || posTEnd == std::string::npos) throw utils::Exception("cannot find type boundaries!"); item.type = std::string(raw_key, posTStart, posTEnd - posTStart); item.key = std::string(raw_key, posTEnd + 1); posStart = str.find(STAT_ITEM_OPEN, posEnd); posEnd = str.find(STAT_ITEM_CLOSE, ++posStart); if(posStart == std::string::npos || posEnd == std::string::npos) throw utils::Exception("cannot find value item boundaries!"); item.value = std::string(str, posStart, posEnd - posStart); return item; }
void RA::key_power(bool bDown) { #ifdef USE_UINPUT raw_key(bDown, 116); return; #endif //ta_log("TDC sleep device"); if( m_monkeysock == INVALID_SOCKET ) return; char buf[1024]; //sprintf_s(buf, "press %d\n", AKEYCODE_POWER); if( bDown ) sprintf_s(buf, "key down %d\n", AKEYCODE_POWER); else sprintf_s(buf, "key up %d\n", AKEYCODE_POWER); WriteExact(m_monkeysock, buf, strlen(buf)); key_checkok(); }
void RA::key_search(bool bDown) { #ifdef USE_UINPUT raw_key(bDown, 217); return; #endif //ta_log("TDC KEYCODE_SEARCH"); if( m_monkeysock == INVALID_SOCKET ) return; char buf[1024]; //sprintf_s(buf, "press %d\n", AKEYCODE_SEARCH); if( bDown ) sprintf_s(buf, "key down %d\n", AKEYCODE_SEARCH); else sprintf_s(buf, "key up %d\n", AKEYCODE_SEARCH); WriteExact(m_monkeysock, buf, strlen(buf)); key_checkok(); }
void RA::key_camera(bool bDown) { #ifdef USE_UINPUT raw_key(bDown, 212); return; #endif //ta_log("TDC KEYCODE_CAMERA"); if( m_monkeysock == INVALID_SOCKET ) return; char buf[1024]; //sprintf_s(buf, "type abcdefg\n"); //sprintf_s(buf, "press %d\n", AKEYCODE_CAMERA); if( bDown ) sprintf_s(buf, "key down %d\n", AKEYCODE_CAMERA); else sprintf_s(buf, "key up %d\n", AKEYCODE_CAMERA); WriteExact(m_monkeysock, buf, strlen(buf)); key_checkok(); }
void RA::key_menu(bool bDown) { #ifdef USE_UINPUT raw_key(bDown, 139); return; #endif //tdc_getinstalledpkgname(); //ta_log("TDC KEYCODE_MENU"); if( m_monkeysock == INVALID_SOCKET ) return; char buf[1024]; //sprintf_s(buf, "press %d\n", AKEYCODE_MENU); if( bDown ) sprintf_s(buf, "key down %d\n", AKEYCODE_MENU); else sprintf_s(buf, "key up %d\n", AKEYCODE_MENU); WriteExact(m_monkeysock, buf, strlen(buf)); key_checkok(); }
void RA::key_wake() { #ifdef USE_UINPUT raw_key(1, 116); // power raw_key(0, 116); raw_key(1, 102); // home raw_key(0, 102); raw_key(1, 158); // back raw_key(0, 158); return; #endif //ta_log("TDC wake device"); if( m_monkeysock == INVALID_SOCKET ) return; char buf[1024]; sprintf_s(buf, "wake\n"); //sprintf_s(buf, "press 187\n"); WriteExact(m_monkeysock, buf, strlen(buf)); key_checkok(); }