comparison src/video/fbcon/SDL_fbevents.c @ 1585:980d2a0dc2a3

Date: Tue, 4 Mar 2003 15:05:31 -0800 From: "Jim" Subject: [SDL] Frame Buffer patches... Okay I'm new at patch generation - so please tell me if there's a better way I could have done this. Attached are two patch files generated with 'cvs diff -u' SDL-fb-open-lock.patch applies to SDL_fbvideo.c Modifies the open loop to check /dev/fb/0 found on devfs... Modifies the lock code to return failure if the current virtual terminal is not the one opened for frame buffer writing... Lock would hang forever if switched away (ctrl-alt-F1) ... SDL-fb-mousedrv-screensave.patch applies to SDL_fbevents.c Switches default mouse mode based on SDL_MOUSEDRV - currently only accepts PS2 - otherwise default is MS Mouse. When the screen is switched - exisiting code (wrapped in ifdef SAVE_SCREEN_COTENTS) would save the wrong bit of the screen.... ( I run frame buffer 1600x1200, the size I requested was 800x600 - the save would save the top 800 lines (non biased) and restore them... Adding screen->offset fixed that ) However, if that option is not set, then a call to SDL_UpdateRect (full screen) is made. (which may have had it's contents changed since the screen is not entirely locked because of lock-failure patch) Jim [patches slightly tweaked for SDL 1.2.10]
author Sam Lantinga <slouken@libsdl.org>
date Wed, 22 Mar 2006 07:48:22 +0000
parents b786d9c15e42
children 14717b52abc0 5115185b6e3c
comparison
equal deleted inserted replaced
1584:b786d9c15e42 1585:980d2a0dc2a3
503 mousedrv = SDL_getenv("SDL_MOUSEDRV"); 503 mousedrv = SDL_getenv("SDL_MOUSEDRV");
504 mousedev = SDL_getenv("SDL_MOUSEDEV"); 504 mousedev = SDL_getenv("SDL_MOUSEDEV");
505 mouse_fd = -1; 505 mouse_fd = -1;
506 506
507 #if SDL_INPUT_TSLIB 507 #if SDL_INPUT_TSLIB
508 if ((mousedrv != NULL) && (SDL_strcmp(mousedrv, "TSLIB") == 0)) { 508 if ( mousedrv && (SDL_strcmp(mousedrv, "TSLIB") == 0) ) {
509 if (mousedev == NULL) mousedev = SDL_getenv("TSLIB_TSDEVICE"); 509 if (mousedev == NULL) mousedev = SDL_getenv("TSLIB_TSDEVICE");
510 if (mousedev != NULL) { 510 if (mousedev != NULL) {
511 ts_dev = ts_open(mousedev, 1); 511 ts_dev = ts_open(mousedev, 1);
512 if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) { 512 if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) {
513 #ifdef DEBUG_MOUSE 513 #ifdef DEBUG_MOUSE
523 } 523 }
524 #endif /* SDL_INPUT_TSLIB */ 524 #endif /* SDL_INPUT_TSLIB */
525 525
526 /* ELO TOUCHSCREEN SUPPORT */ 526 /* ELO TOUCHSCREEN SUPPORT */
527 527
528 if( (mousedrv != NULL) && (SDL_strcmp(mousedrv, "ELO") == 0) ) { 528 if ( mousedrv && (SDL_strcmp(mousedrv, "ELO") == 0) ) {
529 mouse_fd = open(mousedev, O_RDWR); 529 mouse_fd = open(mousedev, O_RDWR);
530 if ( mouse_fd >= 0 ) { 530 if ( mouse_fd >= 0 ) {
531 if(eloInitController(mouse_fd)) { 531 if(eloInitController(mouse_fd)) {
532 #ifdef DEBUG_MOUSE 532 #ifdef DEBUG_MOUSE
533 fprintf(stderr, "Using ELO touchscreen\n"); 533 fprintf(stderr, "Using ELO touchscreen\n");
614 mouse_termios.c_cc[VMIN] = 1; 614 mouse_termios.c_cc[VMIN] = 1;
615 mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL; 615 mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL;
616 mouse_termios.c_cflag |= CS8; 616 mouse_termios.c_cflag |= CS8;
617 mouse_termios.c_cflag |= B1200; 617 mouse_termios.c_cflag |= B1200;
618 tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios); 618 tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios);
619 if ( mousedrv && (SDL_strcmp(mousedrv, "PS2") == 0) ) {
619 #ifdef DEBUG_MOUSE 620 #ifdef DEBUG_MOUSE
620 fprintf(stderr, "Using Microsoft mouse on %s\n", mousedev); 621 fprintf(stderr, "Using (user specified) PS2 mouse on %s\n", mousedev);
621 #endif 622 #endif
622 mouse_drv = MOUSE_MS; 623 mouse_drv = MOUSE_PS2;
624 } else {
625 #ifdef DEBUG_MOUSE
626 fprintf(stderr, "Using (default) MS mouse on %s\n", mousedev);
627 #endif
628 mouse_drv = MOUSE_MS;
629 }
623 } 630 }
624 } 631 }
625 if ( mouse_fd < 0 ) { 632 if ( mouse_fd < 0 ) {
626 mouse_drv = MOUSE_NONE; 633 mouse_drv = MOUSE_NONE;
627 } 634 }
854 static void switch_vt(_THIS, unsigned short which) 861 static void switch_vt(_THIS, unsigned short which)
855 { 862 {
856 struct fb_var_screeninfo vinfo; 863 struct fb_var_screeninfo vinfo;
857 struct vt_stat vtstate; 864 struct vt_stat vtstate;
858 unsigned short v_active; 865 unsigned short v_active;
866 __u16 saved_pal[3*256];
859 SDL_Surface *screen; 867 SDL_Surface *screen;
860 __u16 saved_pal[3*256];
861 Uint32 screen_arealen; 868 Uint32 screen_arealen;
862 Uint8 *screen_contents; 869 Uint8 *screen_contents = NULL;
863 870
864 /* Figure out whether or not we're switching to a new console */ 871 /* Figure out whether or not we're switching to a new console */
865 if ( (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) || 872 if ( (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
866 (which == vtstate.v_active) ) { 873 (which == vtstate.v_active) ) {
867 return; 874 return;
870 877
871 /* Save the contents of the screen, and go to text mode */ 878 /* Save the contents of the screen, and go to text mode */
872 SDL_mutexP(hw_lock); 879 SDL_mutexP(hw_lock);
873 wait_idle(this); 880 wait_idle(this);
874 screen = SDL_VideoSurface; 881 screen = SDL_VideoSurface;
875 screen_arealen = (screen->h*screen->pitch); 882 if ( !SDL_ShadowSurface ) {
876 screen_contents = (Uint8 *)SDL_malloc(screen_arealen); 883 screen_arealen = (screen->h*screen->pitch);
877 if ( screen_contents ) { 884 screen_contents = (Uint8 *)SDL_malloc(screen_arealen);
878 SDL_memcpy(screen_contents, screen->pixels, screen_arealen); 885 if ( screen_contents ) {
886 SDL_memcpy(screen_contents, (Uint8 *)screen->pixels + screen->offset, screen_arealen);
887 }
879 } 888 }
880 FB_SavePaletteTo(this, 256, saved_pal); 889 FB_SavePaletteTo(this, 256, saved_pal);
881 ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo); 890 ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo);
882 ioctl(keyboard_fd, KDSETMODE, KD_TEXT); 891 ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
883 892
897 /* Restore graphics mode and the contents of the screen */ 906 /* Restore graphics mode and the contents of the screen */
898 ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS); 907 ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS);
899 ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); 908 ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
900 FB_RestorePaletteFrom(this, 256, saved_pal); 909 FB_RestorePaletteFrom(this, 256, saved_pal);
901 if ( screen_contents ) { 910 if ( screen_contents ) {
902 SDL_memcpy(screen->pixels, screen_contents, screen_arealen); 911 SDL_memcpy((Uint8 *)screen->pixels + screen->offset, screen_contents, screen_arealen);
903 SDL_free(screen_contents); 912 SDL_free(screen_contents);
913 } else {
914 SDL_UpdateRect(screen, 0, 0, 0, 0);
904 } 915 }
905 SDL_mutexV(hw_lock); 916 SDL_mutexV(hw_lock);
906 } 917 }
907 918
908 static void handle_keyboard(_THIS) 919 static void handle_keyboard(_THIS)