4 // Copyright (C) 2014 Thomas Geymayer <tomgey@gmail.com>
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Library General Public License for more details.
16 // You should have received a copy of the GNU Library General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef CANVAS_KEYBOARD_EVENT_HXX_
21 #define CANVAS_KEYBOARD_EVENT_HXX_
23 #include "DeviceEvent.hxx"
31 * Keyboard (button up/down) event
40 DOM_KEY_LOCATION_STANDARD = 0,
41 DOM_KEY_LOCATION_LEFT,
42 DOM_KEY_LOCATION_RIGHT,
43 DOM_KEY_LOCATION_NUMPAD
47 KeyboardEvent(const osgGA::GUIEventAdapter& ea);
49 void setKey(uint32_t key);
50 void setUnmodifiedKey(uint32_t key);
51 void setRepeat(bool repeat);
53 std::string key() const;
54 DOMKeyLocation location() const;
55 bool repeat() const { return _repeat; }
57 uint32_t charCode() const { return _key; }
58 uint32_t keyCode() const { return _unmodified_key; }
60 /// Whether the key which has triggered this event is a modifier
61 bool isModifier() const;
63 /// Whether this events represents an input of a printable character
67 uint32_t _key, //!< Key identifier for this event
68 _unmodified_key; //!< Virtual key identifier without any
70 bool _repeat; //!< If key has been depressed long enough to
71 // generate key repetition
73 mutable std::string _name; //!< Printable representation/name
74 mutable uint8_t _location; //!< Location of the key on the keyboard
79 } // namespace simgear
81 #endif /* CANVAS_KEYBOARD_EVENT_HXX_ */