comparison src/video/fbcon/SDL_fbevents.c @ 109:5a9c36a45db1

Fixed switching away from the SDL at the framebuffer console
author Sam Lantinga <slouken@lokigames.com>
date Sat, 14 Jul 2001 19:10:06 +0000
parents a746656b7599
children 2604a7be65af
comparison
equal deleted inserted replaced
108:e021a4c9e25f 109:5a9c36a45db1
309 return(keyboard_fd); 309 return(keyboard_fd);
310 } 310 }
311 311
312 static enum { 312 static enum {
313 MOUSE_NONE = -1, 313 MOUSE_NONE = -1,
314 MOUSE_GPM, /* Note: GPM uses the MSC protocol */ 314 MOUSE_MSC, /* Note: GPM uses the MSC protocol */
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,
533 mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0); 533 mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0);
534 if ( mouse_fd >= 0 ) { 534 if ( mouse_fd >= 0 ) {
535 #ifdef DEBUG_MOUSE 535 #ifdef DEBUG_MOUSE
536 fprintf(stderr, "Using GPM mouse\n"); 536 fprintf(stderr, "Using GPM mouse\n");
537 #endif 537 #endif
538 mouse_drv = MOUSE_GPM; 538 mouse_drv = MOUSE_MSC;
539 } 539 }
540 } 540 }
541 } 541 }
542 /* Now try to use a modern PS/2 mouse */ 542 /* Now try to use a modern PS/2 mouse */
543 for ( i=0; (mouse_fd < 0) && ps2mice[i]; ++i ) { 543 for ( i=0; (mouse_fd < 0) && ps2mice[i]; ++i ) {
640 posted += SDL_PrivateMouseButton(state, i+1, 0, 0); 640 posted += SDL_PrivateMouseButton(state, i+1, 0, 0);
641 } 641 }
642 } 642 }
643 } 643 }
644 644
645 /* For now, use GPM, PS/2, and MS protocols 645 /* For now, use MSC, PS/2, and MS protocols
646 Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) 646 Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
647 */ 647 */
648 static void handle_mouse(_THIS) 648 static void handle_mouse(_THIS)
649 { 649 {
650 static int start = 0; 650 static int start = 0;
661 switch (mouse_drv) { 661 switch (mouse_drv) {
662 case MOUSE_NONE: 662 case MOUSE_NONE:
663 /* Ack! */ 663 /* Ack! */
664 read(mouse_fd, mousebuf, BUFSIZ); 664 read(mouse_fd, mousebuf, BUFSIZ);
665 return; 665 return;
666 case MOUSE_GPM: 666 case MOUSE_MSC:
667 packetsize = 5; 667 packetsize = 5;
668 break; 668 break;
669 case MOUSE_IMPS2: 669 case MOUSE_IMPS2:
670 packetsize = 4; 670 packetsize = 4;
671 break; 671 break;
707 #endif 707 #endif
708 for ( i=0; i<(nread-(packetsize-1)); i += packetsize ) { 708 for ( i=0; i<(nread-(packetsize-1)); i += packetsize ) {
709 switch (mouse_drv) { 709 switch (mouse_drv) {
710 case MOUSE_NONE: 710 case MOUSE_NONE:
711 break; 711 break;
712 case MOUSE_GPM: 712 case MOUSE_MSC:
713 /* GPM protocol has 0x80 in high byte */ 713 /* MSC protocol has 0x80 in high byte */
714 if ( (mousebuf[i] & 0xF8) != 0x80 ) { 714 if ( (mousebuf[i] & 0xF8) != 0x80 ) {
715 /* Go to next byte */ 715 /* Go to next byte */
716 i -= (packetsize-1); 716 i -= (packetsize-1);
717 continue; 717 continue;
718 } 718 }
823 start = 0; 823 start = 0;
824 } 824 }
825 return; 825 return;
826 } 826 }
827 827
828 /* Handle switching to another VC, returns when our VC is back */ 828 /* Handle switching to another VC, returns when our VC is back.
829 This isn't necessarily the best solution. For SDL 1.3 we need
830 a way of notifying the application when we lose access to the
831 video hardware and when we regain it.
832 */
829 static void switch_vt(_THIS, unsigned short which) 833 static void switch_vt(_THIS, unsigned short which)
830 { 834 {
831 struct vt_stat vtstate; 835 struct vt_stat vtstate;
832 unsigned short current; 836 unsigned short current;
833 SDL_Surface *screen; 837 SDL_Surface *screen;
842 } 846 }
843 current = vtstate.v_active; 847 current = vtstate.v_active;
844 848
845 /* Save the contents of the screen, and go to text mode */ 849 /* Save the contents of the screen, and go to text mode */
846 SDL_mutexP(hw_lock); 850 SDL_mutexP(hw_lock);
851 wait_idle(this);
847 screen = SDL_VideoSurface; 852 screen = SDL_VideoSurface;
848 screen_arealen = (screen->h*screen->pitch); 853 screen_arealen = (screen->h*screen->pitch);
849 screen_contents = (Uint8 *)malloc(screen_arealen); 854 screen_contents = (Uint8 *)malloc(screen_arealen);
850 if ( screen_contents ) { 855 if ( screen_contents ) {
851 memcpy(screen_contents, screen->pixels, screen_arealen); 856 memcpy(screen_contents, screen->pixels, screen_arealen);
906 case SDLK_F9: 911 case SDLK_F9:
907 case SDLK_F10: 912 case SDLK_F10:
908 case SDLK_F11: 913 case SDLK_F11:
909 case SDLK_F12: 914 case SDLK_F12:
910 if ( SDL_GetModState() & KMOD_ALT ) { 915 if ( SDL_GetModState() & KMOD_ALT ) {
911 switch_vt(this, (keysym.sym-SDLK_F1)+1); 916 if ( pressed ) {
917 switch_vt(this, (keysym.sym-SDLK_F1)+1);
918 }
912 break; 919 break;
913 } 920 }
914 /* Fall through to normal processing */ 921 /* Fall through to normal processing */
915 default: 922 default:
916 posted += SDL_PrivateKeyboard(pressed, &keysym); 923 posted += SDL_PrivateKeyboard(pressed, &keysym);