Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033 #pragma once
00034
00035 #include "../api_display.h"
00036 #include "../../Core/System/sharedptr.h"
00037 #include "../../Core/System/weakptr.h"
00038 #include "../../Core/Text/string_types.h"
00039 #include "../../Core/Signals/signal_v2.h"
00040 #include "../../Core/Math/point.h"
00041
00042 class CL_InputEvent;
00043 class CL_InputState;
00044 class CL_InputDeviceProvider;
00045 class CL_InputDevice_Impl;
00046
00050 class CL_API_DISPLAY CL_InputDevice
00051 {
00052 public:
00054 enum Type
00055 {
00056 keyboard,
00057 pointer,
00058 joystick,
00059 tablet,
00060 unknown
00061 };
00062
00065
00066 public:
00068 CL_InputDevice();
00069
00073 CL_InputDevice(CL_InputDeviceProvider *provider);
00074
00078 CL_InputDevice(CL_WeakPtr<CL_InputDevice_Impl> impl);
00079
00080 ~CL_InputDevice();
00081
00085
00086 public:
00088 bool is_null() const { return !impl; }
00089
00091 void throw_if_null() const;
00092
00094 CL_InputDeviceProvider *get_provider() const;
00095
00097 CL_String get_name() const;
00098
00100 CL_String get_device_name() const;
00101
00103 Type get_type() const;
00104
00106
00108 CL_String get_key_name(int id) const;
00109
00111 CL_String keyid_to_string(int keycode) const;
00112
00114 int string_to_keyid(const CL_String &str) const;
00115
00117
00118 bool get_keycode(int keycode) const;
00119
00121
00122 CL_Point get_position() const;
00123
00125
00126 int get_x() const;
00127
00129
00130 int get_y() const;
00131
00133 double get_axis(int index) const;
00134
00136 int get_axis_count() const;
00137
00139
00140 int get_button_count() const;
00141
00143
00144 bool in_proximity() const;
00145
00149
00150 public:
00151 CL_InputDevice &operator =(const CL_InputDevice ©);
00152
00154
00155 void set_position(int x, int y);
00156
00162 bool poll(bool peek_only);
00163
00167
00168 public:
00170 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_down();
00171
00173 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_up();
00174
00176 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_pointer_move();
00177
00179 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_axis_move();
00180
00182 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_dblclk();
00183
00185 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_proximity_change();
00186
00190
00191 private:
00192 CL_SharedPtr<CL_InputDevice_Impl> impl;
00193
00194 friend class CL_InputContext_Impl;
00196 };
00197