void OISServer::initialize(const ion_intptr windowhandle) { // TODO: resolve this ( a 64bit-issue) std::stringstream wnd; wnd << windowhandle; OIS::ParamList pl; pl.insert(std::make_pair(std::string("WINDOW"), wnd.str())); m_pInternaldata->m_pInputmanager=OIS::InputManager::createInputSystem(pl); enumerateDevices(); }
QT_BEGIN_NAMESPACE BbVideoDeviceSelectorControl::BbVideoDeviceSelectorControl(BbCameraSession *session, QObject *parent) : QVideoDeviceSelectorControl(parent) , m_session(session) , m_default(0) , m_selected(0) { enumerateDevices(&m_devices, &m_descriptions); // pre-select the rear camera const int index = m_devices.indexOf(BbCameraSession::cameraIdentifierRear()); if (index != -1) m_default = m_selected = index; }
void Libdc1394Grabber::listDevices() { enumerateDevices(); /* Verify that we have at least one camera */ if (cameraList->num > 0) { ofLog(OF_LOG_WARNING, "Listing available capture devices:"); ofLog(OF_LOG_WARNING,"(Use GUID as unique ID for camera)"); ofLog(OF_LOG_WARNING, "-------------------------------------------------------"); for (uint32_t index = 0; index < cameraList->num; index++) { ofLog(OF_LOG_WARNING, "Video device %d: GUID = %llx , Unit = %x ", index, cameraList->ids[index].guid, cameraList->ids[index].unit); } ofLog(OF_LOG_WARNING, "-------------------------------------------------------"); } ofLog(OF_LOG_WARNING,"There were %d cameras found.", numCameras ); }
int main(int argc, char* argv[]) { int ret; int pollres; struct pollfd pollinfo; int port; __android_log_print(ANDROID_LOG_INFO, "EvdevReader", "Entered main()"); port = atoi(argv[1]); __android_log_print(ANDROID_LOG_INFO, "EvdevReader", "Requested port number: %d", port); // Connect to the app's socket ret = connectSocket(port); if (ret < 0) { return ret; } // Perform initial enumeration ret = enumerateDevices(); if (ret < 0) { return ret; } // Wait for requests from the client for (;;) { unsigned char requestId; do { // Every second we poll again for new devices if // we haven't received any new events pollinfo.fd = sock; pollinfo.events = POLLIN; pollinfo.revents = 0; pollres = poll(&pollinfo, 1, 1000); if (pollres == 0) { // Timeout, re-enumerate devices enumerateDevices(); } } while (pollres == 0); if (pollres > 0 && (pollinfo.revents & POLLIN)) { // We'll have data available now ret = recv(sock, &requestId, sizeof(requestId), 0); if (ret < sizeof(requestId)) { __android_log_print(ANDROID_LOG_ERROR, "EvdevReader", "Short read on socket"); return errno; } if (requestId != UNGRAB_REQ && requestId != REGRAB_REQ) { __android_log_print(ANDROID_LOG_ERROR, "EvdevReader", "Unknown request"); return requestId; } { struct DeviceEntry *currentEntry; pthread_mutex_lock(&DeviceListLock); // Update state for future devices grabbing = (requestId == REGRAB_REQ); // Carry out the requested action on each device currentEntry = DeviceListHead; while (currentEntry != NULL) { ioctl(currentEntry->fd, EVIOCGRAB, grabbing); currentEntry = currentEntry->next; } pthread_mutex_unlock(&DeviceListLock); __android_log_print(ANDROID_LOG_INFO, "EvdevReader", "New grab status is: %s", grabbing ? "enabled" : "disabled"); } } else { // Terminate this thread if (pollres < 0) { __android_log_print(ANDROID_LOG_ERROR, "EvdevReader", "Socket recv poll() failed: %d", errno); } else { __android_log_print(ANDROID_LOG_ERROR, "EvdevReader", "Socket poll unexpected revents: %d", pollinfo.revents); } return -1; } } }