Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2011, 11:27:05 AM (13 years ago)
Author:
dafrick
Message:

Merging latest changes in usability branch into tutorial branch.

Location:
code/branches/tutorial
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutorial

  • code/branches/tutorial/src/libraries/core/input/InputManager.cc

    r7874 r8051  
    641641        state->destroy();
    642642    }
     643
     644    bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
     645    {
     646        if (name == "empty")
     647        {
     648            COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;
     649            return false;
     650        }
     651        std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
     652        if (it != statesByName_.end())
     653        {
     654            it->second->setMouseExclusive(value);
     655            return true;
     656        }
     657        return false;
     658    }
    643659}
  • code/branches/tutorial/src/libraries/core/input/InputManager.h

    r7874 r8051  
    163163        */
    164164        bool destroyState(const std::string& name); // tolua_export
     165        /**
     166        @brief
     167            Changes the mouse mode of an input state.
     168        @return
     169            True if the call was successful, fals if the name was not found
     170        */
     171        bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
    165172
    166173        //-------------------------------
  • code/branches/tutorial/src/libraries/core/input/Keyboard.cc

    r6422 r8051  
    3636    {
    3737        // update modifiers
    38         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    39             modifiers_ |= KeyboardModifier::Alt;   // alt key
    40         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    41             modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
    42         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    43             modifiers_ |= KeyboardModifier::Shift; // shift key
     38        switch (arg.key)
     39        {
     40            case OIS::KC_RMENU:
     41            case OIS::KC_LMENU:
     42                modifiers_ |= KeyboardModifier::Alt;   // alt key
     43                break;
     44            case OIS::KC_RCONTROL:
     45            case OIS::KC_LCONTROL:
     46                modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
     47                break;
     48            case OIS::KC_RSHIFT:
     49            case OIS::KC_LSHIFT:
     50                modifiers_ |= KeyboardModifier::Shift; // shift key
     51                break;
     52            case OIS::KC_TAB:
     53                // Do not distribute the alt+tab event (messes with the operating system)
     54                if ((modifiers_ & KeyboardModifier::Alt) != 0)
     55                    return true;
     56            default:;
     57        }
    4458
    45         // Do not distribute the alt+tab event (messes with the operating system)
    46         if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB)
    47             return true;
    48 
    49         KeyEvent evt(arg);
     59        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    5060        super::buttonPressed(evt);
    5161        return true;
     
    5666    {
    5767        // update modifiers
    58         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    59             modifiers_ &= ~KeyboardModifier::Alt;   // alt key
    60         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    61             modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
    62         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    63             modifiers_ &= ~KeyboardModifier::Shift; // shift key
     68        switch (arg.key)
     69        {
     70            case OIS::KC_RMENU:
     71            case OIS::KC_LMENU:
     72                modifiers_ &= ~KeyboardModifier::Alt;   // alt key
     73                break;
     74            case OIS::KC_RCONTROL:
     75            case OIS::KC_LCONTROL:
     76                modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
     77                break;
     78            case OIS::KC_RSHIFT:
     79            case OIS::KC_LSHIFT:
     80                modifiers_ &= ~KeyboardModifier::Shift; // shift key
     81                break;
     82            default:;
     83        }
    6484
    65         KeyEvent evt(arg);
     85        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    6686        super::buttonReleased(evt);
    6787        return true;
    6888    }
     89
     90    /// A map which returns the corresponding chars for some key codes
     91    unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg)
     92    {
     93        switch (arg.key)
     94        {
     95            case OIS::KC_NUMPAD0:     return static_cast<unsigned int>('0');
     96            case OIS::KC_NUMPAD1:     return static_cast<unsigned int>('1');
     97            case OIS::KC_NUMPAD2:     return static_cast<unsigned int>('2');
     98            case OIS::KC_NUMPAD3:     return static_cast<unsigned int>('3');
     99            case OIS::KC_NUMPAD4:     return static_cast<unsigned int>('4');
     100            case OIS::KC_NUMPAD5:     return static_cast<unsigned int>('5');
     101            case OIS::KC_NUMPAD6:     return static_cast<unsigned int>('6');
     102            case OIS::KC_NUMPAD7:     return static_cast<unsigned int>('7');
     103            case OIS::KC_NUMPAD8:     return static_cast<unsigned int>('8');
     104            case OIS::KC_NUMPAD9:     return static_cast<unsigned int>('9');
     105            case OIS::KC_DECIMAL:     return static_cast<unsigned int>('.');
     106            case OIS::KC_DIVIDE:      return static_cast<unsigned int>('/');
     107            case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n');
     108            default:                  return arg.text;
     109        }
     110    }
    69111}
  • code/branches/tutorial/src/libraries/core/input/Keyboard.h

    r7809 r8051  
    8383        static std::string getClassNameImpl() { return "Keyboard"; }
    8484
     85        static unsigned int getKeyText(const OIS::KeyEvent& arg);
     86
    8587        //! Bit mask representing keyboard modifiers
    8688        int modifiers_;
Note: See TracChangeset for help on using the changeset viewer.