1 /** @file hatinputcontrol.h  Hat control for a logical input device.
2  *
3  * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  * @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
5  *
6  * @par License
7  * GPL: http://www.gnu.org/licenses/gpl.html
8  *
9  * <small>This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version. This program is distributed in the hope that it
13  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details. You should have received a copy of the GNU
16  * General Public License along with this program; if not, see:
17  * http://www.gnu.org/licenses</small>
18  */
19 
20 #ifndef CLIENT_UI_HATINPUTCONTROL_H
21 #define CLIENT_UI_HATINPUTCONTROL_H
22 
23 #include "inputdevice.h"
24 
25 /**
26  * Models a hat control on a "physical" input device (such as that found on joysticks).
27  *
28  * @ingroup ui
29  */
30 class HatInputControl : public InputDevice::Control
31 {
32 public:
33     explicit HatInputControl(de::String const &name = de::String());
34     virtual ~HatInputControl();
35 
36     /**
37      * Returns the current position of the hat.
38      */
39     de::dint position() const;
40 
41     /**
42      * @param newPosition  @c -1= centered.
43      */
44     void setPosition(de::dint newPosition);
45 
46     /**
47      * When the state of the control last changed, in milliseconds since app init.
48      */
49     de::duint time() const;
50 
51     de::String description() const;
52     bool inDefaultState() const;
53 
54 private:
55     de::dint _pos   = -1;  ///< Current position. @c -1= centered.
56     de::duint _time = 0;   ///< Timestamp of the latest change.
57 };
58 
59 #endif // CLIENT_UI_HATINPUTCONTROL_H
60