Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2008, 9:31:20 PM (16 years ago)
Author:
rgrieder
Message:
  • SpaceShip is now a default listener for mouse input. still a hack..
  • several changes in InputManager.cc regarding joy sticks
  • Key bindings work, but not very advanced
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/InputHandler.cc

    r1213 r1215  
    267267        switch (j)
    268268        {
     269          // note: the first element in the struct is the string, so the following pointer
     270          //       arithmetic works.
    269271          case 0:
    270             cont->getValue(bindingsKeyPress_ + i);
     272            cont->getValue(&bindingsKeyPress_[i].commandStr);
    271273            break;
    272274          case 1:
     
    337339    for (int i = 0; i < numberOfKeys_s; i++)
    338340    {
    339       bindingsKeyPress_  [i] = "";
    340       bindingsKeyRelease_[i] = "";
    341       bindingsKeyHold_   [i] = "";
     341      bindingsKeyPress_  [i].commandStr = "";
     342      bindingsKeyRelease_[i].commandStr = "";
     343      bindingsKeyHold_   [i].commandStr = "";
    342344    }
    343345    for (int i = 0; i < numberOfMouseButtons_s; i++)
     
    366368    setConfigValues();
    367369
     370    // evaluate the key bindings
     371    // TODO: what if binding is invalid?
     372    //for (int i = 0; i < numberOfKeys_s; i++)
     373    //{
     374    //  if (bindingsKeyPress_[i].commandStr != "")
     375    //  {
     376    //    bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
     377    //    bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
     378    //  }
     379    //}
     380
    368381    COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
     382    return true;
     383  }
     384
     385  bool KeyBinder::executeBinding(KeyBinding& binding)
     386  {
     387    if (binding.commandStr != "")
     388    {
     389      //if (binding.commandStr != binding.evaluation.getCommandString())
     390      //{
     391      //  // key binding has changed, reevaluate the command string.
     392      //  binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
     393      //  binding.commandStr = binding.evaluation.getCommandString();
     394      //}
     395      COUT(3) << "Executing command: " << binding.commandStr << std::endl;
     396      CommandExecutor::execute(binding.commandStr);
     397    }
     398
    369399    return true;
    370400  }
     
    379409    COUT(3) << "Key: " << e.key << std::endl;
    380410    // find the appropriate key binding
    381     std::string cmdStr = bindingsKeyPress_[int(e.key)];
    382     if (cmdStr != "")
    383     {
    384       CommandExecutor::execute(cmdStr);
    385       COUT(3) << "Executing command: " << cmdStr << std::endl;
    386     }
    387    
     411    executeBinding(bindingsKeyPress_[int(e.key)]);
     412     
    388413    return true;
    389414  }
     
    396421  {
    397422    // find the appropriate key binding
    398     std::string cmdStr = bindingsKeyRelease_[int(e.key)];
    399     if (cmdStr != "")
    400     {
    401       CommandExecutor::execute(cmdStr);
    402       COUT(3) << "Executing command: " << cmdStr << std::endl;
    403     }
     423    executeBinding(bindingsKeyRelease_[int(e.key)]);
    404424
    405425    return true;
     
    413433  {
    414434    // find the appropriate key binding
    415     std::string cmdStr = bindingsKeyHold_[int(e.key)];
    416     if (cmdStr != "")
    417     {
    418       CommandExecutor::execute(cmdStr);
    419       COUT(3) << "Executing command: " << cmdStr << std::endl;
    420     }
     435    executeBinding(bindingsKeyHold_[int(e.key)]);
    421436
    422437    return true;
     
    486501  }
    487502
    488   bool KeyBinder::buttonPressed(const OIS::JoyStickEvent &arg, int button)
     503  bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    489504  {
    490505    // find the appropriate key binding
     
    499514  }
    500515
    501   bool KeyBinder::buttonReleased(const OIS::JoyStickEvent &arg, int button)
     516  bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    502517  {
    503518    // find the appropriate key binding
     
    512527  }
    513528
    514   bool KeyBinder::buttonHeld(const OIS::JoyStickEvent &arg, int button)
     529  bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    515530  {
    516531    // find the appropriate key binding
     
    525540  }
    526541
    527   bool KeyBinder::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    528   {
    529     return true;
    530   }
    531 
    532   bool KeyBinder::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    533   {
    534     return true;
    535   }
    536 
    537   bool KeyBinder::povMoved(const OIS::JoyStickEvent &arg, int id)
     542  bool KeyBinder::axisMoved(int joyStickID, const OIS::JoyStickEvent &arg, int axis)
     543  {
     544    return true;
     545  }
     546
     547  bool KeyBinder::sliderMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
     548  {
     549    return true;
     550  }
     551
     552  bool KeyBinder::povMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
     553  {
     554    return true;
     555  }
     556
     557  bool KeyBinder::vector3Moved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
    538558  {
    539559    return true;
Note: See TracChangeset for help on using the changeset viewer.