MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / handle

Method handle

source/MRViewer/MRSpaceMouseHandlerHidapi.cpp:106–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void HandlerHidapi::handle()
107{
108 // works in pair with HandlerHidapi::startListenerThread_()
109 std::unique_lock<std::mutex> syncThreadLock( syncThreadMutex_, std::defer_lock );
110 if ( !syncThreadLock.try_lock() )
111 return;
112
113 if ( packetLength_ <= 0 || !device_ )
114 {
115 cv_.notify_one();
116 return;
117 }
118
119 // set the device handle to be non-blocking
120 hid_set_nonblocking( device_, 1 );
121
122 Action action;
123 smDevice_.parseRaw( dataPacket_, packetLength_, action );
124
125 int packetLengthTmp = 0;
126 do
127 {
128 DataPacketRaw dataPacketTmp;
129 packetLengthTmp = hid_read( device_, dataPacketTmp.data(), dataPacketTmp.size() );
130 smDevice_.parseRaw( dataPacketTmp, packetLengthTmp, action );
131 } while ( packetLengthTmp > 0 );
132
133 processAction_( action );
134
135 syncThreadLock.unlock();
136 cv_.notify_one();
137}
138
139void HandlerHidapi::initListenerThread_()
140{

Callers 1

launchEventLoopMethod · 0.45

Calls 3

parseRawMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected