input_device_provider.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib 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 ClanLib 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 
31 #pragma once
32 
33 #include "../api_display.h"
34 #include "../Window/input_device.h"
35 #include "../../Core/System/disposable_object.h"
36 #include <memory>
37 #include "../../Core/Signals/signal_v1.h"
38 
39 namespace clan
40 {
43 
45 class CL_API_DISPLAY InputDeviceProvider : public DisposableObject
46 {
49 
50 public:
51  virtual ~InputDeviceProvider() { return; }
52 
56 
57 public:
59  virtual std::string get_name() const = 0;
60 
62  virtual std::string get_device_name() const = 0;
63 
65  virtual InputDevice::Type get_type() const = 0;
66 
68 
70  virtual std::string get_key_name(int id) const = 0;
71 
73  virtual bool supports_keyid_mapping() const { return false; }
74 
76  virtual std::string keyid_to_string(int /* keycode */) const { return std::string(); }
77 
79  virtual int string_to_keyid(const std::string &/* str */) const { return 0; }
80 
82 
83  virtual bool get_keycode(int keycode) const = 0;
84 
86 
87  virtual int get_x() const = 0;
88 
90 
91  virtual int get_y() const = 0;
92 
94  virtual float get_axis(int index) const = 0;
95 
97  virtual std::vector<int> get_axis_ids() const = 0;
98 
101  virtual int get_hat(int /* index */) const { return -1; }
102 
104 
105  virtual int get_button_count() const = 0;
106 
108 
109  virtual bool in_proximity() const = 0;
110 
114 
115 public:
117 
119  virtual void init(Signal_v1<const InputEvent &> *sig_provider_event) = 0;
120 
122  virtual void set_position(int x, int y) = 0;
123 
127 
128 private:
130 };
131 
132 }
133 
virtual int string_to_keyid(const std::string &) const
Returns the key code for the specified generic string key name.
Definition: input_device_provider.h:79
virtual std::string keyid_to_string(int) const
Returns a generic string name for the specified key code.
Definition: input_device_provider.h:76
DisposableObject.
Definition: disposable_object.h:37
Type
Input device types.
Definition: input_device.h:52
virtual int get_hat(int) const
Returns the current position of a joystick hat.
Definition: input_device_provider.h:101
virtual bool supports_keyid_mapping() const
Returns true if this provider implements keyid to/from string mapping.
Definition: input_device_provider.h:73
Signal_v1.
Definition: signal_v1.h:110
virtual ~InputDeviceProvider()
Definition: input_device_provider.h:51
Interface for implementing a InputDevice source.
Definition: input_device_provider.h:45