コード例 #1
0
ファイル: devicespage.cpp プロジェクト: pmattern/cantata
DevicesPage::DevicesPage(QWidget *p)
    : SinglePageWidget(p)
{
    copyAction = new Action(Icons::self()->downloadIcon, i18n("Copy To Library"), this);
    ToolButton *copyToLibraryButton=new ToolButton(this);
    copyToLibraryButton->setDefaultAction(copyAction);
    #ifdef ENABLE_REMOTE_DEVICES
    forgetDeviceAction=new Action(Icon("list-remove"), i18n("Forget Device"), this);
    connect(forgetDeviceAction, SIGNAL(triggered()), this, SLOT(forgetRemoteDevice()));
    #endif
    connect(DevicesModel::self()->connectAct(), SIGNAL(triggered()), this, SLOT(toggleDevice()));
    connect(DevicesModel::self()->disconnectAct(), SIGNAL(triggered()), this, SLOT(toggleDevice()));
    connect(DevicesModel::self(), SIGNAL(updated(QModelIndex)), this, SLOT(updated(QModelIndex)));
    connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
    connect(view, SIGNAL(searchItems()), this, SLOT(searchItems()));
    connect(view, SIGNAL(itemsSelected(bool)), SLOT(controlActions()));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copyToLibrary()));
    connect(DevicesModel::self()->configureAct(), SIGNAL(triggered()), this, SLOT(configureDevice()));
    connect(DevicesModel::self()->refreshAct(), SIGNAL(triggered()), this, SLOT(refreshDevice()));
    #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
    connect(DevicesModel::self()->editAct(), SIGNAL(triggered()), this, SLOT(editDetails()));
    connect(DevicesModel::self(), SIGNAL(matches(const QString &, const QList<CdAlbum> &)),
            SLOT(cdMatches(const QString &, const QList<CdAlbum> &)));
    #endif
    proxy.setSourceModel(DevicesModel::self());
    view->setModel(&proxy);
    view->setRootIsDecorated(false);
    view->setSearchResetLevel(1);
    Configuration config(metaObject()->className());
    view->load(config);
    MenuButton *menu=new MenuButton(this);
    menu->addAction(createViewMenu(QList<ItemView::Mode>() << ItemView::Mode_BasicTree << ItemView::Mode_SimpleTree
                                                           << ItemView::Mode_DetailedTree << ItemView::Mode_List));
    menu->addSeparator();
    menu->addAction(DevicesModel::self()->configureAct());
    menu->addAction(DevicesModel::self()->refreshAct());
    #ifdef ENABLE_REMOTE_DEVICES
    menu->addSeparator();
    Action *addRemote=new Action(Icon("network-server"), i18n("Add Device"), this);
    connect(addRemote, SIGNAL(triggered()), this, SLOT(addRemoteDevice()));
    menu->addAction(addRemote);
    menu->addAction(forgetDeviceAction);
    #endif
    init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << menu, QList<QWidget *>() << copyToLibraryButton);

    view->addAction(copyAction);
    view->addAction(StdActions::self()->organiseFilesAction);
    view->addAction(StdActions::self()->editTagsAction);
    #ifdef ENABLE_REPLAYGAIN_SUPPORT
    view->addAction(StdActions::self()->replaygainAction);
    #endif
    #ifdef ENABLE_REMOTE_DEVICES
    view->addSeparator();
    view->addAction(forgetDeviceAction);
    #endif
    view->addSeparator();
    view->addAction(StdActions::self()->deleteSongsAction);
}
コード例 #2
0
ファイル: fcdevice.cpp プロジェクト: ferrouswheel/fadecandy
bool FCDevice::matchConfiguration(const Value &config)
{
    if (matchConfigurationWithTypeAndSerial(config, "fadecandy", mSerial)) {
        mConfigMap = findConfigMap(config);
        configureDevice(config);
        return true;
    }

    return false;
}
コード例 #3
0
ファイル: cpu.c プロジェクト: jonatron/pdp-11
//initialise the cpu.
void initCpu() {
	SP = 0200;
	configureDevice(cpuStatus, 0777776, 0777776);
	debug_print("initCpu\n");
	//Test method calls.
	//testHello();
	//testChaser();
	//testMultiplier();
	//testCounter();
	//testInstruction();
}
コード例 #4
0
ファイル: _rpy_device.c プロジェクト: ktargows/rpy2
static int
GrDev_init(PyObject *self, PyObject *args, PyObject *kwds)
{
#ifdef RPY_DEBUG_GRDEV
  printf("FIXME: Initializing GrDev\n");
#endif

  if (!rpy2_isinitialized()) {
    PyErr_Format(PyExc_RuntimeError, 
                 "R must be initialized before instances of GraphicalDevice can be created.");
    return -1;
  }

  if (R_CheckDeviceAvailableBool() != TRUE) {
    PyErr_Format(PyExc_RuntimeError, 
                 "Too many open R devices.");
    return -1;
  }

  pDevDesc dev = ((PyGrDevObject *)self)->grdev;

  configureDevice(dev, self);
  pGEDevDesc gdd = GEcreateDevDesc(dev);
#if (PY_VERSION_HEX < 0x03010000)
  GEaddDevice2(gdd, self->ob_type->tp_name);
#else
  GEaddDevice2(gdd, Py_TYPE(self)->tp_name);
#endif
  GEinitDisplayList(gdd);
  /* FIXME: protect device number ? */
  /* allocate memory for the pDevDesc structure ? */
  /* pDevDesc grdev = malloc(); */
  /* FIXME: handle allocation error */
  /* self->grdev = grdev; */
  
  return 0;
}
コード例 #5
0
EvdevDevice::EvdevDevice(InputHostInterface* host, const std::shared_ptr<InputDeviceNode>& node) :
    mHost(host), mDeviceNode(node), mDeviceDefinition(mHost->createDeviceDefinition()) {

    InputBus bus = getInputBus(node);
    mInputId = mHost->createDeviceIdentifier(
            node->getName().c_str(),
            node->getProductId(),
            node->getVendorId(),
            bus,
            node->getUniqueId().c_str());

    createMappers();
    configureDevice();

    // If we found a need for at least one mapper, register the device with the
    // host. If there were no mappers, this device is effectively ignored, as
    // the host won't know about it.
    if (mMappers.size() > 0) {
        mDeviceHandle = mHost->registerDevice(mInputId, mDeviceDefinition);
        for (const auto& mapper : mMappers) {
            mapper->setDeviceHandle(mDeviceHandle);
        }
    }
}
コード例 #6
0
////////////////////////////////////////////////////////////////////////////////
///
/// @fn main(int argc, char **argv)
///
///  Main entry point for program execution
///
/// @param argc Count of input arguments
/// @param argv Pointer to array of argument arrays
///
/// @return 0 on success
///
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv) {
  // Video parameters
  char videoDevice[] = "/dev/video0";
  int frameWidth = 320;
  int frameHeight = 240;
  float frameRate = 30.0f;
  char format[] = FORMAT_H264;

  // Configure getopt parameters
  int arg = 0;
  int argumentIndex = 0;
  const char abbreviations[] = "dhfs";
  const struct option full[] = {
    {"device", required_argument, NULL, 'd'},
    {"help", no_argument, NULL, 'h'},
    {"format", no_argument, NULL, 'f'},
    {"frame-size", no_argument, NULL, 's'},
    {"available", no_argument, NULL, 'a'}
  };

  // Register signal handler for interrupts
  signal(SIGINT, signalHandler);

  for(;;) {
    arg = getopt_long(argc, argv, abbreviations, full, &argumentIndex);

    // Getopt returns -1 when there are no more arguments left to parse
    if (arg == -1) {
      break;
    }

    switch(arg) {
      case 'd':
        printf("Using device %s\n", optarg);
        break;

      case 'h':
        printHelp();
        break;

      case 'f':
        printf("Using format %s\n", optarg);
        break;

      case 's':
        printf("Using frame size %s\n", optarg);
        break;

      case 'a':
        printf("Available video formats\n");
        printf("Available video sizes\n");
        return 0;

      default:
        break;
    }
  }

  // Begin camera capture
  fprintf(stdout, "Initializing camera capture.\n"
      "Capture Device: %s\n"
      "Video Format: %s\n"
      "Video Size: %i x %i\n"
      "Frame Rate: %0.2f\n",
      videoDevice, format, frameWidth, frameHeight, frameRate);

  // Step 1: Open the device for capture and test for its existence
  int fileDescriptor = openDevice(videoDevice);
  if (fileDescriptor == -1) {
    return EXIT_FAILURE;
  }

  // Step 2: Configure device image format
  if (configureDevice(fileDescriptor, format, frameWidth, frameHeight) == -1 ) {
    return EXIT_FAILURE;
  }

  // Step 3: Capture frames from the device until SIGINT is received
  fprintf(stdout, "\nBeginning frame capture. Press `ctrl+c` to exit.\n\n");
  if (captureFrames(fileDescriptor) == -1) {
    return EXIT_FAILURE;
  }

  // Step 4: Cleanup and exit
  if (shutdownDevice(fileDescriptor) == -1) {
    return EXIT_FAILURE;
  }

  fprintf(stdout, "Successfully Exiting.\n");
  return EXIT_SUCCESS;
}
コード例 #7
0
ファイル: devicespage.cpp プロジェクト: polpo/cantata-mac
DevicesPage::DevicesPage(QWidget *p)
    : QWidget(p)
{
    setupUi(this);
    copyAction = ActionCollection::get()->createAction("copytolibrary", i18n("Copy To Library"), Icons::self()->importIcon);
    copyToLibraryButton->setDefaultAction(copyAction);
    syncAction = ActionCollection::get()->createAction("syncdevice", i18n("Sync"), "folder-sync");
    searchButton->setDefaultAction(StdActions::self()->searchAction);
    connect(syncAction, SIGNAL(triggered()), this, SLOT(sync()));
    #ifdef ENABLE_REMOTE_DEVICES
    forgetDeviceAction=ActionCollection::get()->createAction("forgetdevice", i18n("Forget Device"), "list-remove");
    connect(forgetDeviceAction, SIGNAL(triggered()), this, SLOT(forgetRemoteDevice()));
    #endif
    connect(DevicesModel::self()->connectAct(), SIGNAL(triggered()), this, SLOT(toggleDevice()));
    connect(DevicesModel::self()->disconnectAct(), SIGNAL(triggered()), this, SLOT(toggleDevice()));
    copyToLibraryButton->setEnabled(false);
    syncAction->setEnabled(false);
    view->addAction(copyAction);
    view->addAction(syncAction);
    view->addAction(StdActions::self()->organiseFilesAction);
    view->addAction(StdActions::self()->editTagsAction);
    #ifdef ENABLE_REPLAYGAIN_SUPPORT
    view->addAction(StdActions::self()->replaygainAction);
    #endif
    #ifdef ENABLE_REMOTE_DEVICES
    QAction *sepA=new QAction(this);
    sepA->setSeparator(true);
    view->addAction(sepA);
    view->addAction(forgetDeviceAction);
    #endif
    QAction *sep=new QAction(this);
    sep->setSeparator(true);
    view->addAction(sep);
    view->addAction(StdActions::self()->deleteSongsAction);
    connect(this, SIGNAL(add(const QStringList &, bool, quint8)), MPDConnection::self(), SLOT(add(const QStringList &, bool, quint8)));
    connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &)));
    connect(genreCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(searchItems()));
    connect(DevicesModel::self(), SIGNAL(updateGenres(const QSet<QString> &)), genreCombo, SLOT(update(const QSet<QString> &)));
    connect(DevicesModel::self(), SIGNAL(updated(QModelIndex)), this, SLOT(updated(QModelIndex)));
    connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
    connect(view, SIGNAL(searchItems()), this, SLOT(searchItems()));
    connect(view, SIGNAL(itemsSelected(bool)), SLOT(controlActions()));
    connect(view, SIGNAL(rootIndexSet(QModelIndex)), this, SLOT(updateGenres(QModelIndex)));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copyToLibrary()));
    connect(DevicesModel::self()->configureAct(), SIGNAL(triggered()), this, SLOT(configureDevice()));
    connect(DevicesModel::self()->refreshAct(), SIGNAL(triggered()), this, SLOT(refreshDevice()));
    #if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
    connect(DevicesModel::self()->editAct(), SIGNAL(triggered()), this, SLOT(editDetails()));
    connect(DevicesModel::self(), SIGNAL(matches(const QString &, const QList<CdAlbum> &)),
            SLOT(cdMatches(const QString &, const QList<CdAlbum> &)));
    #endif
    QMenu *menu=new QMenu(this);
    #ifdef ENABLE_REMOTE_DEVICES
    Action *addRemote=ActionCollection::get()->createAction("adddevice", i18n("Add Device"), "network-server");
    connect(addRemote, SIGNAL(triggered()), this, SLOT(addRemoteDevice()));
    menu->addAction(addRemote);
    menu->addAction(forgetDeviceAction);
    menu->addSeparator();
    #endif
    menu->addAction(DevicesModel::self()->configureAct());
    menu->addAction(DevicesModel::self()->refreshAct());
    menu->addSeparator();
    menu->addAction(StdActions::self()->organiseFilesAction);
    menu->addAction(StdActions::self()->editTagsAction);
    #ifdef ENABLE_REPLAYGAIN_SUPPORT
    menu->addAction(StdActions::self()->replaygainAction);
    #endif
    menuButton->setMenu(menu);
    proxy.setSourceModel(DevicesModel::self());
    view->setModel(&proxy);
    view->setRootIsDecorated(false);
}