comparison src/video/fbcon/SDL_fbevents.c @ 1201:718d00094f82

Date: Sat, 10 Dec 2005 18:29:41 +0100 From: Alberto Mardegan <mardy@users.sourceforge.net> To: sdl@libsdl.org Subject: [SDL] [PATCH] Touchscreen support to fbcon via tslib Hi all! I'm new to this list, I just subscribed. I've attached to this e-mail a patch I've written in order to add Touchscreen support to SDL's fbcon module via the tslib library. Since it introduces a new dependency, I've also edited the the configure.in file and added it as a compile-time option. This patch is especially useful for handhelds (I've tested it in my Zaurus). Please consider applying it. :-) -- Saluti, Mardy http://interlingua.altervista.org
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 12 Dec 2005 09:26:32 +0000
parents 3d4f1930ed02
children 4b2146866b82
comparison
equal deleted inserted replaced
1200:8f418dce02b2 1201:718d00094f82
315 MOUSE_PS2, 315 MOUSE_PS2,
316 MOUSE_IMPS2, 316 MOUSE_IMPS2,
317 MOUSE_MS, 317 MOUSE_MS,
318 MOUSE_BM, 318 MOUSE_BM,
319 MOUSE_ELO, 319 MOUSE_ELO,
320 MOUSE_TSLIB,
320 NUM_MOUSE_DRVS 321 NUM_MOUSE_DRVS
321 } mouse_drv = MOUSE_NONE; 322 } mouse_drv = MOUSE_NONE;
322 323
323 void FB_CloseMouse(_THIS) 324 void FB_CloseMouse(_THIS)
324 { 325 {
326 #ifdef HAVE_TSLIB
327 if (ts_dev != NULL) {
328 ts_close(ts_dev);
329 ts_dev = NULL;
330 mouse_fd = -1;
331 }
332 #endif /* HAVE_TSLIB */
325 if ( mouse_fd > 0 ) { 333 if ( mouse_fd > 0 ) {
326 close(mouse_fd); 334 close(mouse_fd);
327 } 335 }
328 mouse_fd = -1; 336 mouse_fd = -1;
329 } 337 }
498 506
499 mousedrv = getenv("SDL_MOUSEDRV"); 507 mousedrv = getenv("SDL_MOUSEDRV");
500 mousedev = getenv("SDL_MOUSEDEV"); 508 mousedev = getenv("SDL_MOUSEDEV");
501 mouse_fd = -1; 509 mouse_fd = -1;
502 510
511 #ifdef HAVE_TSLIB
512 if ((mousedrv != NULL) && (strcmp(mousedrv, "TSLIB") == 0)) {
513 if (mousedev == NULL) mousedev = getenv("TSLIB_TSDEVICE");
514 if (mousedev != NULL) {
515 ts_dev = ts_open(mousedev, 1);
516 if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) {
517 #ifdef DEBUG_MOUSE
518 fprintf(stderr, "Using tslib touchscreen\n");
519 #endif
520 mouse_drv = MOUSE_TSLIB;
521 mouse_fd = ts_fd(ts_dev);
522 return mouse_fd;
523 }
524 }
525 mouse_drv = MOUSE_NONE;
526 return mouse_fd;
527 }
528 #endif /* HAVE_TSLIB */
529
503 /* ELO TOUCHSCREEN SUPPORT */ 530 /* ELO TOUCHSCREEN SUPPORT */
504 531
505 if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) { 532 if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) {
506 mouse_fd = open(mousedev, O_RDWR); 533 mouse_fd = open(mousedev, O_RDWR);
507 if ( mouse_fd >= 0 ) { 534 if ( mouse_fd >= 0 ) {
639 } 666 }
640 posted += SDL_PrivateMouseButton(state, i+1, 0, 0); 667 posted += SDL_PrivateMouseButton(state, i+1, 0, 0);
641 } 668 }
642 } 669 }
643 } 670 }
671
672 /* Handle input from tslib */
673 #ifdef HAVE_TSLIB
674 static void handle_tslib(_THIS)
675 {
676 struct ts_sample sample;
677 int button;
678
679 while (ts_read(ts_dev, &sample, 1) > 0) {
680 button = (sample.pressure > 0) ? 1 : 0;
681 button <<= 2; /* must report it as button 3 */
682 FB_vgamousecallback(button, 0, sample.x, sample.y);
683 }
684 return;
685 }
686 #endif /* HAVE_TSLIB */
644 687
645 /* For now, use MSC, PS/2, and MS protocols 688 /* For now, use MSC, PS/2, and MS protocols
646 Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) 689 Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
647 */ 690 */
648 static void handle_mouse(_THIS) 691 static void handle_mouse(_THIS)
676 break; 719 break;
677 case MOUSE_ELO: 720 case MOUSE_ELO:
678 packetsize = ELO_PACKET_SIZE; 721 packetsize = ELO_PACKET_SIZE;
679 relative = 0; 722 relative = 0;
680 break; 723 break;
724 case MOUSE_TSLIB:
725 #ifdef HAVE_TSLIB
726 handle_tslib(this);
727 #endif
728 return; /* nothing left to do */
681 case NUM_MOUSE_DRVS: 729 case NUM_MOUSE_DRVS:
682 /* Uh oh.. */ 730 /* Uh oh.. */
683 packetsize = 0; 731 packetsize = 0;
684 break; 732 break;
685 } 733 }