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
00083 CL_InputDevice(const CL_InputDevice ©);
00084
00085 ~CL_InputDevice();
00086
00090
00091 public:
00093 CL_InputDeviceProvider *get_provider() const;
00094
00096 CL_String get_name() const;
00097
00099 CL_String get_device_name() const;
00100
00102 Type get_type() const;
00103
00105
00107 CL_String get_key_name(int id) const;
00108
00110 CL_String keyid_to_string(int keycode) const;
00111
00113 int string_to_keyid(const CL_String &str) const;
00114
00116
00117 bool get_keycode(int keycode) const;
00118
00120
00121 CL_Point get_position() const;
00122
00124
00125 int get_x() const;
00126
00128
00129 int get_y() const;
00130
00132 double get_axis(int index) const;
00133
00135 int get_axis_count() const;
00136
00138
00139 int get_button_count() const;
00140
00142
00143 bool in_proximity() const;
00144
00148
00149 public:
00150 CL_InputDevice &operator =(const CL_InputDevice ©);
00151
00153
00154 void set_position(int x, int y);
00155
00161 bool poll(bool peek_only);
00162
00166
00167 public:
00169 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_down();
00170
00172 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_up();
00173
00175 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_pointer_move();
00176
00178 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_ball_move();
00179
00181 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_axis_move();
00182
00184 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_key_dblclk();
00185
00187 CL_Signal_v2<const CL_InputEvent &, const CL_InputState &> &sig_proximity_change();
00188
00192
00193 private:
00194 CL_SharedPtr<CL_InputDevice_Impl> impl;
00195
00196 friend class CL_InputContext_Impl;
00198 };
00199