From 930710ceecf32c12af5d6e416a4697f9eb9df8aa Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Thu, 17 Feb 2011 15:50:44 -0800 Subject: Added an EventAPI listener to LLWindow for hooking into key and mouse inputs. --- indra/llwindow/llwindowlistener.h | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 indra/llwindow/llwindowlistener.h (limited to 'indra/llwindow/llwindowlistener.h') diff --git a/indra/llwindow/llwindowlistener.h b/indra/llwindow/llwindowlistener.h new file mode 100644 index 0000000000..5b234c5d1d --- /dev/null +++ b/indra/llwindow/llwindowlistener.h @@ -0,0 +1,53 @@ +/** + * @file llwindowlistener.h + * @brief EventAPI interface for injecting input into LLWindow + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLWINDOWLISTENER_H +#define LL_LLWINDOWLISTENER_H + +#include "lleventapi.h" + +class LLKeyboard; +class LLWindowCallbacks; + +class LLWindowListener : public LLEventAPI +{ +public: + LLWindowListener(LLWindowCallbacks * window, LLKeyboard * keyboard); + + void keyDown(LLSD const & evt); + void keyUp(LLSD const & evt); + void mouseDown(LLSD const & evt); + void mouseUp(LLSD const & evt); + void mouseMove(LLSD const & evt); + void mouseScroll(LLSD const & evt); + +private: + LLWindowCallbacks * mWindow; + LLKeyboard * mKeyboard; +}; + + +#endif // LL_LLWINDOWLISTENER_H -- cgit v1.2.3 From 3f3429fa6854c6462abf3bbabf4af1dbbeb4c337 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 21 Mar 2011 17:38:16 -0400 Subject: STORM-1051: Fixup to LLWindowListener per code review. Bug: capturing a const ref to value returned by LLSD::asString() not so good. Bug: LLWindowListener::keyUp() was calling handleTranslatedKeyDown(). In keyDown and keyUp, support keysym lookup (e.g. "TAB") as well as integer keycode. In keyDown, keyUp, mouseDown, mouseUp and mouseMove, support modifier mask by accepting an array of "CONTROL", "SHIFT" etc. strings. State in operation doc strings valid values for button, keycode, keysym, mask. The LLWindowListener(... LLKeyboard*) constructor param gKeyboard is always NULL at the time LLWindowListener is constructed. Eliminate tests and global references to gKeyboard by replacing with a more Feathers-style LLKeyboard* getter function. --- indra/llwindow/llwindowlistener.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llwindowlistener.h') diff --git a/indra/llwindow/llwindowlistener.h b/indra/llwindow/llwindowlistener.h index 5b234c5d1d..74e577ff93 100644 --- a/indra/llwindow/llwindowlistener.h +++ b/indra/llwindow/llwindowlistener.h @@ -28,6 +28,7 @@ #define LL_LLWINDOWLISTENER_H #include "lleventapi.h" +#include class LLKeyboard; class LLWindowCallbacks; @@ -35,7 +36,8 @@ class LLWindowCallbacks; class LLWindowListener : public LLEventAPI { public: - LLWindowListener(LLWindowCallbacks * window, LLKeyboard * keyboard); + typedef boost::function KeyboardGetter; + LLWindowListener(LLWindowCallbacks * window, const KeyboardGetter& kbgetter); void keyDown(LLSD const & evt); void keyUp(LLSD const & evt); @@ -46,7 +48,7 @@ public: private: LLWindowCallbacks * mWindow; - LLKeyboard * mKeyboard; + KeyboardGetter mKbGetter; }; -- cgit v1.2.3