input_device.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
30 #pragma once
31 
32 #include "../../Core/Signals/signal.h"
33 #include "../../Core/Math/point.h"
34 #include <memory>
35 
36 namespace uicore
37 {
38  class InputEvent;
39 
42  {
43  public:
45  enum Type
46  {
51  };
52 
54  virtual std::string name() const = 0;
55 
57  virtual std::string device_name() const = 0;
58 
60  virtual Type type() const = 0;
61 
64  // should only be used to display the name of the key to the user
65  // and not as a key identifier inside key binding configuration
66  // files and such.
67  virtual std::string key_name(int id) const = 0;
68 
70  virtual std::string keyid_to_string(int keycode) const = 0;
71 
73  virtual int string_to_keyid(const std::string &str) const = 0;
74 
77  virtual bool keycode(int keycode) const = 0;
78 
81  virtual Pointf position() const = 0;
82 
85  virtual Point device_position() const = 0;
86 
88  virtual float axis(int axisid) const = 0;
89 
91  virtual std::vector<int> axis_ids() const = 0;
92 
95  virtual int hat(int index) const = 0;
96 
99  virtual int button_count() const = 0;
100 
102  virtual void set_position(float x, float y) = 0;
103 
105  virtual void set_device_position(int x, int y) = 0;
106 
109 
112 
115 
118 
121 
124  };
125 
126  typedef std::shared_ptr<InputDevice> InputDevicePtr;
127 }
Definition: input_device.h:49
2D (x,y) point structure - Float
Definition: point.h:68
virtual std::string name() const =0
Returns the human readable name of the device (i.e. 'Microsoft Sidewinder 3D').
virtual Signal< void(const InputEvent &)> & sig_key_dblclk()=0
Signal emitted when the mouse is double-clicked.
virtual void set_position(float x, float y)=0
Sets the display-independent position of the device. (Pointing devices only)
virtual Type type() const =0
Returns the input device type.
virtual std::string device_name() const =0
Return the hardware id/device for this device (i.e. /dev/input/js0)
virtual Pointf position() const =0
Returns the current device-independent x and y position (DIP) of the device. (Pointing devices only) ...
Definition: input_device.h:48
InputDevice.
Definition: input_device.h:41
virtual int button_count() const =0
Returns the number of buttons available on this device. If used on a keyboard or mouse...
virtual Signal< void(const InputEvent &)> & sig_axis_move()=0
Signal emitted when axis is moved.
virtual void set_device_position(int x, int y)=0
Sets the actual position of the device. (Pointing devices only)
virtual std::string key_name(int id) const =0
Retrieves the localized friendly key name for specified identifier (i.e. A, B, Leertaste, Backspace, Mouse Left, ...).
Definition: input_device.h:47
2D (x,y) point structure - Integer
Definition: point.h:58
virtual Signal< void(const InputEvent &)> & sig_proximity_change()=0
Signal emitted when proximity is entered or exited.
virtual Signal< void(const InputEvent &)> & sig_pointer_move()=0
Signal emitted when pointer is moved (absolute movement).
Type
Input device types.
Definition: input_device.h:45
virtual std::vector< int > axis_ids() const =0
Returns the number of axes available on this device. (Joysticks only)
Definition: signal.h:101
virtual int hat(int index) const =0
Returns the current position of a joystick hat. (Joysticks only)
virtual Signal< void(const InputEvent &)> & sig_key_up()=0
Signal emitted when key is released.
virtual Point device_position() const =0
Returns the current devicesice-supplied x and y position of the device. (Pointing devices only) The r...
virtual Signal< void(const InputEvent &)> & sig_key_down()=0
Signal emitted when key is pressed.
virtual std::string keyid_to_string(int keycode) const =0
Returns a generic string name for the specified key code.
Definition: input_device.h:50
virtual float axis(int axisid) const =0
Returns the the current position of a joystick axis. (Joysticks only)
std::shared_ptr< InputDevice > InputDevicePtr
Definition: display_window.h:58
virtual int string_to_keyid(const std::string &str) const =0
Returns the key code for the specified generic string key name.
virtual bool keycode(int keycode) const =0
Returns true if the passed key code is down for this device. See keys.h for list of key codes...
Definition: Application/application.h:35