static void VRPN_CALLBACK handle_states(void *userdata, vrpn_BUTTONSTATESCB info) { auto self = static_cast<VRPNButtonHandler *>(userdata); self->m_handle(info); }
static void VRPN_CALLBACK handle(void *userdata, vrpn_ANALOGCB info) { auto self = static_cast<VRPNAnalogHandler *>(userdata); self->m_handle(info); }
void AsCInterFace::ProcessThreadFunction( std::string input_string ) { Sleep(5000); std::cout<<input_string<<std::endl; m_handle(input_string); }
void Task::run(){ if(m_handle){ m_handle(m_attachment); } }
QSerialPort::QSerialPort(QString filename, QObject *parent) : QIODevice(parent), m_name(filename), #ifdef WIN32 m_handle(INVALID_HANDLE_VALUE) #else m_handle(-1) #endif { } QSerialPort::~QSerialPort() { close(); } bool QSerialPort::open(OpenMode) { #ifdef WIN32 COMMTIMEOUTS cto; char realPortname[10]; memset(realPortname, 0, 10); strncpy(realPortname, "\\\\.\\", 4); strncpy(realPortname+4, m_name.toLocal8Bit(), 5); m_handle = CreateFileA(realPortname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); if(m_handle == INVALID_HANDLE_VALUE) return false; cto.ReadIntervalTimeout = 0; cto.ReadTotalTimeoutMultiplier = 0; cto.ReadTotalTimeoutConstant = 1; cto.WriteTotalTimeoutMultiplier = 0; cto.WriteTotalTimeoutConstant = 0; if(!SetCommTimeouts(m_handle, &cto)) { CloseHandle(m_handle); m_handle = INVALID_HANDLE_VALUE; return false; } if(!SetupComm(m_handle, 2048, 2048)) { CloseHandle(m_handle); m_handle = INVALID_HANDLE_VALUE; return false; } if(!SetCommMask(m_handle, 0)) { CloseHandle(m_handle); m_handle = INVALID_HANDLE_VALUE; return false; } configurePort(); return QIODevice::open(ReadWrite); #else m_handle = ::open(m_name.toLocal8Bit(), O_RDWR | O_NDELAY | O_NOCTTY); if(m_handle > 0) { ::fcntl(m_handle, F_SETFL, ~O_NDELAY & ::fcntl(m_handle, F_GETFL, 0)); configurePort(); return QIODevice::open(ReadWrite); } #endif return false; }