VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
InputArea.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef INPUTAREA_H
18 #define INPUTAREA_H
19 
20 #include <GameInput/KeyCodes.h>
21 #include <QKeyEvent>
22 #include <QMap>
23 #include <QQuickItem>
24 #include <QSet>
25 
46 class InputArea : public QQuickItem {
47  Q_OBJECT
48 public:
54  Q_ENUMS(Key_X)
55  enum Key_X {
59  Key_Button_B = 0x01030000,
60  };
61 
66  explicit InputArea(QQuickItem* parent = 0);
67 
72  static KeyCode convertQtKeyCode(int qtKeyCode);
73 
74 protected:
82  virtual void keyPressEvent(QKeyEvent* event) override;
90  virtual void keyReleaseEvent(QKeyEvent* event) override;
91 
92 private:
93  static QMap<int, KeyCode> sQtKeyConversionMap;
94 };
95 Q_DECLARE_METATYPE(InputArea*)
96 
97 #endif // INPUTAREA_H
virtual void keyPressEvent(QKeyEvent *event) override
Intercept QKeyEvent press and process the event.
virtual void keyReleaseEvent(QKeyEvent *event) override
Intercept QKeyEvent release and process the event.
static KeyCode convertQtKeyCode(int qtKeyCode)
Returns the KeyCode that corresponds Qt::Key code.
Ui module for gaining basic input event (i.e. keyboard) support on non-Android devices.
Definition: InputArea.h:46
KeyCode
Key codes used to uniquely identify hardware input keys.
Definition: KeyCodes.h:26
virtual bool event(QEvent *ev)
Represents a gamepad "B" button.
Definition: InputArea.h:59
InputArea(QQuickItem *parent=0)
Constructs an InputArea.
QObject * parent() const
Key_X
Defines an additional set of key codes to extend Qt::Key.
Definition: InputArea.h:55