Changeset 548
- Timestamp:
- Mar 8, 2006, 10:28:41 AM (16 years ago)
- Location:
- libcaca/trunk/caca
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca_internals.h
r543 r548 120 120 void (* display) (caca_t *); 121 121 void (* handle_resize) (caca_t *, unsigned int *, unsigned int *); 122 unsigned int (* get_event) (caca_t *); 122 123 } driver; 123 124 -
libcaca/trunk/caca/driver_conio.c
r543 r548 121 121 } 122 122 123 static unsigned int conio_get_event(caca_t *kk) 124 { 125 unsigned int event; 126 127 if(!_conio_kbhit()) 128 return CACA_EVENT_NONE; 129 130 event = getch(); 131 _push_event(kk, CACA_EVENT_KEY_RELEASE | event); 132 return CACA_EVENT_KEY_PRESS | event; 133 } 134 123 135 /* 124 136 * Driver initialisation … … 136 148 kk->driver.display = conio_display; 137 149 kk->driver.handle_resize = conio_handle_resize; 150 kk->driver.get_event = conio_get_event; 138 151 } 139 152 -
libcaca/trunk/caca/driver_gl.c
r540 r548 293 293 } 294 294 295 static unsigned int gl_get_event(caca_t *kk) 296 { 297 unsigned int event = 0; 298 299 glutMainLoopEvent(); 300 301 if(kk->gl.resized && !kk->resize) 302 { 303 kk->resize = 1; 304 kk->gl.resized = 0; 305 return CACA_EVENT_RESIZE; 306 } 307 308 if(kk->gl.mouse_changed) 309 { 310 if(kk->gl.mouse_clicked) 311 { 312 event |= CACA_EVENT_MOUSE_PRESS | kk->gl.mouse_button; 313 kk->gl.mouse_clicked = 0; 314 } 315 kk->mouse_x = kk->gl.mouse_x; 316 kk->mouse_y = kk->gl.mouse_y; 317 event |= CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 318 kk->gl.mouse_changed = 0; 319 } 320 321 if(kk->gl.key != 0) 322 { 323 event |= CACA_EVENT_KEY_PRESS; 324 event |= kk->gl.key; 325 kk->gl.key = 0; 326 return event; 327 } 328 329 if(kk->gl.special_key != 0) 330 { 331 event |= CACA_EVENT_KEY_PRESS; 332 333 switch(kk->gl.special_key) 334 { 335 case GLUT_KEY_F1 : kk->gl.special_key = 0; return event | CACA_KEY_F1; 336 case GLUT_KEY_F2 : kk->gl.special_key = 0; return event | CACA_KEY_F2; 337 case GLUT_KEY_F3 : kk->gl.special_key = 0; return event | CACA_KEY_F3; 338 case GLUT_KEY_F4 : kk->gl.special_key = 0; return event | CACA_KEY_F4; 339 case GLUT_KEY_F5 : kk->gl.special_key = 0; return event | CACA_KEY_F5; 340 case GLUT_KEY_F6 : kk->gl.special_key = 0; return event | CACA_KEY_F6; 341 case GLUT_KEY_F7 : kk->gl.special_key = 0; return event | CACA_KEY_F7; 342 case GLUT_KEY_F8 : kk->gl.special_key = 0; return event | CACA_KEY_F8; 343 case GLUT_KEY_F9 : kk->gl.special_key = 0; return event | CACA_KEY_F9; 344 case GLUT_KEY_F10: kk->gl.special_key = 0; return event | CACA_KEY_F10; 345 case GLUT_KEY_F11: kk->gl.special_key = 0; return event | CACA_KEY_F11; 346 case GLUT_KEY_F12: kk->gl.special_key = 0; return event | CACA_KEY_F12; 347 case GLUT_KEY_LEFT : kk->gl.special_key = 0; return event | CACA_KEY_LEFT; 348 case GLUT_KEY_RIGHT: kk->gl.special_key = 0; return event | CACA_KEY_RIGHT; 349 case GLUT_KEY_UP : kk->gl.special_key = 0; return event | CACA_KEY_UP; 350 case GLUT_KEY_DOWN : kk->gl.special_key = 0; return event | CACA_KEY_DOWN; 351 default: return CACA_EVENT_NONE; 352 } 353 } 354 return CACA_EVENT_NONE; 355 } 356 295 357 /* 296 358 * XXX: following functions are local … … 362 424 kk->driver.display = gl_display; 363 425 kk->driver.handle_resize = gl_handle_resize; 426 kk->driver.get_event = gl_get_event; 364 427 } 365 428 -
libcaca/trunk/caca/driver_ncurses.c
r540 r548 209 209 } 210 210 211 static unsigned int ncurses_get_event(caca_t *kk) 212 { 213 unsigned int event; 214 int intkey; 215 216 if(kk->resize_event) 217 { 218 kk->resize_event = 0; 219 kk->resize = 1; 220 return CACA_EVENT_RESIZE; 221 } 222 223 intkey = getch(); 224 if(intkey == ERR) 225 return CACA_EVENT_NONE; 226 227 if(intkey < 0x100) 228 { 229 return CACA_EVENT_KEY_PRESS | intkey; 230 } 231 232 if(intkey == KEY_MOUSE) 233 { 234 MEVENT mevent; 235 getmouse(&mevent); 236 237 switch(mevent.bstate) 238 { 239 case BUTTON1_PRESSED: 240 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 241 break; 242 case BUTTON1_RELEASED: 243 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 244 break; 245 case BUTTON1_CLICKED: 246 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 247 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 248 break; 249 case BUTTON1_DOUBLE_CLICKED: 250 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 251 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 252 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 253 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 254 break; 255 case BUTTON1_TRIPLE_CLICKED: 256 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 257 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 258 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 259 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 260 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 261 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 262 break; 263 case BUTTON1_RESERVED_EVENT: 264 break; 265 266 case BUTTON2_PRESSED: 267 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 268 break; 269 case BUTTON2_RELEASED: 270 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 271 break; 272 case BUTTON2_CLICKED: 273 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 274 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 275 break; 276 case BUTTON2_DOUBLE_CLICKED: 277 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 278 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 279 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 280 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 281 break; 282 case BUTTON2_TRIPLE_CLICKED: 283 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 284 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 285 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 286 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 287 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 288 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 289 break; 290 case BUTTON2_RESERVED_EVENT: 291 break; 292 293 case BUTTON3_PRESSED: 294 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 295 break; 296 case BUTTON3_RELEASED: 297 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 298 break; 299 case BUTTON3_CLICKED: 300 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 301 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 302 break; 303 case BUTTON3_DOUBLE_CLICKED: 304 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 305 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 306 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 307 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 308 break; 309 case BUTTON3_TRIPLE_CLICKED: 310 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 311 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 312 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 313 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 314 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 315 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 316 break; 317 case BUTTON3_RESERVED_EVENT: 318 break; 319 320 case BUTTON4_PRESSED: 321 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 322 break; 323 case BUTTON4_RELEASED: 324 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 325 break; 326 case BUTTON4_CLICKED: 327 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 328 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 329 break; 330 case BUTTON4_DOUBLE_CLICKED: 331 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 332 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 333 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 334 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 335 break; 336 case BUTTON4_TRIPLE_CLICKED: 337 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 338 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 339 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 340 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 341 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 342 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 343 break; 344 case BUTTON4_RESERVED_EVENT: 345 break; 346 347 default: 348 break; 349 } 350 351 if(kk->mouse_x == (unsigned int)mevent.x && 352 kk->mouse_y == (unsigned int)mevent.y) 353 return _pop_event(kk); 354 355 kk->mouse_x = mevent.x; 356 kk->mouse_y = mevent.y; 357 358 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 359 } 360 361 event = CACA_EVENT_KEY_PRESS; 362 363 switch(intkey) 364 { 365 case KEY_UP: return event | CACA_KEY_UP; 366 case KEY_DOWN: return event | CACA_KEY_DOWN; 367 case KEY_LEFT: return event | CACA_KEY_LEFT; 368 case KEY_RIGHT: return event | CACA_KEY_RIGHT; 369 370 case KEY_IC: return event | CACA_KEY_INSERT; 371 case KEY_DC: return event | CACA_KEY_DELETE; 372 case KEY_HOME: return event | CACA_KEY_HOME; 373 case KEY_END: return event | CACA_KEY_END; 374 case KEY_PPAGE: return event | CACA_KEY_PAGEUP; 375 case KEY_NPAGE: return event | CACA_KEY_PAGEDOWN; 376 377 case KEY_F(1): return event | CACA_KEY_F1; 378 case KEY_F(2): return event | CACA_KEY_F2; 379 case KEY_F(3): return event | CACA_KEY_F3; 380 case KEY_F(4): return event | CACA_KEY_F4; 381 case KEY_F(5): return event | CACA_KEY_F5; 382 case KEY_F(6): return event | CACA_KEY_F6; 383 case KEY_F(7): return event | CACA_KEY_F7; 384 case KEY_F(8): return event | CACA_KEY_F8; 385 case KEY_F(9): return event | CACA_KEY_F9; 386 case KEY_F(10): return event | CACA_KEY_F10; 387 case KEY_F(11): return event | CACA_KEY_F11; 388 case KEY_F(12): return event | CACA_KEY_F12; 389 } 390 391 return CACA_EVENT_NONE; 392 } 393 211 394 /* 212 395 * XXX: following functions are local … … 237 420 kk->driver.display = ncurses_display; 238 421 kk->driver.handle_resize = ncurses_handle_resize; 422 kk->driver.get_event = ncurses_get_event; 239 423 } 240 424 -
libcaca/trunk/caca/driver_slang.c
r540 r548 246 246 } 247 247 248 static unsigned int slang_get_event(caca_t *kk) 249 { 250 unsigned int event; 251 int intkey; 252 253 if(kk->resize_event) 254 { 255 kk->resize_event = 0; 256 kk->resize = 1; 257 return CACA_EVENT_RESIZE; 258 } 259 260 if(!SLang_input_pending(0)) 261 return CACA_EVENT_NONE; 262 263 /* We first use SLang_getkey() to see whether Esc was pressed 264 * alone, then (if it wasn't) we unget the key and use SLkp_getkey() 265 * instead, so that escape sequences are interpreted. */ 266 intkey = SLang_getkey(); 267 268 if(intkey != 0x1b /* Esc */ || SLang_input_pending(0)) 269 { 270 SLang_ungetkey(intkey); 271 intkey = SLkp_getkey(); 272 } 273 274 /* If the key was ASCII, return it immediately */ 275 if(intkey < 0x100) 276 { 277 return CACA_EVENT_KEY_PRESS | intkey; 278 } 279 280 if(intkey == 0x3e9) 281 { 282 int button = (SLang_getkey() - ' ' + 1) & 0xf; 283 unsigned int x = SLang_getkey() - '!'; 284 unsigned int y = SLang_getkey() - '!'; 285 _push_event(kk, CACA_EVENT_MOUSE_PRESS | button); 286 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | button); 287 288 if(kk->mouse_x == x && kk->mouse_y == y) 289 return _pop_event(kk); 290 291 kk->mouse_x = x; 292 kk->mouse_y = y; 293 294 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 295 } 296 297 event = CACA_EVENT_KEY_PRESS; 298 299 switch(intkey) 300 { 301 case SL_KEY_UP: return event | CACA_KEY_UP; 302 case SL_KEY_DOWN: return event | CACA_KEY_DOWN; 303 case SL_KEY_LEFT: return event | CACA_KEY_LEFT; 304 case SL_KEY_RIGHT: return event | CACA_KEY_RIGHT; 305 306 case SL_KEY_IC: return event | CACA_KEY_INSERT; 307 case SL_KEY_DELETE: return event | CACA_KEY_DELETE; 308 case SL_KEY_HOME: return event | CACA_KEY_HOME; 309 case SL_KEY_END: return event | CACA_KEY_END; 310 case SL_KEY_PPAGE: return event | CACA_KEY_PAGEUP; 311 case SL_KEY_NPAGE: return event | CACA_KEY_PAGEDOWN; 312 313 case SL_KEY_F(1): return event | CACA_KEY_F1; 314 case SL_KEY_F(2): return event | CACA_KEY_F2; 315 case SL_KEY_F(3): return event | CACA_KEY_F3; 316 case SL_KEY_F(4): return event | CACA_KEY_F4; 317 case SL_KEY_F(5): return event | CACA_KEY_F5; 318 case SL_KEY_F(6): return event | CACA_KEY_F6; 319 case SL_KEY_F(7): return event | CACA_KEY_F7; 320 case SL_KEY_F(8): return event | CACA_KEY_F8; 321 case SL_KEY_F(9): return event | CACA_KEY_F9; 322 case SL_KEY_F(10): return event | CACA_KEY_F10; 323 case SL_KEY_F(11): return event | CACA_KEY_F11; 324 case SL_KEY_F(12): return event | CACA_KEY_F12; 325 } 326 327 return CACA_EVENT_NONE; 328 } 329 248 330 /* 249 331 * XXX: following functions are local … … 317 399 kk->driver.display = slang_display; 318 400 kk->driver.handle_resize = slang_handle_resize; 401 kk->driver.get_event = slang_get_event; 319 402 } 320 403 -
libcaca/trunk/caca/driver_win32.c
r540 r548 217 217 } 218 218 219 static unsigned int win32_get_event(caca_t *kk) 220 { 221 INPUT_RECORD rec; 222 DWORD num; 223 224 for( ; ; ) 225 { 226 GetNumberOfConsoleInputEvents(kk->win32.hin, &num); 227 if(num == 0) 228 break; 229 230 ReadConsoleInput(kk->win32.hin, &rec, 1, &num); 231 if(rec.EventType == KEY_EVENT) 232 { 233 unsigned int event; 234 235 if(rec.Event.KeyEvent.bKeyDown) 236 event = CACA_EVENT_KEY_PRESS; 237 else 238 event = CACA_EVENT_KEY_RELEASE; 239 240 if(rec.Event.KeyEvent.uChar.AsciiChar) 241 return event | rec.Event.KeyEvent.uChar.AsciiChar; 242 } 243 244 if(rec.EventType == MOUSE_EVENT) 245 { 246 if(rec.Event.MouseEvent.dwEventFlags == 0) 247 { 248 if(rec.Event.MouseEvent.dwButtonState & 0x01) 249 return CACA_EVENT_MOUSE_PRESS | 0x000001; 250 251 if(rec.Event.MouseEvent.dwButtonState & 0x02) 252 return CACA_EVENT_MOUSE_PRESS | 0x000002; 253 } 254 else if(rec.Event.MouseEvent.dwEventFlags == MOUSE_MOVED) 255 { 256 COORD pos = rec.Event.MouseEvent.dwMousePosition; 257 258 if(kk->mouse_x == (unsigned int)pos.X && 259 kk->mouse_y == (unsigned int)pos.Y) 260 continue; 261 262 kk->mouse_x = pos.X; 263 kk->mouse_y = pos.Y; 264 265 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 266 } 267 #if 0 268 else if(rec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK) 269 { 270 cout << rec.Event.MouseEvent.dwMousePosition.X << "," << 271 rec.Event.MouseEvent.dwMousePosition.Y << " " << flush; 272 } 273 else if(rec.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED) 274 { 275 SetConsoleCursorPosition(hOut, 276 WheelWhere); 277 if(rec.Event.MouseEvent.dwButtonState & 0xFF000000) 278 cout << "Down" << flush; 279 else 280 cout << "Up " << flush; 281 } 282 #endif 283 } 284 285 /* Unknown event */ 286 return CACA_EVENT_NONE; 287 } 288 289 /* No event */ 290 return CACA_EVENT_NONE; 291 } 292 219 293 /* 220 294 * Driver initialisation … … 232 306 kk->driver.display = win32_display; 233 307 kk->driver.handle_resize = win32_handle_resize; 308 kk->driver.get_event = win32_get_event; 234 309 } 235 310 -
libcaca/trunk/caca/driver_x11.c
r540 r548 23 23 24 24 #include <X11/Xlib.h> 25 #include <X11/Xutil.h> 26 #include <X11/keysym.h> 25 27 #if defined(HAVE_X11_XKBLIB_H) 26 28 # include <X11/XKBlib.h> … … 163 165 for(;;) 164 166 { 165 XEvent event;166 XNextEvent(kk->x11.dpy, & event);167 if ( event.type == MapNotify)167 XEvent xevent; 168 XNextEvent(kk->x11.dpy, &xevent); 169 if (xevent.type == MapNotify) 168 170 break; 169 171 } … … 312 314 } 313 315 316 static unsigned int x11_get_event(caca_t *kk) 317 { 318 unsigned int event = 0; 319 XEvent xevent; 320 char key; 321 322 while(XCheckWindowEvent(kk->x11.dpy, kk->x11.window, 323 kk->x11.event_mask, &xevent) == True) 324 { 325 KeySym keysym; 326 327 /* Expose event */ 328 if(xevent.type == Expose) 329 { 330 XCopyArea(kk->x11.dpy, kk->x11.pixmap, 331 kk->x11.window, kk->x11.gc, 0, 0, 332 kk->qq->width * kk->x11.font_width, 333 kk->qq->height * kk->x11.font_height, 0, 0); 334 continue; 335 } 336 337 /* Resize event */ 338 if(xevent.type == ConfigureNotify) 339 { 340 unsigned int w, h; 341 342 w = (xevent.xconfigure.width + kk->x11.font_width / 3) 343 / kk->x11.font_width; 344 h = (xevent.xconfigure.height + kk->x11.font_height / 3) 345 / kk->x11.font_height; 346 347 if(!w || !h || (w == kk->qq->width && h == kk->qq->height)) 348 continue; 349 350 kk->x11.new_width = w; 351 kk->x11.new_height = h; 352 353 /* If we are already resizing, ignore the new signal */ 354 if(kk->resize) 355 continue; 356 357 kk->resize = 1; 358 359 return CACA_EVENT_RESIZE; 360 } 361 362 /* Check for mouse motion events */ 363 if(xevent.type == MotionNotify) 364 { 365 unsigned int newx = xevent.xmotion.x / kk->x11.font_width; 366 unsigned int newy = xevent.xmotion.y / kk->x11.font_height; 367 368 if(newx >= kk->qq->width) 369 newx = kk->qq->width - 1; 370 if(newy >= kk->qq->height) 371 newy = kk->qq->height - 1; 372 373 if(kk->mouse_x == newx && kk->mouse_y == newy) 374 continue; 375 376 kk->mouse_x = newx; 377 kk->mouse_y = newy; 378 379 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 380 } 381 382 /* Check for mouse press and release events */ 383 if(xevent.type == ButtonPress) 384 return CACA_EVENT_MOUSE_PRESS 385 | ((XButtonEvent *)&xevent)->button; 386 387 if(xevent.type == ButtonRelease) 388 return CACA_EVENT_MOUSE_RELEASE 389 | ((XButtonEvent *)&xevent)->button; 390 391 /* Check for key press and release events */ 392 if(xevent.type == KeyPress) 393 event |= CACA_EVENT_KEY_PRESS; 394 else if(xevent.type == KeyRelease) 395 event |= CACA_EVENT_KEY_RELEASE; 396 else 397 continue; 398 399 if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL)) 400 return event | key; 401 402 keysym = XKeycodeToKeysym(kk->x11.dpy, xevent.xkey.keycode, 0); 403 switch(keysym) 404 { 405 case XK_F1: return event | CACA_KEY_F1; 406 case XK_F2: return event | CACA_KEY_F2; 407 case XK_F3: return event | CACA_KEY_F3; 408 case XK_F4: return event | CACA_KEY_F4; 409 case XK_F5: return event | CACA_KEY_F5; 410 case XK_F6: return event | CACA_KEY_F6; 411 case XK_F7: return event | CACA_KEY_F7; 412 case XK_F8: return event | CACA_KEY_F8; 413 case XK_F9: return event | CACA_KEY_F9; 414 case XK_F10: return event | CACA_KEY_F10; 415 case XK_F11: return event | CACA_KEY_F11; 416 case XK_F12: return event | CACA_KEY_F12; 417 case XK_F13: return event | CACA_KEY_F13; 418 case XK_F14: return event | CACA_KEY_F14; 419 case XK_F15: return event | CACA_KEY_F15; 420 case XK_Left: return event | CACA_KEY_LEFT; 421 case XK_Right: return event | CACA_KEY_RIGHT; 422 case XK_Up: return event | CACA_KEY_UP; 423 case XK_Down: return event | CACA_KEY_DOWN; 424 default: return CACA_EVENT_NONE; 425 } 426 } 427 428 return CACA_EVENT_NONE; 429 } 430 314 431 /* 315 432 * XXX: following functions are local 316 433 */ 317 434 318 static int x11_error_handler(Display *dpy, XErrorEvent * event)435 static int x11_error_handler(Display *dpy, XErrorEvent *xevent) 319 436 { 320 437 /* Ignore the error */ … … 337 454 kk->driver.display = x11_display; 338 455 kk->driver.handle_resize = x11_handle_resize; 456 kk->driver.get_event = x11_get_event; 339 457 } 340 458 -
libcaca/trunk/caca/event.c
r541 r548 20 20 #include "config.h" 21 21 22 #if defined(USE_SLANG)23 # if defined(HAVE_SLANG_SLANG_H)24 # include <slang/slang.h>25 # else26 # include <slang.h>27 # endif28 #endif29 #if defined(USE_NCURSES)30 # if defined(HAVE_NCURSES_H)31 # include <ncurses.h>32 # else33 # include <curses.h>34 # endif35 #endif36 #if defined(USE_CONIO)37 # include <conio.h>38 #endif39 #if defined(USE_X11)40 # include <X11/Xlib.h>41 # include <X11/Xutil.h>42 # include <X11/keysym.h>43 #endif44 #if defined(USE_WIN32)45 # include <windows.h>46 #endif47 #if defined(USE_GL)48 #include <GL/gl.h>49 #include <GL/glut.h>50 #include <GL/freeglut_ext.h>51 #endif52 53 22 #include "cucul.h" 54 23 #include "cucul_internals.h" … … 59 28 static unsigned int _lowlevel_event(caca_t *); 60 29 #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) 61 staticvoid _push_event(caca_t *, unsigned int);62 staticunsigned int _pop_event(caca_t *);30 void _push_event(caca_t *, unsigned int); 31 unsigned int _pop_event(caca_t *); 63 32 #endif 64 33 … … 230 199 static unsigned int _lowlevel_event(caca_t *kk) 231 200 { 232 unsigned int event;233 234 201 #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) 235 event = _pop_event(kk);202 unsigned int event = _pop_event(kk); 236 203 237 204 if(event) … … 239 206 #endif 240 207 241 #if defined(USE_X11) 242 /* The X11 event check routine */ 243 if(kk->driver.driver == CACA_DRIVER_X11) 244 { 245 XEvent xevent; 246 char key; 247 248 while(XCheckWindowEvent(kk->x11.dpy, kk->x11.window, kk->x11.event_mask, &xevent) 249 == True) 250 { 251 KeySym keysym; 252 253 /* Expose event */ 254 if(xevent.type == Expose) 255 { 256 XCopyArea(kk->x11.dpy, kk->x11.pixmap, 257 kk->x11.window, kk->x11.gc, 0, 0, 258 kk->qq->width * kk->x11.font_width, 259 kk->qq->height * kk->x11.font_height, 0, 0); 260 continue; 261 } 262 263 /* Resize event */ 264 if(xevent.type == ConfigureNotify) 265 { 266 unsigned int w, h; 267 268 w = (xevent.xconfigure.width + kk->x11.font_width / 3) 269 / kk->x11.font_width; 270 h = (xevent.xconfigure.height + kk->x11.font_height / 3) 271 / kk->x11.font_height; 272 273 if(!w || !h || (w == kk->qq->width && h == kk->qq->height)) 274 continue; 275 276 kk->x11.new_width = w; 277 kk->x11.new_height = h; 278 279 /* If we are already resizing, ignore the new signal */ 280 if(kk->resize) 281 continue; 282 283 kk->resize = 1; 284 285 return CACA_EVENT_RESIZE; 286 } 287 288 /* Check for mouse motion events */ 289 if(xevent.type == MotionNotify) 290 { 291 unsigned int newx = xevent.xmotion.x / kk->x11.font_width; 292 unsigned int newy = xevent.xmotion.y / kk->x11.font_height; 293 294 if(newx >= kk->qq->width) 295 newx = kk->qq->width - 1; 296 if(newy >= kk->qq->height) 297 newy = kk->qq->height - 1; 298 299 if(kk->mouse_x == newx && kk->mouse_y == newy) 300 continue; 301 302 kk->mouse_x = newx; 303 kk->mouse_y = newy; 304 305 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 306 } 307 308 /* Check for mouse press and release events */ 309 if(xevent.type == ButtonPress) 310 return CACA_EVENT_MOUSE_PRESS 311 | ((XButtonEvent *)&xevent)->button; 312 313 if(xevent.type == ButtonRelease) 314 return CACA_EVENT_MOUSE_RELEASE 315 | ((XButtonEvent *)&xevent)->button; 316 317 /* Check for key press and release events */ 318 if(xevent.type == KeyPress) 319 event |= CACA_EVENT_KEY_PRESS; 320 else if(xevent.type == KeyRelease) 321 event |= CACA_EVENT_KEY_RELEASE; 322 else 323 continue; 324 325 if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL)) 326 return event | key; 327 328 keysym = XKeycodeToKeysym(kk->x11.dpy, xevent.xkey.keycode, 0); 329 switch(keysym) 330 { 331 case XK_F1: return event | CACA_KEY_F1; 332 case XK_F2: return event | CACA_KEY_F2; 333 case XK_F3: return event | CACA_KEY_F3; 334 case XK_F4: return event | CACA_KEY_F4; 335 case XK_F5: return event | CACA_KEY_F5; 336 case XK_F6: return event | CACA_KEY_F6; 337 case XK_F7: return event | CACA_KEY_F7; 338 case XK_F8: return event | CACA_KEY_F8; 339 case XK_F9: return event | CACA_KEY_F9; 340 case XK_F10: return event | CACA_KEY_F10; 341 case XK_F11: return event | CACA_KEY_F11; 342 case XK_F12: return event | CACA_KEY_F12; 343 case XK_F13: return event | CACA_KEY_F13; 344 case XK_F14: return event | CACA_KEY_F14; 345 case XK_F15: return event | CACA_KEY_F15; 346 case XK_Left: return event | CACA_KEY_LEFT; 347 case XK_Right: return event | CACA_KEY_RIGHT; 348 case XK_Up: return event | CACA_KEY_UP; 349 case XK_Down: return event | CACA_KEY_DOWN; 350 default: return CACA_EVENT_NONE; 351 } 352 } 353 354 return CACA_EVENT_NONE; 355 } 356 else 357 #endif 358 #if defined(USE_NCURSES) 359 if(kk->driver.driver == CACA_DRIVER_NCURSES) 360 { 361 int intkey; 362 363 if(kk->resize_event) 364 { 365 kk->resize_event = 0; 366 kk->resize = 1; 367 return CACA_EVENT_RESIZE; 368 } 369 370 intkey = getch(); 371 if(intkey == ERR) 372 return CACA_EVENT_NONE; 373 374 if(intkey < 0x100) 375 { 376 return CACA_EVENT_KEY_PRESS | intkey; 377 } 378 379 if(intkey == KEY_MOUSE) 380 { 381 MEVENT mevent; 382 getmouse(&mevent); 383 384 switch(mevent.bstate) 385 { 386 case BUTTON1_PRESSED: 387 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 388 break; 389 case BUTTON1_RELEASED: 390 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 391 break; 392 case BUTTON1_CLICKED: 393 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 394 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 395 break; 396 case BUTTON1_DOUBLE_CLICKED: 397 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 398 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 399 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 400 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 401 break; 402 case BUTTON1_TRIPLE_CLICKED: 403 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 404 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 405 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 406 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 407 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 1); 408 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 1); 409 break; 410 case BUTTON1_RESERVED_EVENT: 411 break; 412 413 case BUTTON2_PRESSED: 414 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 415 break; 416 case BUTTON2_RELEASED: 417 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 418 break; 419 case BUTTON2_CLICKED: 420 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 421 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 422 break; 423 case BUTTON2_DOUBLE_CLICKED: 424 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 425 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 426 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 427 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 428 break; 429 case BUTTON2_TRIPLE_CLICKED: 430 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 431 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 432 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 433 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 434 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 2); 435 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 2); 436 break; 437 case BUTTON2_RESERVED_EVENT: 438 break; 439 440 case BUTTON3_PRESSED: 441 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 442 break; 443 case BUTTON3_RELEASED: 444 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 445 break; 446 case BUTTON3_CLICKED: 447 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 448 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 449 break; 450 case BUTTON3_DOUBLE_CLICKED: 451 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 452 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 453 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 454 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 455 break; 456 case BUTTON3_TRIPLE_CLICKED: 457 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 458 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 459 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 460 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 461 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 3); 462 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 3); 463 break; 464 case BUTTON3_RESERVED_EVENT: 465 break; 466 467 case BUTTON4_PRESSED: 468 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 469 break; 470 case BUTTON4_RELEASED: 471 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 472 break; 473 case BUTTON4_CLICKED: 474 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 475 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 476 break; 477 case BUTTON4_DOUBLE_CLICKED: 478 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 479 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 480 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 481 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 482 break; 483 case BUTTON4_TRIPLE_CLICKED: 484 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 485 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 486 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 487 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 488 _push_event(kk, CACA_EVENT_MOUSE_PRESS | 4); 489 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | 4); 490 break; 491 case BUTTON4_RESERVED_EVENT: 492 break; 493 494 default: 495 break; 496 } 497 498 if(kk->mouse_x == (unsigned int)mevent.x && 499 kk->mouse_y == (unsigned int)mevent.y) 500 return _pop_event(kk); 501 502 kk->mouse_x = mevent.x; 503 kk->mouse_y = mevent.y; 504 505 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 506 } 507 508 event = CACA_EVENT_KEY_PRESS; 509 510 switch(intkey) 511 { 512 case KEY_UP: return event | CACA_KEY_UP; 513 case KEY_DOWN: return event | CACA_KEY_DOWN; 514 case KEY_LEFT: return event | CACA_KEY_LEFT; 515 case KEY_RIGHT: return event | CACA_KEY_RIGHT; 516 517 case KEY_IC: return event | CACA_KEY_INSERT; 518 case KEY_DC: return event | CACA_KEY_DELETE; 519 case KEY_HOME: return event | CACA_KEY_HOME; 520 case KEY_END: return event | CACA_KEY_END; 521 case KEY_PPAGE: return event | CACA_KEY_PAGEUP; 522 case KEY_NPAGE: return event | CACA_KEY_PAGEDOWN; 523 524 case KEY_F(1): return event | CACA_KEY_F1; 525 case KEY_F(2): return event | CACA_KEY_F2; 526 case KEY_F(3): return event | CACA_KEY_F3; 527 case KEY_F(4): return event | CACA_KEY_F4; 528 case KEY_F(5): return event | CACA_KEY_F5; 529 case KEY_F(6): return event | CACA_KEY_F6; 530 case KEY_F(7): return event | CACA_KEY_F7; 531 case KEY_F(8): return event | CACA_KEY_F8; 532 case KEY_F(9): return event | CACA_KEY_F9; 533 case KEY_F(10): return event | CACA_KEY_F10; 534 case KEY_F(11): return event | CACA_KEY_F11; 535 case KEY_F(12): return event | CACA_KEY_F12; 536 } 537 538 return CACA_EVENT_NONE; 539 } 540 else 541 #endif 542 #if defined(USE_SLANG) 543 if(kk->driver.driver == CACA_DRIVER_SLANG) 544 { 545 int intkey; 546 547 if(kk->resize_event) 548 { 549 kk->resize_event = 0; 550 kk->resize = 1; 551 return CACA_EVENT_RESIZE; 552 } 553 554 if(!SLang_input_pending(0)) 555 return CACA_EVENT_NONE; 556 557 /* We first use SLang_getkey() to see whether Esc was pressed 558 * alone, then (if it wasn't) we unget the key and use SLkp_getkey() 559 * instead, so that escape sequences are interpreted. */ 560 intkey = SLang_getkey(); 561 562 if(intkey != 0x1b /* Esc */ || SLang_input_pending(0)) 563 { 564 SLang_ungetkey(intkey); 565 intkey = SLkp_getkey(); 566 } 567 568 /* If the key was ASCII, return it immediately */ 569 if(intkey < 0x100) 570 { 571 return CACA_EVENT_KEY_PRESS | intkey; 572 } 573 574 if(intkey == 0x3e9) 575 { 576 int button = (SLang_getkey() - ' ' + 1) & 0xf; 577 unsigned int x = SLang_getkey() - '!'; 578 unsigned int y = SLang_getkey() - '!'; 579 _push_event(kk, CACA_EVENT_MOUSE_PRESS | button); 580 _push_event(kk, CACA_EVENT_MOUSE_RELEASE | button); 581 582 if(kk->mouse_x == x && kk->mouse_y == y) 583 return _pop_event(kk); 584 585 kk->mouse_x = x; 586 kk->mouse_y = y; 587 588 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 589 } 590 591 event = CACA_EVENT_KEY_PRESS; 592 593 switch(intkey) 594 { 595 case SL_KEY_UP: return event | CACA_KEY_UP; 596 case SL_KEY_DOWN: return event | CACA_KEY_DOWN; 597 case SL_KEY_LEFT: return event | CACA_KEY_LEFT; 598 case SL_KEY_RIGHT: return event | CACA_KEY_RIGHT; 599 600 case SL_KEY_IC: return event | CACA_KEY_INSERT; 601 case SL_KEY_DELETE: return event | CACA_KEY_DELETE; 602 case SL_KEY_HOME: return event | CACA_KEY_HOME; 603 case SL_KEY_END: return event | CACA_KEY_END; 604 case SL_KEY_PPAGE: return event | CACA_KEY_PAGEUP; 605 case SL_KEY_NPAGE: return event | CACA_KEY_PAGEDOWN; 606 607 case SL_KEY_F(1): return event | CACA_KEY_F1; 608 case SL_KEY_F(2): return event | CACA_KEY_F2; 609 case SL_KEY_F(3): return event | CACA_KEY_F3; 610 case SL_KEY_F(4): return event | CACA_KEY_F4; 611 case SL_KEY_F(5): return event | CACA_KEY_F5; 612 case SL_KEY_F(6): return event | CACA_KEY_F6; 613 case SL_KEY_F(7): return event | CACA_KEY_F7; 614 case SL_KEY_F(8): return event | CACA_KEY_F8; 615 case SL_KEY_F(9): return event | CACA_KEY_F9; 616 case SL_KEY_F(10): return event | CACA_KEY_F10; 617 case SL_KEY_F(11): return event | CACA_KEY_F11; 618 case SL_KEY_F(12): return event | CACA_KEY_F12; 619 } 620 621 return CACA_EVENT_NONE; 622 } 623 else 624 #endif 625 #if defined(USE_CONIO) 626 if(kk->driver.driver == CACA_DRIVER_CONIO) 627 { 628 if(!_conio_kbhit()) 629 return CACA_EVENT_NONE; 630 631 event = getch(); 632 _push_event(kk, CACA_EVENT_KEY_RELEASE | event); 633 return CACA_EVENT_KEY_PRESS | event; 634 } 635 else 636 #endif 637 #if defined(USE_WIN32) 638 if(kk->driver.driver == CACA_DRIVER_WIN32) 639 { 640 INPUT_RECORD rec; 641 DWORD num; 642 643 for( ; ; ) 644 { 645 GetNumberOfConsoleInputEvents(kk->win32.hin, &num); 646 if(num == 0) 647 break; 648 649 ReadConsoleInput(kk->win32.hin, &rec, 1, &num); 650 if(rec.EventType == KEY_EVENT) 651 { 652 if(rec.Event.KeyEvent.bKeyDown) 653 event = CACA_EVENT_KEY_PRESS; 654 else 655 event = CACA_EVENT_KEY_RELEASE; 656 657 if(rec.Event.KeyEvent.uChar.AsciiChar) 658 return event | rec.Event.KeyEvent.uChar.AsciiChar; 659 } 660 661 if(rec.EventType == MOUSE_EVENT) 662 { 663 if(rec.Event.MouseEvent.dwEventFlags == 0) 664 { 665 if(rec.Event.MouseEvent.dwButtonState & 0x01) 666 return CACA_EVENT_MOUSE_PRESS | 0x000001; 667 668 if(rec.Event.MouseEvent.dwButtonState & 0x02) 669 return CACA_EVENT_MOUSE_PRESS | 0x000002; 670 } 671 else if(rec.Event.MouseEvent.dwEventFlags == MOUSE_MOVED) 672 { 673 COORD pos = rec.Event.MouseEvent.dwMousePosition; 674 675 if(kk->mouse_x == (unsigned int)pos.X && 676 kk->mouse_y == (unsigned int)pos.Y) 677 continue; 678 679 kk->mouse_x = pos.X; 680 kk->mouse_y = pos.Y; 681 682 return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 683 } 684 #if 0 685 else if(rec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK) 686 { 687 cout << rec.Event.MouseEvent.dwMousePosition.X << "," << 688 rec.Event.MouseEvent.dwMousePosition.Y << " " << flush; 689 } 690 else if(rec.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED) 691 { 692 SetConsoleCursorPosition(hOut, 693 WheelWhere); 694 if(rec.Event.MouseEvent.dwButtonState & 0xFF000000) 695 cout << "Down" << flush; 696 else 697 cout << "Up " << flush; 698 } 699 #endif 700 } 701 702 /* Unknown event */ 703 return CACA_EVENT_NONE; 704 } 705 706 /* No event */ 707 return CACA_EVENT_NONE; 708 } 709 else 710 #endif 711 #if defined(USE_GL) 712 if(kk->driver.driver == CACA_DRIVER_GL) 713 { 714 glutMainLoopEvent(); 715 716 if(kk->gl.resized && !kk->resize) 717 { 718 kk->resize = 1; 719 kk->gl.resized = 0; 720 return CACA_EVENT_RESIZE; 721 } 722 723 if(kk->gl.mouse_changed) 724 { 725 if(kk->gl.mouse_clicked) 726 { 727 event|= CACA_EVENT_MOUSE_PRESS | kk->gl.mouse_button; 728 kk->gl.mouse_clicked=0; 729 } 730 kk->mouse_x = kk->gl.mouse_x; 731 kk->mouse_y = kk->gl.mouse_y; 732 event |= CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; 733 kk->gl.mouse_changed = 0; 734 } 735 736 if(kk->gl.key != 0) 737 { 738 event |= CACA_EVENT_KEY_PRESS; 739 event |= kk->gl.key; 740 kk->gl.key = 0; 741 return event; 742 } 743 744 if(kk->gl.special_key != 0) 745 { 746 event |= CACA_EVENT_KEY_PRESS; 747 748 switch(kk->gl.special_key) 749 { 750 case GLUT_KEY_F1 : kk->gl.special_key = 0; return event | CACA_KEY_F1; 751 case GLUT_KEY_F2 : kk->gl.special_key = 0; return event | CACA_KEY_F2; 752 case GLUT_KEY_F3 : kk->gl.special_key = 0; return event | CACA_KEY_F3; 753 case GLUT_KEY_F4 : kk->gl.special_key = 0; return event | CACA_KEY_F4; 754 case GLUT_KEY_F5 : kk->gl.special_key = 0; return event | CACA_KEY_F5; 755 case GLUT_KEY_F6 : kk->gl.special_key = 0; return event | CACA_KEY_F6; 756 case GLUT_KEY_F7 : kk->gl.special_key = 0; return event | CACA_KEY_F7; 757 case GLUT_KEY_F8 : kk->gl.special_key = 0; return event | CACA_KEY_F8; 758 case GLUT_KEY_F9 : kk->gl.special_key = 0; return event | CACA_KEY_F9; 759 case GLUT_KEY_F10: kk->gl.special_key = 0; return event | CACA_KEY_F10; 760 case GLUT_KEY_F11: kk->gl.special_key = 0; return event | CACA_KEY_F11; 761 case GLUT_KEY_F12: kk->gl.special_key = 0; return event | CACA_KEY_F12; 762 case GLUT_KEY_LEFT : kk->gl.special_key = 0; return event | CACA_KEY_LEFT; 763 case GLUT_KEY_RIGHT: kk->gl.special_key = 0; return event | CACA_KEY_RIGHT; 764 case GLUT_KEY_UP : kk->gl.special_key = 0; return event | CACA_KEY_UP; 765 case GLUT_KEY_DOWN : kk->gl.special_key = 0; return event | CACA_KEY_DOWN; 766 default: return CACA_EVENT_NONE; 767 } 768 } 769 return CACA_EVENT_NONE; 770 } 771 else 772 #endif 773 { 774 /* Dummy */ 775 } 776 777 return CACA_EVENT_NONE; 208 return kk->driver.get_event(kk); 778 209 } 779 210 780 211 #if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) 781 staticvoid _push_event(caca_t *kk, unsigned int event)212 void _push_event(caca_t *kk, unsigned int event) 782 213 { 783 214 if(!event || kk->events.queue == EVENTBUF_LEN) … … 787 218 } 788 219 789 staticunsigned int _pop_event(caca_t *kk)220 unsigned int _pop_event(caca_t *kk) 790 221 { 791 222 int i;
Note: See TracChangeset
for help on using the changeset viewer.