Go to the documentation of this file.00001
00002 #ifdef LINUX
00003
00004 #include <blort/GLWindow/GLWindow.h>
00005
00006 namespace blortGLWindow{
00007
00008 void MapMouse(unsigned int xbutton, Input &input);
00009 void MapKey(KeySym ks, Input &input);
00010
00011 bool GLWindow::GetEvent(Event &event){
00012
00013 if(XPending(dpy)){
00014 XEvent xev;
00015
00016
00017 if( XCheckWindowEvent(dpy, glWin, KeyPressMask, &xev) )
00018 {
00019 event.type = TMGL_Press;
00020 KeySym ks = XKeycodeToKeysym(dpy, xev.xkey.keycode, 0);
00021 MapKey(ks, event.input);
00022 }
00023
00024 else if(XCheckWindowEvent(dpy, glWin, KeyReleaseMask, &xev))
00025 {
00026 event.type = TMGL_Release;
00027 KeySym ks = XKeycodeToKeysym(dpy, xev.xkey.keycode, 0);
00028 MapKey(ks, event.input);
00029 }
00030
00031 else if(XCheckWindowEvent(dpy, glWin, ButtonPressMask, &xev))
00032 {
00033 event.type = TMGL_Press;
00034 MapMouse(xev.xbutton.button, event.input);
00035 }
00036
00037 else if(XCheckWindowEvent(dpy, glWin, ButtonReleaseMask, &xev))
00038 {
00039 event.type = TMGL_Release;
00040 MapMouse(xev.xbutton.button, event.input);
00041 }
00042
00043 else if(XCheckWindowEvent(dpy, glWin, PointerMotionMask, &xev))
00044 {
00045 event.type = TMGL_Motion;
00046 event.motion.x = xev.xmotion.x;
00047 event.motion.y = xev.xmotion.y;
00048 }
00049
00050 else if(XCheckWindowEvent(dpy, glWin, ExposureMask, &xev))
00051 {
00052 XWindowAttributes gwa;
00053 event.type = TMGL_Expose;
00054 XGetWindowAttributes(dpy, glWin, &gwa);
00055 event.expose.width = gwa.width;
00056 event.expose.height = gwa.height;
00057 }
00058
00059
00060 else
00061 {
00062 return false;
00063 }
00064
00065 return true;
00066 }
00067 return false;
00068 }
00069
00070 void MapMouse(unsigned int xbutton, Input &input)
00071 {
00072 switch(xbutton)
00073 {
00074 case Button1:
00075 input = TMGL_Button1;
00076 break;
00077 case Button2:
00078 input = TMGL_Button2;
00079 break;
00080 case Button3:
00081 input = TMGL_Button3;
00082 break;
00083 case Button4:
00084 input = TMGL_Button4;
00085 break;
00086 case Button5:
00087 input = TMGL_Button5;
00088 break;
00089 }
00090 }
00091
00092 void MapKey(KeySym ks, Input &input)
00093 {
00094 switch(ks)
00095 {
00096 case XK_0:
00097 input = TMGL_0;
00098 break;
00099 case XK_1:
00100 input = TMGL_1;
00101 break;
00102 case XK_2:
00103 input = TMGL_2;
00104 break;
00105 case XK_3:
00106 input = TMGL_3;
00107 break;
00108 case XK_4:
00109 input = TMGL_4;
00110 break;
00111 case XK_5:
00112 input = TMGL_5;
00113 break;
00114 case XK_6:
00115 input = TMGL_6;
00116 break;
00117 case XK_7:
00118 input = TMGL_7;
00119 break;
00120 case XK_8:
00121 input = TMGL_8;
00122 break;
00123 case XK_9:
00124 input = TMGL_9;
00125 break;
00126
00127 case XK_a:
00128 input = TMGL_a;
00129 break;
00130 case XK_b:
00131 input = TMGL_b;
00132 break;
00133 case XK_c:
00134 input = TMGL_c;
00135 break;
00136 case XK_d:
00137 input = TMGL_d;
00138 break;
00139 case XK_e:
00140 input = TMGL_e;
00141 break;
00142 case XK_f:
00143 input = TMGL_f;
00144 break;
00145 case XK_g:
00146 input = TMGL_g;
00147 break;
00148 case XK_h:
00149 input = TMGL_h;
00150 break;
00151 case XK_i:
00152 input = TMGL_i;
00153 break;
00154 case XK_j:
00155 input = TMGL_j;
00156 break;
00157 case XK_k:
00158 input = TMGL_k;
00159 break;
00160 case XK_l:
00161 input = TMGL_l;
00162 break;
00163 case XK_m:
00164 input = TMGL_m;
00165 break;
00166 case XK_n:
00167 input = TMGL_n;
00168 break;
00169 case XK_o:
00170 input = TMGL_o;
00171 break;
00172 case XK_p:
00173 input = TMGL_p;
00174 break;
00175 case XK_q:
00176 input = TMGL_q;
00177 break;
00178 case XK_r:
00179 input = TMGL_r;
00180 break;
00181 case XK_s:
00182 input = TMGL_s;
00183 break;
00184 case XK_t:
00185 input = TMGL_t;
00186 break;
00187 case XK_u:
00188 input = TMGL_u;
00189 break;
00190 case XK_v:
00191 input = TMGL_v;
00192 break;
00193 case XK_w:
00194 input = TMGL_w;
00195 break;
00196 case XK_x:
00197 input = TMGL_x;
00198 break;
00199 case XK_y:
00200 input = TMGL_y;
00201 break;
00202 case XK_z:
00203 input = TMGL_z;
00204 break;
00205
00206 case XK_space:
00207 input = TMGL_Space;
00208 break;
00209 case XK_BackSpace:
00210 input = TMGL_BackSpace;
00211 break;
00212 case XK_Tab:
00213 input = TMGL_Tab;
00214 break;
00215 case XK_Return:
00216 input = TMGL_Return;
00217 break;
00218 case XK_Pause:
00219 input = TMGL_Pause;
00220 break;
00221 case XK_Escape:
00222 input = TMGL_Escape;
00223 break;
00224 case XK_Delete:
00225 input = TMGL_Delete;
00226 break;
00227 case XK_Left:
00228 input = TMGL_Left;
00229 break;
00230 case XK_Up:
00231 input = TMGL_Up;
00232 break;
00233 case XK_Right:
00234 input = TMGL_Right;
00235 break;
00236 case XK_Down:
00237 input = TMGL_Down;
00238 break;
00239 case XK_Page_Up:
00240 input = TMGL_Page_Up;
00241 break;
00242 case XK_Page_Down:
00243 input = TMGL_Page_Down;
00244 break;
00245 case XK_End:
00246 input = TMGL_End;
00247 break;
00248 case XK_Begin:
00249 input = TMGL_Begin;
00250 break;
00251 case XK_KP_Enter:
00252 input = TMGL_Return;
00253 break;
00254 case XK_KP_Multiply:
00255 input = TMGL_KP_Multiply;
00256 break;
00257 case XK_KP_Add:
00258 input = TMGL_KP_Add;
00259 break;
00260 case XK_KP_Subtract:
00261 input = TMGL_KP_Subtract;
00262 break;
00263 case XK_KP_Divide:
00264 input = TMGL_KP_Divide;
00265 break;
00266 case XK_KP_0:
00267 input = TMGL_KP_0;
00268 break;
00269 case XK_KP_1:
00270 input = TMGL_KP_1;
00271 break;
00272 case XK_KP_2:
00273 input = TMGL_KP_2;
00274 break;
00275 case XK_KP_3:
00276 input = TMGL_KP_3;
00277 break;
00278 case XK_KP_4:
00279 input = TMGL_KP_4;
00280 break;
00281 case XK_KP_5:
00282 input = TMGL_KP_5;
00283 break;
00284 case XK_KP_6:
00285 input = TMGL_KP_6;
00286 break;
00287 case XK_KP_7:
00288 input = TMGL_KP_7;
00289 break;
00290 case XK_KP_8:
00291 input = TMGL_KP_8;
00292 break;
00293 case XK_KP_9:
00294 input = TMGL_KP_9;
00295 break;
00296 case XK_F1:
00297 input = TMGL_F1;
00298 break;
00299 case XK_F2:
00300 input = TMGL_F2;
00301 break;
00302 case XK_F3:
00303 input = TMGL_F3;
00304 break;
00305 case XK_F4:
00306 input = TMGL_F4;
00307 break;
00308 case XK_F5:
00309 input = TMGL_F5;
00310 break;
00311 case XK_F6:
00312 input = TMGL_F6;
00313 break;
00314 case XK_F7:
00315 input = TMGL_F7;
00316 break;
00317 case XK_F8:
00318 input = TMGL_F8;
00319 break;
00320 case XK_F9:
00321 input = TMGL_F9;
00322 break;
00323 case XK_F10:
00324 input = TMGL_F10;
00325 break;
00326 case XK_F11:
00327 input = TMGL_F11;
00328 break;
00329 case XK_F12:
00330 input = TMGL_F12;
00331 break;
00332 case XK_Shift_L:
00333 input = TMGL_Shift_L;
00334 break;
00335 case XK_Shift_R:
00336 input = TMGL_Shift_R;
00337 break;
00338 case XK_Control_L:
00339 input = TMGL_Control_L;
00340 break;
00341 case XK_Control_R:
00342 input = TMGL_Control_R;
00343 break;
00344 }
00345 }
00346
00347 }
00348
00349 #endif
00350
blort
Author(s): Michael Zillich,
Thomas Mörwald,
Johann Prankl,
Andreas Richtsfeld,
Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:25