1 /***********************************************************************
2     created:    Fri Feb 17 2012
3     author:     Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  *   Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7  *
8  *   Permission is hereby granted, free of charge, to any person obtaining
9  *   a copy of this software and associated documentation files (the
10  *   "Software"), to deal in the Software without restriction, including
11  *   without limitation the rights to use, copy, modify, merge, publish,
12  *   distribute, sublicense, and/or sell copies of the Software, and to
13  *   permit persons to whom the Software is furnished to do so, subject to
14  *   the following conditions:
15  *
16  *   The above copyright notice and this permission notice shall be
17  *   included in all copies or substantial portions of the Software.
18  *
19  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  *   OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUISystemKeys_h_
28 #define _CEGUISystemKeys_h_
29 
30 #include "CEGUI/InputEvent.h"
31 
32 namespace CEGUI
33 {
34 class CEGUIEXPORT SystemKeys
35 {
36 public:
37     enum SystemKey
38     {
39         None          = 0x0000,
40         LeftMouse     = 0x0001,
41         RightMouse    = 0x0002,
42         Shift         = 0x0004,
43         Control       = 0x0008,
44         MiddleMouse   = 0x0010,
45         X1Mouse       = 0x0020,
46         X2Mouse       = 0x0040,
47         Alt           = 0x0080
48     };
49 
50     SystemKeys();
51 
52     void reset();
53 
54     uint get() const;
55     bool isPressed(SystemKey key) const;
56 
57     //! notify that the given key was presed
58     void keyPressed(Key::Scan key);
59     //! notify that the given key was released.
60     void keyReleased(Key::Scan key);
61     //! notify that the given mouse button was pressed.
62     void mouseButtonPressed(MouseButton button);
63     //! notify that the given mouse button was released.
64     void mouseButtonReleased(MouseButton button);
65 
66     static SystemKey mouseButtonToSystemKey(MouseButton button);
67     static SystemKey keyCodeToSystemKey(Key::Scan key);
68 
69 private:
70     void updatePressedStateForKey(Key::Scan key, bool state);
71     void updateSystemKeyState(SystemKey syskey);
72 
73     uint d_current;
74 
75     bool d_leftShift;
76     bool d_rightShift;
77     bool d_leftCtrl;
78     bool d_rightCtrl;
79     bool d_leftAlt;
80     bool d_rightAlt;
81 };
82 
83 }
84 
85 #endif
86 
87