summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerkeyboard.h
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-09-25 17:54:36 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-09-25 17:54:36 +0300
commit08969001e25397cc947b5aa027522d3cc7aa8c53 (patch)
tree7a9c84e758bebc54c8dc63716c7e92e8e250cb75 /indra/newview/llviewerkeyboard.h
parentc21812bf095de2defa4e61978b2659764c838abf (diff)
SL-6109 Mouse support ready
Diffstat (limited to 'indra/newview/llviewerkeyboard.h')
-rw-r--r--indra/newview/llviewerkeyboard.h82
1 files changed, 75 insertions, 7 deletions
diff --git a/indra/newview/llviewerkeyboard.h b/indra/newview/llviewerkeyboard.h
index 2bfe285be4..3ba033509c 100644
--- a/indra/newview/llviewerkeyboard.h
+++ b/indra/newview/llviewerkeyboard.h
@@ -43,6 +43,27 @@ public:
LLKeyFunc mFunction;
};
+class LLKeyboardBinding
+{
+public:
+ KEY mKey;
+ MASK mMask;
+ bool mIgnoreMask; // whether CTRL/ALT/SHIFT should be checked
+
+ LLKeyFunc mFunction;
+};
+
+class LLMouseBinding
+{
+public:
+ EMouseClickType mMouse;
+ MASK mMask;
+ bool mIgnoreMask; // whether CTRL/ALT/SHIFT should be checked
+
+ LLKeyFunc mFunction;
+};
+
+
typedef enum e_keyboard_mode
{
MODE_FIRST_PERSON,
@@ -53,6 +74,7 @@ typedef enum e_keyboard_mode
MODE_COUNT
} EKeyboardMode;
+class LLWindow;
void bind_keyboard_functions();
@@ -64,6 +86,8 @@ public:
Mandatory<std::string> key,
mask,
command;
+ Optional<std::string> mouse; // Note, not mandatory for the sake of backward campatibility
+ Optional<bool> ignore;
KeyBinding();
};
@@ -93,24 +117,68 @@ public:
S32 loadBindings(const std::string& filename); // returns number bound, 0 on error
S32 loadBindingsXML(const std::string& filename); // returns number bound, 0 on error
- EKeyboardMode getMode();
+ EKeyboardMode getMode() const;
+
+ BOOL modeFromString(const std::string& string, S32 *mode) const; // False on failure
+ BOOL mouseFromString(const std::string& string, EMouseClickType *mode) const;// False on failure
- BOOL modeFromString(const std::string& string, S32 *mode); // False on failure
+ void scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) const;
- void scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
+ // handleMouse() records state, scanMouse() goes through states, scanMouse(click) processes individual saved states after UI is done with them
+ BOOL handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK mask, EMouseClickType clicktype, BOOL down);
+ void LLViewerKeyboard::scanMouse();
private:
- S32 loadBindingMode(const LLViewerKeyboard::KeyMode& keymode, S32 mode);
- BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name);
+ bool scanKey(const LLKeyboardBinding* binding,
+ S32 binding_count,
+ KEY key,
+ MASK mask,
+ BOOL key_down,
+ BOOL key_up,
+ BOOL key_level,
+ bool repeat) const;
+
+ enum EMouseState
+ {
+ MOUSE_STATE_DOWN, // key down this frame
+ MOUSE_STATE_LEVEL, // clicked again fast, or never released
+ MOUSE_STATE_UP, // went up this frame
+ MOUSE_STATE_SILENT // notified about 'up', do not notify again
+ };
+ bool scanMouse(EMouseClickType click, EMouseState state) const;
+ bool scanMouse(const LLMouseBinding *binding,
+ S32 binding_count,
+ EMouseClickType mouse,
+ MASK mask,
+ EMouseState state) const;
+
+ S32 loadBindingMode(const LLViewerKeyboard::KeyMode& keymode, S32 mode);
+ BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const bool ignore, const std::string& function_name);
+ BOOL bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const bool ignore, const std::string& function_name);
+ void resetBindings();
// Hold all the ugly stuff torn out to make LLKeyboard non-viewer-specific here
- S32 mBindingCount[MODE_COUNT];
- LLKeyBinding mBindings[MODE_COUNT][MAX_KEY_BINDINGS];
+ // We process specific keys first, then keys that should ignore mask.
+ // This way with W+ignore defined to 'forward' and with ctrl+W tied to camera,
+ // pressing undefined Shift+W will do 'forward', yet ctrl+W will do 'camera forward'
+ // With A defined to 'turn', shift+A defined to strafe, pressing Shift+W+A will do strafe+forward
+ S32 mKeyBindingCount[MODE_COUNT];
+ S32 mKeyIgnoreMaskCount[MODE_COUNT];
+ S32 mMouseBindingCount[MODE_COUNT];
+ S32 mMouseIgnoreMaskCount[MODE_COUNT];
+ LLKeyboardBinding mKeyBindings[MODE_COUNT][MAX_KEY_BINDINGS];
+ LLKeyboardBinding mKeyIgnoreMask[MODE_COUNT][MAX_KEY_BINDINGS];
+ LLMouseBinding mMouseBindings[MODE_COUNT][MAX_KEY_BINDINGS];
+ LLMouseBinding mMouseIgnoreMask[MODE_COUNT][MAX_KEY_BINDINGS];
typedef std::map<U32, U32> key_remap_t;
key_remap_t mRemapKeys[MODE_COUNT];
std::set<KEY> mKeysSkippedByUI;
BOOL mKeyHandledByUI[KEY_COUNT]; // key processed successfully by UI
+
+ // This is indentical to what llkeyboard does (mKeyRepeated, mKeyLevel, mKeyDown e t c),
+ // just instead of remembering individually as bools, we record state as enum
+ EMouseState mMouseLevel[CLICK_COUNT]; // records of key state
};
extern LLViewerKeyboard gViewerKeyboard;