Exemplo n.º 1
0
void
FBGui::checkForData()
{
    // GNASH_REPORT_FUNCTION;

    std::vector<boost::shared_ptr<InputDevice> >::iterator it;

    for (it=_inputs.begin(); it!=_inputs.end(); ++it) {
        (*it)->check();
        boost::shared_ptr<InputDevice::input_data_t> ie = (*it)->popData();
        if (ie) {            
            // notifyMouseMove(ie->x, ie->y);
#if 0
            std::cerr << "Got data: " << ((ie->pressed) ? "true" : "false");
            std::cerr << ", " << ie->key << ", " << ie->modifier;
            std::cerr << ", " << ie->x << ", " << ie->y << std::endl;
            // cerr << "X = " << coords[0] << endl;
            // cerr << "Y = " << coords[1] << endl;
#endif
            // Range check and convert the position from relative to
            // absolute
            boost::shared_array<int> coords =
                InputDevice::convertAbsCoords(ie->x, ie->y,
                                              getStage()->getStageWidth(),
                                              getStage()->getStageHeight());
#ifdef HAVE_LINUX_UINPUT_H
            // The mouse was moved
            _uinput.moveTo(coords[0], coords[1]);
            if (coords) {
                notifyMouseMove(coords[0], coords[1]);
            }
#endif
            
            // See if a mouse button was clicked
            if (ie->pressed) {
                notifyMouseClick(true);
#if 1
                double x = 0.655 * ie->x;
                double y = 0.46875 * ie->y;
                // log_debug("Mouse clicked at: %g:%g", x, y);
                notifyMouseMove(int(x), int(y));
#else
                notifyMouseMove(ie->x, ie->y);
#endif  
            }
        }
    }
}
Exemplo n.º 2
0
void
Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed) 
{

    // Handle GUI shortcuts
    if (pressed) {
        if (k == gnash::key::ESCAPE) {
            if (isFullscreen()) {
                _stage->setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
            }
        }
	
        if (modifier & gnash::key::GNASH_MOD_CONTROL) {
            switch (k) {
              case gnash::key::o:
              case gnash::key::O:
                  takeScreenShot();
                  break;
              case gnash::key::r:
              case gnash::key::R:
                  restart();
                  break;
              case gnash::key::p:
              case gnash::key::P:
                  pause();
                  break;
              case gnash::key::l:
              case gnash::key::L:
                  refreshView();
                  break;
              case gnash::key::q:
              case gnash::key::Q:
              case gnash::key::w:
              case gnash::key::W:
                  quit();
                  break;
              case gnash::key::f:
              case gnash::key::F:
                  toggleFullscreen();
                  break;
              case gnash::key::h:
              case gnash::key::H:
                  showUpdatedRegions(!showUpdatedRegions());
                  break;
              case gnash::key::MINUS:
              {
                  // Max interval allowed: 1 second (1FPS)
                  const size_t ni = std::min<size_t>(_interval + 2, 1000u);
                  setInterval(ni);
                  break;
              }
              case gnash::key::PLUS:
              {
                  // Min interval allowed: 1/100 second (100FPS)
                  const size_t ni = std::max<size_t>(_interval - 2, 10u);
                  setInterval(ni);
                  break;
              }
              case gnash::key::EQUALS:
              {
                  if (_stage) {
                      const float fps = _stage->getRootMovie().frameRate();
                      // Min interval allowed: 1/100 second (100FPS)
                      const size_t ni = 1000.0/fps;
                      setInterval(ni);
                  }
                  break;
              }
              default:
                  break;
            }
            
#ifdef ENABLE_KEYBOARD_MOUSE_MOVEMENTS
            if ( _keyboardMouseMovements ) {
                int step = _keyboardMouseMovementsStep; 
                // x5 if SHIFT is pressed
                if (modifier & gnash::key::GNASH_MOD_SHIFT) step *= 5; 
                switch (k) {
                  case gnash::key::UP:
                  {
                      int newx = _xpointer;
                      int newy = _ypointer-step;
                      if ( newy < 0 ) newy=0;
                      notifyMouseMove(newx, newy);
                      break;
                  }
                  case gnash::key::DOWN:
                  {
                      int newx = _xpointer;
                      int newy = _ypointer+step;
                      if ( newy >= _height ) newy = _height-1;
                      notifyMouseMove(newx, newy);
                      break;
                  }
                  case gnash::key::LEFT:
                  {
                      int newx = _xpointer-step;
                      int newy = _ypointer;
                      if ( newx < 0 ) newx = 0;
                      notifyMouseMove(newx, newy);
                      break;
                  }
                  case gnash::key::RIGHT:
                  {
                      const int newy = _ypointer;
                      int newx = _xpointer + step;
                      if ( newx >= _width ) newx = _width-1;
                      notifyMouseMove(newx, newy);
                      break;
                  }
                  default:
                      break;
                }
            }
#endif // ENABLE_KEYBOARD_MOUSE_MOVEMENTS
        }
    }
    
    if (!_started) return;
    
    if (_stopped) return;
    
    if (_stage->keyEvent(k, pressed)) {
        // any action triggered by the
        // event required screen refresh
        display(_stage);
    }
    
}