00001
00032 #ifndef LL_LLVIEWERKEYBOARD_H
00033 #define LL_LLVIEWERKEYBOARD_H
00034
00035 #include "llkeyboard.h"
00036
00037 const S32 MAX_NAMED_FUNCTIONS = 100;
00038 const S32 MAX_KEY_BINDINGS = 128;
00039
00040 class LLNamedFunction
00041 {
00042 public:
00043 const char *mName;
00044 LLKeyFunc mFunction;
00045 };
00046
00047 typedef enum e_keyboard_mode
00048 {
00049 MODE_FIRST_PERSON,
00050 MODE_THIRD_PERSON,
00051 MODE_EDIT,
00052 MODE_EDIT_AVATAR,
00053 MODE_SITTING,
00054 MODE_COUNT
00055 } EKeyboardMode;
00056
00057
00058 void agent_push_forward( EKeystate s );
00059 void agent_turn_right( EKeystate s );
00060 void bind_keyboard_functions();
00061
00062 class LLViewerKeyboard
00063 {
00064 public:
00065 LLViewerKeyboard();
00066
00067 BOOL handleKey(KEY key, MASK mask, BOOL repeated);
00068
00069 void bindNamedFunction(const char *name, LLKeyFunc func);
00070
00071 S32 loadBindings(const char *filename);
00072 EKeyboardMode getMode();
00073
00074 BOOL modeFromString(const char *string, S32 *mode);
00075
00076 void scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
00077 protected:
00078 BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const char *function_name);
00079 S32 mNamedFunctionCount;
00080 LLNamedFunction mNamedFunctions[MAX_NAMED_FUNCTIONS];
00081
00082
00083 S32 mBindingCount[MODE_COUNT];
00084 LLKeyBinding mBindings[MODE_COUNT][MAX_KEY_BINDINGS];
00085
00086 typedef std::map<U32, U32> key_remap_t;
00087 key_remap_t mRemapKeys[MODE_COUNT];
00088 std::set<KEY> mKeysSkippedByUI;
00089 BOOL mKeyHandledByUI[KEY_COUNT];
00090 };
00091
00092 extern LLViewerKeyboard gViewerKeyboard;
00093
00094 #endif // LL_LLVIEWERKEYBOARD_H