00001 00002 00003 00004 #ifndef GOSU_INPUT_HPP 00005 #define GOSU_INPUT_HPP 00006 00007 #include <Gosu/Fwd.hpp> 00008 #include <Gosu/Platform.hpp> 00009 00010 #ifdef GOSU_IS_WIN 00011 #include <Gosu/ButtonsWin.hpp> 00012 #include <windows.h> 00013 #endif 00014 00015 #ifdef GOSU_IS_MAC 00016 #include <Gosu/ButtonsMac.hpp> 00017 #endif 00018 00019 #ifdef GOSU_IS_X 00020 #include <X11/Xlib.h> 00021 #include <X11/Xutil.h> 00022 #include <X11/keysym.h> 00023 #include <Gosu/ButtonsX.hpp> 00024 #endif 00025 00026 #include <Gosu/Platform.hpp> 00027 #include <Gosu/Fwd.hpp> 00028 #include <boost/function.hpp> 00029 #include <boost/scoped_ptr.hpp> 00030 #include <vector> 00031 00032 namespace Gosu 00033 { 00035 class Button 00036 { 00037 unsigned id; 00038 00039 public: 00041 explicit Button(unsigned id) : id(id) {} 00043 unsigned getId() const { return id; } 00044 00046 Button() : id(noButton) {} 00047 00049 Button(ButtonName name) : id(name) {} 00050 }; 00051 00052 // Available even on non-iPhone platforms to make it easier to compile the 00053 // same source for multiple platforms. 00054 00057 struct Touch 00058 { 00060 void* id; 00062 double x, y; 00063 }; 00064 typedef std::vector<Touch> Touches; 00065 00067 inline bool operator==(Button lhs, Button rhs) 00068 { 00069 return lhs.getId() == rhs.getId(); 00070 } 00071 inline bool operator!=(Button lhs, Button rhs) 00072 { 00073 return !(lhs == rhs); 00074 } 00075 00078 class Input 00079 { 00080 struct Impl; 00081 boost::scoped_ptr<Impl> pimpl; 00082 00083 public: 00084 #ifdef GOSU_IS_WIN 00085 Input(HWND window); 00086 #endif 00087 00088 #ifdef GOSU_IS_MAC 00089 #ifdef GOSU_IS_IPHONE 00090 Input(); 00091 #else 00092 Input(void* nswindow); 00093 bool feedNSEvent(void* event); 00094 #endif 00095 #endif 00096 00097 #ifdef GOSU_IS_X 00098 Input(::Display* display, ::Window window); 00099 bool feedXEvent(::XEvent& event); 00100 #endif 00101 00102 ~Input(); 00103 00105 static wchar_t idToChar(Button btn); 00108 static Button charToId(wchar_t ch); 00109 00112 bool down(Button btn) const; 00113 00116 double mouseX() const; 00118 double mouseY() const; 00119 00123 void setMousePosition(double x, double y); 00124 00125 // Undocumented for the moment. 00126 void setMouseFactors(double factorX, double factorY); 00127 00130 void update(); 00131 00134 boost::function<void (Button)> onButtonDown, onButtonUp; 00135 00137 TextInput* textInput() const; 00139 void setTextInput(TextInput* input); 00140 }; 00141 } 00142 00143 #endif
Documentation not clear enough? Please go to one of the places listed on http://www.libgosu.org/ and leave feedback. Thanks!