Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KeyEventSource now produces an instance of KeyEvent.
- Loading branch information
Showing
7 changed files
with
111 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "gui/keyevent.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** @file keyevent.h Input event from a keyboard. | ||
* | ||
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program 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 General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef LIBGUI_KEYEVENT_H | ||
#define LIBGUI_KEYEVENT_H | ||
|
||
#include "libgui.h" | ||
#include "ddkey.h" | ||
#include <de/Event> | ||
#include <de/String> | ||
|
||
namespace de { | ||
|
||
/** | ||
* Input event generated by a keyboard device. @ingroup ui | ||
*/ | ||
class LIBGUI_PUBLIC KeyEvent : public de::Event | ||
{ | ||
public: | ||
enum State | ||
{ | ||
Released, ///< Released key. | ||
Pressed ///< Pressed key. | ||
}; | ||
|
||
public: | ||
KeyEvent(); | ||
|
||
KeyEvent(State keyState, int qtKeyCode, int ddKeyCode, int nativeKeyCode, de::String const &keyText); | ||
|
||
State state() const; | ||
inline int qtKey() const { return _qtKey; } | ||
inline int ddKey() const { return _ddKey; } | ||
inline int nativeCode() const { return _nativeCode; } | ||
inline de::String const &text() const { return _text; } | ||
|
||
/** | ||
* Translates a Qt key code to a Doomsday key code (see ddkey.h). | ||
* | ||
* @param qtKey Qt key code. | ||
* @param nativeVirtualKey Native virtual key code. | ||
* @param nativeScanCode Native scan code. | ||
* | ||
* @return DDKEY code. | ||
*/ | ||
static int ddKeyFromQt(int qtKey, int nativeVirtualKey, int nativeScanCode); | ||
|
||
private: | ||
int _qtKey; | ||
int _ddKey; | ||
int _nativeCode; | ||
de::String _text; | ||
}; | ||
|
||
} // namespace de | ||
|
||
#endif // LIBGUI_KEYEVENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters