input_device.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
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 &copy);
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 &copy);
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 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6