trikRuntime
keys.h
Go to the documentation of this file.
1 /* Copyright 2013 - 2015 Matvey Bryksin, Yurii Litvinov and CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QObject>
18 #include <QtCore/QThread>
19 #include <QtCore/QScopedPointer>
20 #include <QtCore/QHash>
21 
22 #include "keysInterface.h"
23 #include "deviceState.h"
24 
25 namespace trikKernel {
26 class Configurer;
27 }
28 
29 namespace trikHal {
30 class HardwareAbstractionInterface;
31 }
32 
33 namespace trikControl {
34 
35 class KeysWorker;
36 
38 class Keys : public KeysInterface
39 {
40  Q_OBJECT
41 
42 public:
45  Keys(const trikKernel::Configurer &configurer, const trikHal::HardwareAbstractionInterface &hardwareAbstraction);
46 
47  ~Keys() override;
48 
49  Status status() const override;
50 
51 public slots:
52  void reset() override;
53 
54  bool wasPressed(int code) override;
55 
56  bool isPressed(int code) override;
57 
58  int buttonCode(bool wait = true) override;
59 
60 private slots:
61  void changeButtonState(int code, int value);
62 
63 private:
64  int pressedButton();
65 
67  DeviceState mState;
68 
69  QScopedPointer<KeysWorker> mKeysWorker;
70  QThread mWorkerThread;
71  QHash<int, int> mKeysPressed;
72 };
73 
74 }
Definition: analogSensor.h:23
Generic configuration helper, parses configuration XML files and presents configuration as a set of a...
Definition: configurer.h:28
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
Implementation of handler for keys on a brick for a real robot.
Definition: keys.h:38
Class for handling keys on a brick.
Definition: keysInterface.h:26
Definition: brickFactory.h:21
Hardware abstraction, provides devices that are used to communicate with robot hardware or emulate it...
Definition: hardwareAbstractionInterface.h:29