Пример #1
0
void InputInit() {
  struct IOMessagebuf bufMsg;
  struct IOMessage *msg = (struct IOMessage *)&bufMsg;
  int reply, src;
  struct IONode nodes[100];
  struct IONode *first[2] = {NULL, NULL};
  struct IONode *last[2] = {NULL, NULL};
  int buffer1[BUFFERSIZE];
  int buffer2[BUFFERSIZE];
  int bufHead[2] = {0, 0};
  int bufTail[2] = {0, 0};

  int notifier1Tid = Create(7, notifier);
  int notifier2Tid = Create(7, bufferedNotifier);
  int eventType = TERMIN_EVENT;
  Send(notifier2Tid, (char *)&eventType, sizeof(int), (char *)&reply, sizeof(int));
  eventType = TRAIIN_EVENT;
  Send(notifier1Tid, (char *)&eventType, sizeof(int), (char *)&reply, sizeof(int));
  RegisterAs("Input Server");

  while(true) {
    Receive(&src, (char *)&bufMsg, sizeof(struct IOMessagebuf));
    switch(bufMsg.type) {
      case IONOTIFIER:
	reply = 0;
	Reply(src, (char *)&reply, sizeof(int));
	if(src == notifier1Tid){
	  handleNewInput(&first[0], last[0], buffer1, &bufHead[0], bufTail[0], (char)msg->data);
	}else if(src == notifier2Tid) {
	  int *buffer = bufMsg.data;
	  while(*buffer != (int)'\0') {
	    handleNewInput(&first[1], last[1], buffer2, &bufHead[1], bufTail[1], *buffer);
	    buffer++;
	  }
	}
	break;
      case IOINPUT:
        nodes[src & 0x7F].tid = src;
	if (msg->channel == 1){
	  handleNewInputTask(&first[0], &last[0], buffer1, bufHead[0], &bufTail[0], &nodes[src & 0x7F]);
	}else if(msg->channel == 2) {
	  handleNewInputTask(&first[1], &last[1], buffer2, bufHead[1], &bufTail[1], &nodes[src & 0x7F]);
	}
	break;
    }
  }
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QObject::connect(ui->open_rom, &QAction::triggered, this, &MainWindow::handle_open_rom);
    QObject::connect(ui->configure_input, &QAction::triggered, this, &MainWindow::handle_configure_input);
    QObject::connect(&gb_, &GameboyGui::frameReady, ui->gameboywidget, &GameboyWidget::updateImage);
    QObject::connect(ui->gameboywidget, SIGNAL(newInput(uint8_t)), &gb_, SLOT(handleNewInput(uint8_t)));
    QObject::connect(ui->exit, &QAction::triggered, QApplication::instance(), &QCoreApplication::quit);
    ui->gameboywidget->setFocus();
}