Changeset 48 for trunk/luigi/adapters
- Timestamp:
- 04/22/07 06:28:25 (2 years ago)
- Files:
-
- trunk/luigi/adapters/gld.d (modified) (4 diffs)
- trunk/luigi/adapters/glfw.d (modified) (4 diffs)
- trunk/luigi/adapters/sdl.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/adapters/gld.d
r42 r48 32 32 import luigi.adapter; 33 33 private import gld; 34 //import sslot.signal;35 34 import luigi.signalobj; 36 35 … … 159 158 { 160 159 _KeyEvent ev; 161 ev.key = translate_key(k); 162 m_lastKey = ev.key; 163 ev.ch = 0; 164 ev.is_press = (action==GLD_PRESS); 165 ev.mods = inst._getMods(); 166 ev.is_key = true; 167 ev.is_char = false; 168 inst.sig.key.emit(&ev); 160 void _initEvent() { 161 ev.key = translate_key(k); 162 m_lastKey = ev.key; 163 ev.ch = 0; 164 ev.is_press = (action==GLD_PRESS); 165 ev.mods = inst._getMods(); 166 ev.is_key = true; 167 ev.is_char = false; 168 } 169 _initEvent(); 170 inst.sig.sysKey.emit(&ev); 171 if (ev.alive) { 172 _initEvent(); 173 inst.sig.key.emit(&ev); 174 } 169 175 } 170 176 static void charCallbackC(int ch, int action) … … 177 183 // (e.g. european and asian) but it seems to be the case with GLD. 178 184 // Not every key has a char, but every char has a key in GLD 179 ev.key = m_lastKey; 180 ev.ch = ch; 181 ev.is_press = (action==GLD_PRESS); 182 ev.mods = inst._getMods(); 183 ev.is_key = false; 184 ev.is_char = true; 185 inst.sig.key.emit(&ev); 185 void _initEvent() { 186 ev.key = m_lastKey; 187 ev.ch = ch; 188 ev.is_press = (action==GLD_PRESS); 189 ev.mods = inst._getMods(); 190 ev.is_key = false; 191 ev.is_char = true; 192 } 193 _initEvent(); 194 inst.sig.sysKey.emit(&ev); 195 if (ev.alive) { 196 _initEvent(); 197 inst.sig.key.emit(&ev); 198 } 186 199 } 187 200 static void mouseButtonCallbackC(int button, int action) … … 190 203 int x,y; 191 204 gldGetMousePos(&x, &y); 192 ev.x = ev.winx = x; 193 ev.y = ev.winy = y; 194 ev.is_press = (action==GLD_PRESS); 195 ev.mods = inst._getMods(); 196 ev.pressed = inst._getButtons(); 197 if (button == GLD_MOUSE_BUTTON_LEFT) ev.button = MouseButtons.Left; 198 else if (button == GLD_MOUSE_BUTTON_RIGHT) ev.button = MouseButtons.Right; 199 else if (button == GLD_MOUSE_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 200 201 inst.sig.mouseButton.emit(&ev); 205 void _initEvent() { 206 ev.x = ev.winx = x; 207 ev.y = ev.winy = y; 208 ev.is_press = (action==GLD_PRESS); 209 ev.mods = inst._getMods(); 210 ev.pressed = inst._getButtons(); 211 if (button == GLD_MOUSE_BUTTON_LEFT) ev.button = MouseButtons.Left; 212 else if (button == GLD_MOUSE_BUTTON_RIGHT) ev.button = MouseButtons.Right; 213 else if (button == GLD_MOUSE_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 214 } 215 _initEvent(); 216 inst.sig.sysMouseButton.emit(&ev); 217 if (ev.alive) { 218 // reinit because GUI might much with it 219 _initEvent(); 220 inst.sig.mouseButton.emit(&ev); 221 } 202 222 } 203 223 static void mousePosCallbackC(int x, int y) trunk/luigi/adapters/glfw.d
r33 r48 5 5 luigi/adapter/glfw.d 6 6 -- GLFW input adapter for the 'Luigi' user interface library. 7 This was originally written for DerelictGLFW, but the Derelict 8 project has since decided to abandon the project. 9 There are supposedly D bindings distributed with GLFW, so you can 10 link to it directly without Derelict's help. 11 12 This is made to work with Derelict's former GLFW. Should be 13 easy to get it working with the D bindings that come with GLFW, or 14 just use GLD, the all-D native port of GLFW for D. 15 The Luigi GLD bindings are better tested than these. 7 16 8 17 Copyright (C) 2006 William V. Baxter III … … 159 168 { 160 169 _KeyEvent ev; 161 ev.key = translate_key(k); 162 m_lastKey = ev.key; 163 ev.ch = 0; 164 ev.is_press = (action==GLFW_PRESS); 165 ev.mods = inst._getMods(); 166 ev.is_key = true; 167 ev.is_char = false; 168 inst.sig.key.emit(&ev); 170 void _initEvent() { 171 ev.key = translate_key(k); 172 m_lastKey = ev.key; 173 ev.ch = 0; 174 ev.is_press = (action==GLFW_PRESS); 175 ev.mods = inst._getMods(); 176 ev.is_key = true; 177 ev.is_char = false; 178 } 179 _initEvent(); 180 inst.sig.sysKey.emit(&ev); 181 if (ev.alive) { 182 _initEvent(); 183 inst.sig.key.emit(&ev); 184 } 169 185 } 170 186 static void charCallbackC(int ch, int action) … … 177 193 // (e.g. european and asian) but it seems to be the case with GLFW. 178 194 // Not every key has a char, but every char has a key in GLFW 179 ev.key = m_lastKey; 180 ev.ch = ch; 181 ev.is_press = (action==GLFW_PRESS); 182 ev.mods = inst._getMods(); 183 ev.is_key = false; 184 ev.is_char = true; 185 inst.sig.key.emit(&ev); 195 void _initEvent() { 196 ev.key = m_lastKey; 197 ev.ch = ch; 198 ev.is_press = (action==GLFW_PRESS); 199 ev.mods = inst._getMods(); 200 ev.is_key = false; 201 ev.is_char = true; 202 } 203 _initEvent(); 204 inst.sig.sysKey.emit(&ev); 205 if (ev.alive) { 206 _initEvent(); 207 inst.sig.key.emit(&ev); 208 } 186 209 } 187 210 static void mouseButtonCallbackC(int button, int action) … … 190 213 int x,y; 191 214 glfwGetMousePos(&x, &y); 192 ev.x = ev.winx = x; 193 ev.y = ev.winy = y; 194 ev.is_press = (action==GLFW_PRESS); 195 ev.mods = inst._getMods(); 196 ev.pressed = inst._getButtons(); 197 if (button == GLFW_MOUSE_BUTTON_LEFT) ev.button = MouseButtons.Left; 198 else if (button == GLFW_MOUSE_BUTTON_RIGHT) ev.button = MouseButtons.Right; 199 else if (button == GLFW_MOUSE_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 200 201 inst.sig.mouseButton.emit(&ev); 215 void _initEvent() { 216 ev.x = ev.winx = x; 217 ev.y = ev.winy = y; 218 ev.is_press = (action==GLFW_PRESS); 219 ev.mods = inst._getMods(); 220 ev.pressed = inst._getButtons(); 221 if (button == GLFW_MOUSE_BUTTON_LEFT) ev.button = MouseButtons.Left; 222 else if (button == GLFW_MOUSE_BUTTON_RIGHT) ev.button = MouseButtons.Right; 223 else if (button == GLFW_MOUSE_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 224 } 225 _initEvent(); 226 inst.sig.sysMouseButton.emit(&ev); 227 if (ev.alive) { 228 // reinit because GUI might much with it 229 _initEvent(); 230 inst.sig.mouseButton.emit(&ev); 231 } 202 232 } 203 233 static void mousePosCallbackC(int x, int y) trunk/luigi/adapters/sdl.d
r34 r48 356 356 { 357 357 _KeyEvent ev; 358 ev.key= translate_key(sdl.keysym.sym);359 ev.mods = inst._getMods();358 int k = translate_key(sdl.keysym.sym); 359 dchar ch; 360 360 if (SDL_EnableUNICODE(-1)) { 361 ev.ch = sdl.keysym.unicode;361 ch = sdl.keysym.unicode; 362 362 } 363 363 else { 364 ev.ch = translate_char(sdl.keysym.sym, ev.mods); 365 } 366 ev.is_press = (sdl.type==SDL_KEYDOWN); 367 ev.is_key = true; 368 ev.is_char = (ev.ch != 0); 369 370 inst.sig.key.emit(&ev); 364 ch = translate_char(sdl.keysym.sym, ev.mods); 365 } 366 void _initEvent() { 367 ev.key = k; 368 ev.ch = ch; 369 ev.mods = inst._getMods(); 370 ev.is_press = (sdl.type==SDL_KEYDOWN); 371 ev.is_key = true; 372 ev.is_char = (ev.ch != 0); 373 } 374 _initEvent(); 375 inst.sig.sysKey.emit(&ev); 376 if (ev.alive) { 377 _initEvent(); 378 inst.sig.key.emit(&ev); 379 } 371 380 return ev.alive; 372 381 } … … 378 387 } 379 388 _MouseButtonEvent ev; 380 ev.x = ev.winx = sdl.x; 381 ev.y = ev.winy = sdl.y; 382 ev.is_press = (sdl.type==SDL_MOUSEBUTTONDOWN); 383 ev.mods = inst._getMods(); 384 ev.pressed = inst._getButtons(); 385 if (sdl.button == SDL_BUTTON_LEFT) ev.button = MouseButtons.Left; 386 else if (sdl.button == SDL_BUTTON_RIGHT) ev.button = MouseButtons.Right; 387 else if (sdl.button == SDL_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 388 389 inst.sig.mouseButton.emit(&ev); 389 void _initEvent() { 390 ev.x = ev.winx = sdl.x; 391 ev.y = ev.winy = sdl.y; 392 ev.is_press = (sdl.type==SDL_MOUSEBUTTONDOWN); 393 ev.mods = inst._getMods(); 394 ev.pressed = inst._getButtons(); 395 if (sdl.button == SDL_BUTTON_LEFT) ev.button = MouseButtons.Left; 396 else if (sdl.button == SDL_BUTTON_RIGHT) ev.button = MouseButtons.Right; 397 else if (sdl.button == SDL_BUTTON_MIDDLE) ev.button = MouseButtons.Middle; 398 } 399 _initEvent(); 400 inst.sig.sysMouseButton.emit(&ev); 401 if (ev.alive) { 402 _initEvent(); 403 inst.sig.mouseButton.emit(&ev); 404 } 390 405 return ev.alive; 391 406 }
