PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llviewerkeyboard.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 117 lines | 68 code | 23 blank | 26 comment | 0 complexity | 81163e5a1258629f2f54de443f538754 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewerkeyboard.h
  3. * @brief LLViewerKeyboard class header file
  4. *
  5. * $LicenseInfo:firstyear=2005&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLVIEWERKEYBOARD_H
  27. #define LL_LLVIEWERKEYBOARD_H
  28. #include "llkeyboard.h" // For EKeystate
  29. #include "llinitparam.h"
  30. const S32 MAX_NAMED_FUNCTIONS = 100;
  31. const S32 MAX_KEY_BINDINGS = 128; // was 60
  32. class LLNamedFunction
  33. {
  34. public:
  35. LLNamedFunction() : mFunction(NULL) { };
  36. ~LLNamedFunction() { };
  37. std::string mName;
  38. LLKeyFunc mFunction;
  39. };
  40. typedef enum e_keyboard_mode
  41. {
  42. MODE_FIRST_PERSON,
  43. MODE_THIRD_PERSON,
  44. MODE_EDIT,
  45. MODE_EDIT_AVATAR,
  46. MODE_SITTING,
  47. MODE_COUNT
  48. } EKeyboardMode;
  49. void bind_keyboard_functions();
  50. class LLViewerKeyboard
  51. {
  52. public:
  53. struct KeyBinding : public LLInitParam::Block<KeyBinding>
  54. {
  55. Mandatory<std::string> key,
  56. mask,
  57. command;
  58. KeyBinding();
  59. };
  60. struct KeyMode : public LLInitParam::Block<KeyMode>
  61. {
  62. Multiple<KeyBinding> bindings;
  63. EKeyboardMode mode;
  64. KeyMode(EKeyboardMode mode);
  65. };
  66. struct Keys : public LLInitParam::Block<Keys>
  67. {
  68. Optional<KeyMode> first_person,
  69. third_person,
  70. edit,
  71. sitting,
  72. edit_avatar;
  73. Keys();
  74. };
  75. LLViewerKeyboard();
  76. BOOL handleKey(KEY key, MASK mask, BOOL repeated);
  77. S32 loadBindings(const std::string& filename); // returns number bound, 0 on error
  78. S32 loadBindingsXML(const std::string& filename); // returns number bound, 0 on error
  79. EKeyboardMode getMode();
  80. BOOL modeFromString(const std::string& string, S32 *mode); // False on failure
  81. void scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
  82. private:
  83. S32 loadBindingMode(const LLViewerKeyboard::KeyMode& keymode);
  84. BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name);
  85. // Hold all the ugly stuff torn out to make LLKeyboard non-viewer-specific here
  86. S32 mBindingCount[MODE_COUNT];
  87. LLKeyBinding mBindings[MODE_COUNT][MAX_KEY_BINDINGS];
  88. typedef std::map<U32, U32> key_remap_t;
  89. key_remap_t mRemapKeys[MODE_COUNT];
  90. std::set<KEY> mKeysSkippedByUI;
  91. BOOL mKeyHandledByUI[KEY_COUNT]; // key processed successfully by UI
  92. };
  93. extern LLViewerKeyboard gViewerKeyboard;
  94. #endif // LL_LLVIEWERKEYBOARD_H