src/video/fbcon/SDL_fbevents.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/fbcon/SDL_fbevents.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/fbcon/SDL_fbevents.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -63,7 +63,7 @@
     1.4  static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
     1.5  static SDLKey keymap[128];
     1.6  static Uint16 keymap_temp[128]; /* only used at startup */
     1.7 -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym);
     1.8 +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym);
     1.9  
    1.10  /* Ugh, we have to duplicate the kernel's keysym mapping code...
    1.11     Oh, it's not so bad. :-)
    1.12 @@ -71,7 +71,7 @@
    1.13     FIXME: Add keyboard LED handling code
    1.14   */
    1.15  static void
    1.16 -FB_vgainitkeymaps (int fd)
    1.17 +FB_vgainitkeymaps(int fd)
    1.18  {
    1.19      struct kbentry entry;
    1.20      int map, i;
    1.21 @@ -83,21 +83,21 @@
    1.22  
    1.23      /* Load all the keysym mappings */
    1.24      for (map = 0; map < NUM_VGAKEYMAPS; ++map) {
    1.25 -        SDL_memset (vga_keymap[map], 0, NR_KEYS * sizeof (Uint16));
    1.26 +        SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16));
    1.27          for (i = 0; i < NR_KEYS; ++i) {
    1.28              entry.kb_table = map;
    1.29              entry.kb_index = i;
    1.30 -            if (ioctl (fd, KDGKBENT, &entry) == 0) {
    1.31 +            if (ioctl(fd, KDGKBENT, &entry) == 0) {
    1.32                  /* fill keytemp. This replaces SDL_fbkeys.h */
    1.33                  if ((map == 0) && (i < 128)) {
    1.34                      keymap_temp[i] = entry.kb_value;
    1.35                  }
    1.36                  /* The "Enter" key is a special case */
    1.37                  if (entry.kb_value == K_ENTER) {
    1.38 -                    entry.kb_value = K (KT_ASCII, 13);
    1.39 +                    entry.kb_value = K(KT_ASCII, 13);
    1.40                  }
    1.41                  /* Handle numpad specially as well */
    1.42 -                if (KTYP (entry.kb_value) == KT_PAD) {
    1.43 +                if (KTYP(entry.kb_value) == KT_PAD) {
    1.44                      switch (entry.kb_value) {
    1.45                      case K_P0:
    1.46                      case K_P1:
    1.47 @@ -113,34 +113,34 @@
    1.48                          vga_keymap[map][i] += '0';
    1.49                          break;
    1.50                      case K_PPLUS:
    1.51 -                        vga_keymap[map][i] = K (KT_ASCII, '+');
    1.52 +                        vga_keymap[map][i] = K(KT_ASCII, '+');
    1.53                          break;
    1.54                      case K_PMINUS:
    1.55 -                        vga_keymap[map][i] = K (KT_ASCII, '-');
    1.56 +                        vga_keymap[map][i] = K(KT_ASCII, '-');
    1.57                          break;
    1.58                      case K_PSTAR:
    1.59 -                        vga_keymap[map][i] = K (KT_ASCII, '*');
    1.60 +                        vga_keymap[map][i] = K(KT_ASCII, '*');
    1.61                          break;
    1.62                      case K_PSLASH:
    1.63 -                        vga_keymap[map][i] = K (KT_ASCII, '/');
    1.64 +                        vga_keymap[map][i] = K(KT_ASCII, '/');
    1.65                          break;
    1.66                      case K_PENTER:
    1.67 -                        vga_keymap[map][i] = K (KT_ASCII, '\r');
    1.68 +                        vga_keymap[map][i] = K(KT_ASCII, '\r');
    1.69                          break;
    1.70                      case K_PCOMMA:
    1.71 -                        vga_keymap[map][i] = K (KT_ASCII, ',');
    1.72 +                        vga_keymap[map][i] = K(KT_ASCII, ',');
    1.73                          break;
    1.74                      case K_PDOT:
    1.75 -                        vga_keymap[map][i] = K (KT_ASCII, '.');
    1.76 +                        vga_keymap[map][i] = K(KT_ASCII, '.');
    1.77                          break;
    1.78                      default:
    1.79                          break;
    1.80                      }
    1.81                  }
    1.82                  /* Do the normal key translation */
    1.83 -                if ((KTYP (entry.kb_value) == KT_LATIN) ||
    1.84 -                    (KTYP (entry.kb_value) == KT_ASCII) ||
    1.85 -                    (KTYP (entry.kb_value) == KT_LETTER)) {
    1.86 +                if ((KTYP(entry.kb_value) == KT_LATIN) ||
    1.87 +                    (KTYP(entry.kb_value) == KT_ASCII) ||
    1.88 +                    (KTYP(entry.kb_value) == KT_LETTER)) {
    1.89                      vga_keymap[map][i] = entry.kb_value;
    1.90                  }
    1.91              }
    1.92 @@ -149,44 +149,44 @@
    1.93  }
    1.94  
    1.95  int
    1.96 -FB_InGraphicsMode (_THIS)
    1.97 +FB_InGraphicsMode(_THIS)
    1.98  {
    1.99      return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0));
   1.100  }
   1.101  
   1.102  int
   1.103 -FB_EnterGraphicsMode (_THIS)
   1.104 +FB_EnterGraphicsMode(_THIS)
   1.105  {
   1.106      struct termios keyboard_termios;
   1.107  
   1.108      /* Set medium-raw keyboard mode */
   1.109 -    if ((keyboard_fd >= 0) && !FB_InGraphicsMode (this)) {
   1.110 +    if ((keyboard_fd >= 0) && !FB_InGraphicsMode(this)) {
   1.111  
   1.112          /* Switch to the correct virtual terminal */
   1.113          if (current_vt > 0) {
   1.114              struct vt_stat vtstate;
   1.115  
   1.116 -            if (ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
   1.117 +            if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
   1.118                  saved_vt = vtstate.v_active;
   1.119              }
   1.120 -            if (ioctl (keyboard_fd, VT_ACTIVATE, current_vt) == 0) {
   1.121 -                ioctl (keyboard_fd, VT_WAITACTIVE, current_vt);
   1.122 +            if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) {
   1.123 +                ioctl(keyboard_fd, VT_WAITACTIVE, current_vt);
   1.124              }
   1.125          }
   1.126  
   1.127          /* Set the terminal input mode */
   1.128 -        if (tcgetattr (keyboard_fd, &saved_kbd_termios) < 0) {
   1.129 -            SDL_SetError ("Unable to get terminal attributes");
   1.130 +        if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) {
   1.131 +            SDL_SetError("Unable to get terminal attributes");
   1.132              if (keyboard_fd > 0) {
   1.133 -                close (keyboard_fd);
   1.134 +                close(keyboard_fd);
   1.135              }
   1.136              keyboard_fd = -1;
   1.137              return (-1);
   1.138          }
   1.139 -        if (ioctl (keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) {
   1.140 -            SDL_SetError ("Unable to get current keyboard mode");
   1.141 +        if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) {
   1.142 +            SDL_SetError("Unable to get current keyboard mode");
   1.143              if (keyboard_fd > 0) {
   1.144 -                close (keyboard_fd);
   1.145 +                close(keyboard_fd);
   1.146              }
   1.147              keyboard_fd = -1;
   1.148              return (-1);
   1.149 @@ -197,59 +197,59 @@
   1.150              ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
   1.151          keyboard_termios.c_cc[VMIN] = 0;
   1.152          keyboard_termios.c_cc[VTIME] = 0;
   1.153 -        if (tcsetattr (keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
   1.154 -            FB_CloseKeyboard (this);
   1.155 -            SDL_SetError ("Unable to set terminal attributes");
   1.156 +        if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
   1.157 +            FB_CloseKeyboard(this);
   1.158 +            SDL_SetError("Unable to set terminal attributes");
   1.159              return (-1);
   1.160          }
   1.161          /* This will fail if we aren't root or this isn't our tty */
   1.162 -        if (ioctl (keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   1.163 -            FB_CloseKeyboard (this);
   1.164 -            SDL_SetError ("Unable to set keyboard in raw mode");
   1.165 +        if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   1.166 +            FB_CloseKeyboard(this);
   1.167 +            SDL_SetError("Unable to set keyboard in raw mode");
   1.168              return (-1);
   1.169          }
   1.170 -        if (ioctl (keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) {
   1.171 -            FB_CloseKeyboard (this);
   1.172 -            SDL_SetError ("Unable to set keyboard in graphics mode");
   1.173 +        if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) {
   1.174 +            FB_CloseKeyboard(this);
   1.175 +            SDL_SetError("Unable to set keyboard in graphics mode");
   1.176              return (-1);
   1.177          }
   1.178          /* Prevent switching the virtual terminal */
   1.179 -        ioctl (keyboard_fd, VT_LOCKSWITCH, 1);
   1.180 +        ioctl(keyboard_fd, VT_LOCKSWITCH, 1);
   1.181      }
   1.182      return (keyboard_fd);
   1.183  }
   1.184  
   1.185  void
   1.186 -FB_LeaveGraphicsMode (_THIS)
   1.187 +FB_LeaveGraphicsMode(_THIS)
   1.188  {
   1.189 -    if (FB_InGraphicsMode (this)) {
   1.190 -        ioctl (keyboard_fd, KDSETMODE, KD_TEXT);
   1.191 -        ioctl (keyboard_fd, KDSKBMODE, saved_kbd_mode);
   1.192 -        tcsetattr (keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
   1.193 +    if (FB_InGraphicsMode(this)) {
   1.194 +        ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
   1.195 +        ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode);
   1.196 +        tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
   1.197          saved_kbd_mode = -1;
   1.198  
   1.199          /* Head back over to the original virtual terminal */
   1.200 -        ioctl (keyboard_fd, VT_UNLOCKSWITCH, 1);
   1.201 +        ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1);
   1.202          if (saved_vt > 0) {
   1.203 -            ioctl (keyboard_fd, VT_ACTIVATE, saved_vt);
   1.204 +            ioctl(keyboard_fd, VT_ACTIVATE, saved_vt);
   1.205          }
   1.206      }
   1.207  }
   1.208  
   1.209  void
   1.210 -FB_CloseKeyboard (_THIS)
   1.211 +FB_CloseKeyboard(_THIS)
   1.212  {
   1.213      if (keyboard_fd >= 0) {
   1.214 -        FB_LeaveGraphicsMode (this);
   1.215 +        FB_LeaveGraphicsMode(this);
   1.216          if (keyboard_fd > 0) {
   1.217 -            close (keyboard_fd);
   1.218 +            close(keyboard_fd);
   1.219          }
   1.220      }
   1.221      keyboard_fd = -1;
   1.222  }
   1.223  
   1.224  int
   1.225 -FB_OpenKeyboard (_THIS)
   1.226 +FB_OpenKeyboard(_THIS)
   1.227  {
   1.228      /* Open only if not already opened */
   1.229      if (keyboard_fd < 0) {
   1.230 @@ -260,33 +260,33 @@
   1.231          /* Try to query for a free virtual terminal */
   1.232          tty0_fd = -1;
   1.233          for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
   1.234 -            tty0_fd = open (tty0[i], O_WRONLY, 0);
   1.235 +            tty0_fd = open(tty0[i], O_WRONLY, 0);
   1.236          }
   1.237          if (tty0_fd < 0) {
   1.238 -            tty0_fd = dup (0);  /* Maybe stdin is a VT? */
   1.239 +            tty0_fd = dup(0);   /* Maybe stdin is a VT? */
   1.240          }
   1.241 -        ioctl (tty0_fd, VT_OPENQRY, &current_vt);
   1.242 -        close (tty0_fd);
   1.243 -        if ((geteuid () == 0) && (current_vt > 0)) {
   1.244 +        ioctl(tty0_fd, VT_OPENQRY, &current_vt);
   1.245 +        close(tty0_fd);
   1.246 +        if ((geteuid() == 0) && (current_vt > 0)) {
   1.247              for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) {
   1.248                  char vtpath[12];
   1.249  
   1.250 -                SDL_snprintf (vtpath, SDL_arraysize (vtpath), vcs[i],
   1.251 -                              current_vt);
   1.252 -                keyboard_fd = open (vtpath, O_RDWR, 0);
   1.253 +                SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i],
   1.254 +                             current_vt);
   1.255 +                keyboard_fd = open(vtpath, O_RDWR, 0);
   1.256  #ifdef DEBUG_KEYBOARD
   1.257 -                fprintf (stderr, "vtpath = %s, fd = %d\n",
   1.258 -                         vtpath, keyboard_fd);
   1.259 +                fprintf(stderr, "vtpath = %s, fd = %d\n",
   1.260 +                        vtpath, keyboard_fd);
   1.261  #endif /* DEBUG_KEYBOARD */
   1.262  
   1.263                  /* This needs to be our controlling tty
   1.264                     so that the kernel ioctl() calls work
   1.265                   */
   1.266                  if (keyboard_fd >= 0) {
   1.267 -                    tty0_fd = open ("/dev/tty", O_RDWR, 0);
   1.268 +                    tty0_fd = open("/dev/tty", O_RDWR, 0);
   1.269                      if (tty0_fd >= 0) {
   1.270 -                        ioctl (tty0_fd, TIOCNOTTY, 0);
   1.271 -                        close (tty0_fd);
   1.272 +                        ioctl(tty0_fd, TIOCNOTTY, 0);
   1.273 +                        close(tty0_fd);
   1.274                      }
   1.275                  }
   1.276              }
   1.277 @@ -295,31 +295,31 @@
   1.278              /* Last resort, maybe our tty is a usable VT */
   1.279              struct vt_stat vtstate;
   1.280  
   1.281 -            keyboard_fd = open ("/dev/tty", O_RDWR);
   1.282 +            keyboard_fd = open("/dev/tty", O_RDWR);
   1.283  
   1.284 -            if (ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
   1.285 +            if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
   1.286                  current_vt = vtstate.v_active;
   1.287              } else {
   1.288                  current_vt = 0;
   1.289              }
   1.290          }
   1.291  #ifdef DEBUG_KEYBOARD
   1.292 -        fprintf (stderr, "Current VT: %d\n", current_vt);
   1.293 +        fprintf(stderr, "Current VT: %d\n", current_vt);
   1.294  #endif
   1.295          saved_kbd_mode = -1;
   1.296  
   1.297          /* Make sure that our input is a console terminal */
   1.298          {
   1.299              int dummy;
   1.300 -            if (ioctl (keyboard_fd, KDGKBMODE, &dummy) < 0) {
   1.301 -                close (keyboard_fd);
   1.302 +            if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) {
   1.303 +                close(keyboard_fd);
   1.304                  keyboard_fd = -1;
   1.305 -                SDL_SetError ("Unable to open a console terminal");
   1.306 +                SDL_SetError("Unable to open a console terminal");
   1.307              }
   1.308          }
   1.309  
   1.310          /* Set up keymap */
   1.311 -        FB_vgainitkeymaps (keyboard_fd);
   1.312 +        FB_vgainitkeymaps(keyboard_fd);
   1.313      }
   1.314      return (keyboard_fd);
   1.315  }
   1.316 @@ -338,46 +338,46 @@
   1.317  } mouse_drv = MOUSE_NONE;
   1.318  
   1.319  void
   1.320 -FB_CloseMouse (_THIS)
   1.321 +FB_CloseMouse(_THIS)
   1.322  {
   1.323  #if SDL_INPUT_TSLIB
   1.324      if (ts_dev != NULL) {
   1.325 -        ts_close (ts_dev);
   1.326 +        ts_close(ts_dev);
   1.327          ts_dev = NULL;
   1.328          mouse_fd = -1;
   1.329      }
   1.330  #endif /* SDL_INPUT_TSLIB */
   1.331      if (mouse_fd > 0) {
   1.332 -        close (mouse_fd);
   1.333 +        close(mouse_fd);
   1.334      }
   1.335      mouse_fd = -1;
   1.336  }
   1.337  
   1.338  /* Returns processes listed in /proc with the desired name */
   1.339  static int
   1.340 -find_pid (DIR * proc, const char *wanted_name)
   1.341 +find_pid(DIR * proc, const char *wanted_name)
   1.342  {
   1.343      struct dirent *entry;
   1.344      int pid;
   1.345  
   1.346      /* First scan proc for the gpm process */
   1.347      pid = 0;
   1.348 -    while ((pid == 0) && ((entry = readdir (proc)) != NULL)) {
   1.349 -        if (isdigit (entry->d_name[0])) {
   1.350 +    while ((pid == 0) && ((entry = readdir(proc)) != NULL)) {
   1.351 +        if (isdigit(entry->d_name[0])) {
   1.352              FILE *status;
   1.353              char path[PATH_MAX];
   1.354              char name[PATH_MAX];
   1.355  
   1.356 -            SDL_snprintf (path, SDL_arraysize (path), "/proc/%s/status",
   1.357 -                          entry->d_name);
   1.358 -            status = fopen (path, "r");
   1.359 +            SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status",
   1.360 +                         entry->d_name);
   1.361 +            status = fopen(path, "r");
   1.362              if (status) {
   1.363                  name[0] = '\0';
   1.364 -                fscanf (status, "Name: %s", name);
   1.365 -                if (SDL_strcmp (name, wanted_name) == 0) {
   1.366 -                    pid = SDL_atoi (entry->d_name);
   1.367 +                fscanf(status, "Name: %s", name);
   1.368 +                if (SDL_strcmp(name, wanted_name) == 0) {
   1.369 +                    pid = SDL_atoi(entry->d_name);
   1.370                  }
   1.371 -                fclose (status);
   1.372 +                fclose(status);
   1.373              }
   1.374          }
   1.375      }
   1.376 @@ -386,7 +386,7 @@
   1.377  
   1.378  /* Returns true if /dev/gpmdata is being written to by gpm */
   1.379  static int
   1.380 -gpm_available (char *proto, size_t protolen)
   1.381 +gpm_available(char *proto, size_t protolen)
   1.382  {
   1.383      int available;
   1.384      DIR *proc;
   1.385 @@ -397,67 +397,66 @@
   1.386  
   1.387      /* Don't bother looking if the fifo isn't there */
   1.388  #ifdef DEBUG_MOUSE
   1.389 -    fprintf (stderr, "testing gpm\n");
   1.390 +    fprintf(stderr, "testing gpm\n");
   1.391  #endif
   1.392 -    if (access (GPM_NODE_FIFO, F_OK) < 0) {
   1.393 +    if (access(GPM_NODE_FIFO, F_OK) < 0) {
   1.394          return (0);
   1.395      }
   1.396  
   1.397      available = 0;
   1.398 -    proc = opendir ("/proc");
   1.399 +    proc = opendir("/proc");
   1.400      if (proc) {
   1.401          char raw_proto[10] = { '\0' };
   1.402          char repeat_proto[10] = { '\0' };
   1.403 -        while (!available && (pid = find_pid (proc, "gpm")) > 0) {
   1.404 -            SDL_snprintf (path, SDL_arraysize (path), "/proc/%d/cmdline",
   1.405 -                          pid);
   1.406 -            cmdline = open (path, O_RDONLY, 0);
   1.407 +        while (!available && (pid = find_pid(proc, "gpm")) > 0) {
   1.408 +            SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
   1.409 +            cmdline = open(path, O_RDONLY, 0);
   1.410              if (cmdline >= 0) {
   1.411 -                len = read (cmdline, args, sizeof (args));
   1.412 +                len = read(cmdline, args, sizeof(args));
   1.413                  arg = args;
   1.414                  while (len > 0) {
   1.415 -                    arglen = SDL_strlen (arg) + 1;
   1.416 +                    arglen = SDL_strlen(arg) + 1;
   1.417  #ifdef DEBUG_MOUSE
   1.418 -                    fprintf (stderr, "gpm arg %s len %d\n", arg, arglen);
   1.419 +                    fprintf(stderr, "gpm arg %s len %d\n", arg, arglen);
   1.420  #endif
   1.421 -                    if (SDL_strcmp (arg, "-t") == 0) {
   1.422 +                    if (SDL_strcmp(arg, "-t") == 0) {
   1.423                          /* protocol string, keep it for later */
   1.424                          char *t, *s;
   1.425                          t = arg + arglen;
   1.426 -                        s = SDL_strchr (t, ' ');
   1.427 +                        s = SDL_strchr(t, ' ');
   1.428                          if (s)
   1.429                              *s = 0;
   1.430 -                        SDL_strlcpy (raw_proto, t, SDL_arraysize (raw_proto));
   1.431 +                        SDL_strlcpy(raw_proto, t, SDL_arraysize(raw_proto));
   1.432                          if (s)
   1.433                              *s = ' ';
   1.434                      }
   1.435 -                    if (SDL_strncmp (arg, "-R", 2) == 0) {
   1.436 +                    if (SDL_strncmp(arg, "-R", 2) == 0) {
   1.437                          char *t, *s;
   1.438                          available = 1;
   1.439                          t = arg + 2;
   1.440 -                        s = SDL_strchr (t, ' ');
   1.441 +                        s = SDL_strchr(t, ' ');
   1.442                          if (s)
   1.443                              *s = 0;
   1.444 -                        SDL_strlcpy (repeat_proto, t,
   1.445 -                                     SDL_arraysize (repeat_proto));
   1.446 +                        SDL_strlcpy(repeat_proto, t,
   1.447 +                                    SDL_arraysize(repeat_proto));
   1.448                          if (s)
   1.449                              *s = ' ';
   1.450                      }
   1.451                      len -= arglen;
   1.452                      arg += arglen;
   1.453                  }
   1.454 -                close (cmdline);
   1.455 +                close(cmdline);
   1.456              }
   1.457          }
   1.458 -        closedir (proc);
   1.459 +        closedir(proc);
   1.460  
   1.461          if (available) {
   1.462 -            if (SDL_strcmp (repeat_proto, "raw") == 0) {
   1.463 -                SDL_strlcpy (proto, raw_proto, protolen);
   1.464 +            if (SDL_strcmp(repeat_proto, "raw") == 0) {
   1.465 +                SDL_strlcpy(proto, raw_proto, protolen);
   1.466              } else if (*repeat_proto) {
   1.467 -                SDL_strlcpy (proto, repeat_proto, protolen);
   1.468 +                SDL_strlcpy(proto, repeat_proto, protolen);
   1.469              } else {
   1.470 -                SDL_strlcpy (proto, "msc", protolen);
   1.471 +                SDL_strlcpy(proto, "msc", protolen);
   1.472              }
   1.473          }
   1.474      }
   1.475 @@ -471,7 +470,7 @@
   1.476   *  device to see which mode it's actually in.
   1.477   */
   1.478  static int
   1.479 -set_imps2_mode (int fd)
   1.480 +set_imps2_mode(int fd)
   1.481  {
   1.482      /* If you wanted to control the mouse mode (and we do :)  ) ...
   1.483         Set IMPS/2 protocol:
   1.484 @@ -485,7 +484,7 @@
   1.485      struct timeval tv;
   1.486      int retval = 0;
   1.487  
   1.488 -    if (write (fd, &set_imps2, sizeof (set_imps2)) == sizeof (set_imps2)) {
   1.489 +    if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) {
   1.490          /* Don't reset it, that'll clear IMPS/2 mode on some mice
   1.491             if (write(fd, &reset, sizeof (reset)) == sizeof (reset) ) {
   1.492             retval = 1;
   1.493 @@ -494,13 +493,13 @@
   1.494      }
   1.495  
   1.496      /* Get rid of any chatter from the above */
   1.497 -    FD_ZERO (&fdset);
   1.498 -    FD_SET (fd, &fdset);
   1.499 +    FD_ZERO(&fdset);
   1.500 +    FD_SET(fd, &fdset);
   1.501      tv.tv_sec = 0;
   1.502      tv.tv_usec = 0;
   1.503 -    while (select (fd + 1, &fdset, 0, 0, &tv) > 0) {
   1.504 +    while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
   1.505          char temp[32];
   1.506 -        read (fd, temp, sizeof (temp));
   1.507 +        read(fd, temp, sizeof(temp));
   1.508      }
   1.509  
   1.510      return retval;
   1.511 @@ -509,13 +508,13 @@
   1.512  
   1.513  /* Returns true if the mouse uses the IMPS/2 protocol */
   1.514  static int
   1.515 -detect_imps2 (int fd)
   1.516 +detect_imps2(int fd)
   1.517  {
   1.518      int imps2;
   1.519  
   1.520      imps2 = 0;
   1.521  
   1.522 -    if (SDL_getenv ("SDL_MOUSEDEV_IMPS2")) {
   1.523 +    if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) {
   1.524          imps2 = 1;
   1.525      }
   1.526      if (!imps2) {
   1.527 @@ -524,35 +523,35 @@
   1.528          struct timeval tv;
   1.529  
   1.530          /* Get rid of any mouse motion noise */
   1.531 -        FD_ZERO (&fdset);
   1.532 -        FD_SET (fd, &fdset);
   1.533 +        FD_ZERO(&fdset);
   1.534 +        FD_SET(fd, &fdset);
   1.535          tv.tv_sec = 0;
   1.536          tv.tv_usec = 0;
   1.537 -        while (select (fd + 1, &fdset, 0, 0, &tv) > 0) {
   1.538 +        while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
   1.539              char temp[32];
   1.540 -            read (fd, temp, sizeof (temp));
   1.541 +            read(fd, temp, sizeof(temp));
   1.542          }
   1.543  
   1.544          /* Query for the type of mouse protocol */
   1.545 -        if (write (fd, &query_ps2, sizeof (query_ps2)) == sizeof (query_ps2)) {
   1.546 +        if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) {
   1.547              Uint8 ch = 0;
   1.548  
   1.549              /* Get the mouse protocol response */
   1.550              do {
   1.551 -                FD_ZERO (&fdset);
   1.552 -                FD_SET (fd, &fdset);
   1.553 +                FD_ZERO(&fdset);
   1.554 +                FD_SET(fd, &fdset);
   1.555                  tv.tv_sec = 1;
   1.556                  tv.tv_usec = 0;
   1.557 -                if (select (fd + 1, &fdset, 0, 0, &tv) < 1) {
   1.558 +                if (select(fd + 1, &fdset, 0, 0, &tv) < 1) {
   1.559                      break;
   1.560                  }
   1.561              }
   1.562 -            while ((read (fd, &ch, sizeof (ch)) == sizeof (ch)) &&
   1.563 +            while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
   1.564                     ((ch == 0xFA) || (ch == 0xAA)));
   1.565  
   1.566              /* Experimental values (Logitech wheelmouse) */
   1.567  #ifdef DEBUG_MOUSE
   1.568 -            fprintf (stderr, "Last mouse mode: 0x%x\n", ch);
   1.569 +            fprintf(stderr, "Last mouse mode: 0x%x\n", ch);
   1.570  #endif
   1.571              if ((ch == 3) || (ch == 4)) {
   1.572                  imps2 = 1;
   1.573 @@ -563,28 +562,28 @@
   1.574  }
   1.575  
   1.576  int
   1.577 -FB_OpenMouse (_THIS)
   1.578 +FB_OpenMouse(_THIS)
   1.579  {
   1.580      int i;
   1.581      const char *mousedev;
   1.582      const char *mousedrv;
   1.583  
   1.584 -    mousedrv = SDL_getenv ("SDL_MOUSEDRV");
   1.585 -    mousedev = SDL_getenv ("SDL_MOUSEDEV");
   1.586 +    mousedrv = SDL_getenv("SDL_MOUSEDRV");
   1.587 +    mousedev = SDL_getenv("SDL_MOUSEDEV");
   1.588      mouse_fd = -1;
   1.589  
   1.590  #if SDL_INPUT_TSLIB
   1.591 -    if (mousedrv && (SDL_strcmp (mousedrv, "TSLIB") == 0)) {
   1.592 +    if (mousedrv && (SDL_strcmp(mousedrv, "TSLIB") == 0)) {
   1.593          if (mousedev == NULL)
   1.594 -            mousedev = SDL_getenv ("TSLIB_TSDEVICE");
   1.595 +            mousedev = SDL_getenv("TSLIB_TSDEVICE");
   1.596          if (mousedev != NULL) {
   1.597 -            ts_dev = ts_open (mousedev, 1);
   1.598 -            if ((ts_dev != NULL) && (ts_config (ts_dev) >= 0)) {
   1.599 +            ts_dev = ts_open(mousedev, 1);
   1.600 +            if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) {
   1.601  #ifdef DEBUG_MOUSE
   1.602 -                fprintf (stderr, "Using tslib touchscreen\n");
   1.603 +                fprintf(stderr, "Using tslib touchscreen\n");
   1.604  #endif
   1.605                  mouse_drv = MOUSE_TSLIB;
   1.606 -                mouse_fd = ts_fd (ts_dev);
   1.607 +                mouse_fd = ts_fd(ts_dev);
   1.608                  return mouse_fd;
   1.609              }
   1.610          }
   1.611 @@ -595,12 +594,12 @@
   1.612  
   1.613      /* ELO TOUCHSCREEN SUPPORT */
   1.614  
   1.615 -    if (mousedrv && (SDL_strcmp (mousedrv, "ELO") == 0)) {
   1.616 -        mouse_fd = open (mousedev, O_RDWR);
   1.617 +    if (mousedrv && (SDL_strcmp(mousedrv, "ELO") == 0)) {
   1.618 +        mouse_fd = open(mousedev, O_RDWR);
   1.619          if (mouse_fd >= 0) {
   1.620 -            if (eloInitController (mouse_fd)) {
   1.621 +            if (eloInitController(mouse_fd)) {
   1.622  #ifdef DEBUG_MOUSE
   1.623 -                fprintf (stderr, "Using ELO touchscreen\n");
   1.624 +                fprintf(stderr, "Using ELO touchscreen\n");
   1.625  #endif
   1.626                  mouse_drv = MOUSE_ELO;
   1.627              }
   1.628 @@ -622,56 +621,56 @@
   1.629          /* First try to use GPM in repeater mode */
   1.630          if (mouse_fd < 0) {
   1.631              char proto[10];
   1.632 -            if (gpm_available (proto, SDL_arraysize (proto))) {
   1.633 -                mouse_fd = open (GPM_NODE_FIFO, O_RDONLY, 0);
   1.634 +            if (gpm_available(proto, SDL_arraysize(proto))) {
   1.635 +                mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0);
   1.636                  if (mouse_fd >= 0) {
   1.637 -                    if (SDL_strcmp (proto, "msc") == 0) {
   1.638 +                    if (SDL_strcmp(proto, "msc") == 0) {
   1.639                          mouse_drv = MOUSE_MSC;
   1.640 -                    } else if (SDL_strcmp (proto, "ps2") == 0) {
   1.641 +                    } else if (SDL_strcmp(proto, "ps2") == 0) {
   1.642                          mouse_drv = MOUSE_PS2;
   1.643 -                    } else if (SDL_strcmp (proto, "imps2") == 0) {
   1.644 +                    } else if (SDL_strcmp(proto, "imps2") == 0) {
   1.645                          mouse_drv = MOUSE_IMPS2;
   1.646 -                    } else if (SDL_strcmp (proto, "ms") == 0 ||
   1.647 -                               SDL_strcmp (proto, "bare") == 0) {
   1.648 +                    } else if (SDL_strcmp(proto, "ms") == 0 ||
   1.649 +                               SDL_strcmp(proto, "bare") == 0) {
   1.650                          mouse_drv = MOUSE_MS;
   1.651 -                    } else if (SDL_strcmp (proto, "bm") == 0) {
   1.652 +                    } else if (SDL_strcmp(proto, "bm") == 0) {
   1.653                          mouse_drv = MOUSE_BM;
   1.654                      } else {
   1.655                          /* Unknown protocol... */
   1.656  #ifdef DEBUG_MOUSE
   1.657 -                        fprintf (stderr,
   1.658 -                                 "GPM mouse using unknown protocol = %s\n",
   1.659 -                                 proto);
   1.660 +                        fprintf(stderr,
   1.661 +                                "GPM mouse using unknown protocol = %s\n",
   1.662 +                                proto);
   1.663  #endif
   1.664 -                        close (mouse_fd);
   1.665 +                        close(mouse_fd);
   1.666                          mouse_fd = -1;
   1.667                      }
   1.668                  }
   1.669  #ifdef DEBUG_MOUSE
   1.670                  if (mouse_fd >= 0) {
   1.671 -                    fprintf (stderr,
   1.672 -                             "Using GPM mouse, protocol = %s\n", proto);
   1.673 +                    fprintf(stderr,
   1.674 +                            "Using GPM mouse, protocol = %s\n", proto);
   1.675                  }
   1.676  #endif /* DEBUG_MOUSE */
   1.677              }
   1.678          }
   1.679          /* Now try to use a modern PS/2 mouse */
   1.680          for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) {
   1.681 -            mouse_fd = open (ps2mice[i], O_RDWR, 0);
   1.682 +            mouse_fd = open(ps2mice[i], O_RDWR, 0);
   1.683              if (mouse_fd < 0) {
   1.684 -                mouse_fd = open (ps2mice[i], O_RDONLY, 0);
   1.685 +                mouse_fd = open(ps2mice[i], O_RDONLY, 0);
   1.686              }
   1.687              if (mouse_fd >= 0) {
   1.688                  /* rcg06112001 Attempt to set IMPS/2 mode */
   1.689 -                set_imps2_mode (mouse_fd);
   1.690 -                if (detect_imps2 (mouse_fd)) {
   1.691 +                set_imps2_mode(mouse_fd);
   1.692 +                if (detect_imps2(mouse_fd)) {
   1.693  #ifdef DEBUG_MOUSE
   1.694 -                    fprintf (stderr, "Using IMPS2 mouse\n");
   1.695 +                    fprintf(stderr, "Using IMPS2 mouse\n");
   1.696  #endif
   1.697                      mouse_drv = MOUSE_IMPS2;
   1.698                  } else {
   1.699  #ifdef DEBUG_MOUSE
   1.700 -                    fprintf (stderr, "Using PS2 mouse\n");
   1.701 +                    fprintf(stderr, "Using PS2 mouse\n");
   1.702  #endif
   1.703                      mouse_drv = MOUSE_PS2;
   1.704                  }
   1.705 @@ -679,10 +678,10 @@
   1.706          }
   1.707          /* Next try to use a PPC ADB port mouse */
   1.708          if (mouse_fd < 0) {
   1.709 -            mouse_fd = open ("/dev/adbmouse", O_RDONLY, 0);
   1.710 +            mouse_fd = open("/dev/adbmouse", O_RDONLY, 0);
   1.711              if (mouse_fd >= 0) {
   1.712  #ifdef DEBUG_MOUSE
   1.713 -                fprintf (stderr, "Using ADB mouse\n");
   1.714 +                fprintf(stderr, "Using ADB mouse\n");
   1.715  #endif
   1.716                  mouse_drv = MOUSE_BM;
   1.717              }
   1.718 @@ -693,12 +692,12 @@
   1.719          if (mousedev == NULL) {
   1.720              mousedev = "/dev/mouse";
   1.721          }
   1.722 -        mouse_fd = open (mousedev, O_RDONLY, 0);
   1.723 +        mouse_fd = open(mousedev, O_RDONLY, 0);
   1.724          if (mouse_fd >= 0) {
   1.725              struct termios mouse_termios;
   1.726  
   1.727              /* Set the sampling speed to 1200 baud */
   1.728 -            tcgetattr (mouse_fd, &mouse_termios);
   1.729 +            tcgetattr(mouse_fd, &mouse_termios);
   1.730              mouse_termios.c_iflag = IGNBRK | IGNPAR;
   1.731              mouse_termios.c_oflag = 0;
   1.732              mouse_termios.c_lflag = 0;
   1.733 @@ -708,18 +707,16 @@
   1.734              mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL;
   1.735              mouse_termios.c_cflag |= CS8;
   1.736              mouse_termios.c_cflag |= B1200;
   1.737 -            tcsetattr (mouse_fd, TCSAFLUSH, &mouse_termios);
   1.738 -            if (mousedrv && (SDL_strcmp (mousedrv, "PS2") == 0)) {
   1.739 +            tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios);
   1.740 +            if (mousedrv && (SDL_strcmp(mousedrv, "PS2") == 0)) {
   1.741  #ifdef DEBUG_MOUSE
   1.742 -                fprintf (stderr,
   1.743 -                         "Using (user specified) PS2 mouse on %s\n",
   1.744 -                         mousedev);
   1.745 +                fprintf(stderr,
   1.746 +                        "Using (user specified) PS2 mouse on %s\n", mousedev);
   1.747  #endif
   1.748                  mouse_drv = MOUSE_PS2;
   1.749              } else {
   1.750  #ifdef DEBUG_MOUSE
   1.751 -                fprintf (stderr, "Using (default) MS mouse on %s\n",
   1.752 -                         mousedev);
   1.753 +                fprintf(stderr, "Using (default) MS mouse on %s\n", mousedev);
   1.754  #endif
   1.755                  mouse_drv = MOUSE_MS;
   1.756              }
   1.757 @@ -734,7 +731,7 @@
   1.758  static int posted = 0;
   1.759  
   1.760  void
   1.761 -FB_vgamousecallback (int button, int relative, int dx, int dy)
   1.762 +FB_vgamousecallback(int button, int relative, int dx, int dy)
   1.763  {
   1.764      int button_1, button_3;
   1.765      int button_state;
   1.766 @@ -743,7 +740,7 @@
   1.767      Uint8 state;
   1.768  
   1.769      if (dx || dy) {
   1.770 -        posted += SDL_PrivateMouseMotion (0, relative, dx, dy);
   1.771 +        posted += SDL_PrivateMouseMotion(0, relative, dx, dy);
   1.772      }
   1.773  
   1.774      /* Swap button 1 and 3 */
   1.775 @@ -753,7 +750,7 @@
   1.776      button |= (button_1 | button_3);
   1.777  
   1.778      /* See what changed */
   1.779 -    button_state = SDL_GetMouseState (NULL, NULL);
   1.780 +    button_state = SDL_GetMouseState(NULL, NULL);
   1.781      state_changed = button_state ^ button;
   1.782      for (i = 0; i < 8; ++i) {
   1.783          if (state_changed & (1 << i)) {
   1.784 @@ -762,7 +759,7 @@
   1.785              } else {
   1.786                  state = SDL_RELEASED;
   1.787              }
   1.788 -            posted += SDL_PrivateMouseButton (state, i + 1, 0, 0);
   1.789 +            posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
   1.790          }
   1.791      }
   1.792  }
   1.793 @@ -770,15 +767,15 @@
   1.794  /* Handle input from tslib */
   1.795  #if SDL_INPUT_TSLIB
   1.796  static void
   1.797 -handle_tslib (_THIS)
   1.798 +handle_tslib(_THIS)
   1.799  {
   1.800      struct ts_sample sample;
   1.801      int button;
   1.802  
   1.803 -    while (ts_read (ts_dev, &sample, 1) > 0) {
   1.804 +    while (ts_read(ts_dev, &sample, 1) > 0) {
   1.805          button = (sample.pressure > 0) ? 1 : 0;
   1.806          button <<= 2;           /* must report it as button 3 */
   1.807 -        FB_vgamousecallback (button, 0, sample.x, sample.y);
   1.808 +        FB_vgamousecallback(button, 0, sample.x, sample.y);
   1.809      }
   1.810      return;
   1.811  }
   1.812 @@ -788,7 +785,7 @@
   1.813     Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
   1.814   */
   1.815  static void
   1.816 -handle_mouse (_THIS)
   1.817 +handle_mouse(_THIS)
   1.818  {
   1.819      static int start = 0;
   1.820      static unsigned char mousebuf[BUFSIZ];
   1.821 @@ -804,7 +801,7 @@
   1.822      switch (mouse_drv) {
   1.823      case MOUSE_NONE:
   1.824          /* Ack! */
   1.825 -        read (mouse_fd, mousebuf, BUFSIZ);
   1.826 +        read(mouse_fd, mousebuf, BUFSIZ);
   1.827          return;
   1.828      case MOUSE_MSC:
   1.829          packetsize = 5;
   1.830 @@ -822,12 +819,12 @@
   1.831          if (eloReadPosition
   1.832              (this, mouse_fd, &dx, &dy, &button, &realx, &realy)) {
   1.833              button = (button & 0x01) << 2;
   1.834 -            FB_vgamousecallback (button, 0, dx, dy);
   1.835 +            FB_vgamousecallback(button, 0, dx, dy);
   1.836          }
   1.837          return;                 /* nothing left to do */
   1.838      case MOUSE_TSLIB:
   1.839  #if SDL_INPUT_TSLIB
   1.840 -        handle_tslib (this);
   1.841 +        handle_tslib(this);
   1.842  #endif
   1.843          return;                 /* nothing left to do */
   1.844      default:
   1.845 @@ -842,13 +839,13 @@
   1.846      }
   1.847  
   1.848      /* Read as many packets as possible */
   1.849 -    nread = read (mouse_fd, &mousebuf[start], BUFSIZ - start);
   1.850 +    nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start);
   1.851      if (nread < 0) {
   1.852          return;
   1.853      }
   1.854      nread += start;
   1.855  #ifdef DEBUG_MOUSE
   1.856 -    fprintf (stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
   1.857 +    fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
   1.858  #endif
   1.859      for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) {
   1.860          switch (mouse_drv) {
   1.861 @@ -900,10 +897,10 @@
   1.862              case 0x02:         /* DX = -1 */
   1.863                  break;
   1.864              case 0x0F:         /* DY = +1 (map button 4) */
   1.865 -                FB_vgamousecallback (button | (1 << 3), 1, 0, 0);
   1.866 +                FB_vgamousecallback(button | (1 << 3), 1, 0, 0);
   1.867                  break;
   1.868              case 0x01:         /* DY = -1 (map button 5) */
   1.869 -                FB_vgamousecallback (button | (1 << 4), 1, 0, 0);
   1.870 +                FB_vgamousecallback(button | (1 << 4), 1, 0, 0);
   1.871                  break;
   1.872              }
   1.873              break;
   1.874 @@ -940,10 +937,10 @@
   1.875              dy = 0;
   1.876              break;
   1.877          }
   1.878 -        FB_vgamousecallback (button, relative, dx, dy);
   1.879 +        FB_vgamousecallback(button, relative, dx, dy);
   1.880      }
   1.881      if (i < nread) {
   1.882 -        SDL_memcpy (mousebuf, &mousebuf[i], (nread - i));
   1.883 +        SDL_memcpy(mousebuf, &mousebuf[i], (nread - i));
   1.884          start = (nread - i);
   1.885      } else {
   1.886          start = 0;
   1.887 @@ -953,76 +950,76 @@
   1.888  
   1.889  /* Handle switching to another VC, returns when our VC is back */
   1.890  static void
   1.891 -switch_vt_prep (_THIS)
   1.892 +switch_vt_prep(_THIS)
   1.893  {
   1.894      SDL_Surface *screen = SDL_VideoSurface;
   1.895  
   1.896 -    SDL_PrivateAppActive (0,
   1.897 -                          (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
   1.898 -                           SDL_APPMOUSEFOCUS));
   1.899 +    SDL_PrivateAppActive(0,
   1.900 +                         (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
   1.901 +                          SDL_APPMOUSEFOCUS));
   1.902  
   1.903      /* Save the contents of the screen, and go to text mode */
   1.904 -    wait_idle (this);
   1.905 +    wait_idle(this);
   1.906      screen_arealen = ((screen->h + (2 * this->offset_y)) * screen->pitch);
   1.907 -    screen_contents = (Uint8 *) SDL_malloc (screen_arealen);
   1.908 +    screen_contents = (Uint8 *) SDL_malloc(screen_arealen);
   1.909      if (screen_contents) {
   1.910 -        SDL_memcpy (screen_contents, screen->pixels, screen_arealen);
   1.911 +        SDL_memcpy(screen_contents, screen->pixels, screen_arealen);
   1.912      }
   1.913 -    FB_SavePaletteTo (this, 256, screen_palette);
   1.914 -    ioctl (console_fd, FBIOGET_VSCREENINFO, &screen_vinfo);
   1.915 -    ioctl (keyboard_fd, KDSETMODE, KD_TEXT);
   1.916 -    ioctl (keyboard_fd, VT_UNLOCKSWITCH, 1);
   1.917 +    FB_SavePaletteTo(this, 256, screen_palette);
   1.918 +    ioctl(console_fd, FBIOGET_VSCREENINFO, &screen_vinfo);
   1.919 +    ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
   1.920 +    ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1);
   1.921  }
   1.922  static void
   1.923 -switch_vt_done (_THIS)
   1.924 +switch_vt_done(_THIS)
   1.925  {
   1.926      SDL_Surface *screen = SDL_VideoSurface;
   1.927  
   1.928      /* Restore graphics mode and the contents of the screen */
   1.929 -    ioctl (keyboard_fd, VT_LOCKSWITCH, 1);
   1.930 -    ioctl (keyboard_fd, KDSETMODE, KD_GRAPHICS);
   1.931 -    ioctl (console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo);
   1.932 -    FB_RestorePaletteFrom (this, 256, screen_palette);
   1.933 +    ioctl(keyboard_fd, VT_LOCKSWITCH, 1);
   1.934 +    ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS);
   1.935 +    ioctl(console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo);
   1.936 +    FB_RestorePaletteFrom(this, 256, screen_palette);
   1.937      if (screen_contents) {
   1.938 -        SDL_memcpy (screen->pixels, screen_contents, screen_arealen);
   1.939 -        SDL_free (screen_contents);
   1.940 +        SDL_memcpy(screen->pixels, screen_contents, screen_arealen);
   1.941 +        SDL_free(screen_contents);
   1.942          screen_contents = NULL;
   1.943      }
   1.944  
   1.945      /* Get updates to the shadow surface while switched away */
   1.946      if (SDL_ShadowSurface) {
   1.947 -        SDL_UpdateRect (SDL_ShadowSurface, 0, 0, 0, 0);
   1.948 +        SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0);
   1.949      }
   1.950  
   1.951 -    SDL_PrivateAppActive (1,
   1.952 -                          (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
   1.953 -                           SDL_APPMOUSEFOCUS));
   1.954 +    SDL_PrivateAppActive(1,
   1.955 +                         (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
   1.956 +                          SDL_APPMOUSEFOCUS));
   1.957  }
   1.958  static void
   1.959 -switch_vt (_THIS, unsigned short which)
   1.960 +switch_vt(_THIS, unsigned short which)
   1.961  {
   1.962      struct vt_stat vtstate;
   1.963  
   1.964      /* Figure out whether or not we're switching to a new console */
   1.965 -    if ((ioctl (keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
   1.966 +    if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
   1.967          (which == vtstate.v_active)) {
   1.968          return;
   1.969      }
   1.970  
   1.971      /* New console, switch to it */
   1.972 -    SDL_mutexP (hw_lock);
   1.973 -    switch_vt_prep (this);
   1.974 -    if (ioctl (keyboard_fd, VT_ACTIVATE, which) == 0) {
   1.975 -        ioctl (keyboard_fd, VT_WAITACTIVE, which);
   1.976 +    SDL_mutexP(hw_lock);
   1.977 +    switch_vt_prep(this);
   1.978 +    if (ioctl(keyboard_fd, VT_ACTIVATE, which) == 0) {
   1.979 +        ioctl(keyboard_fd, VT_WAITACTIVE, which);
   1.980          switched_away = 1;
   1.981      } else {
   1.982 -        switch_vt_done (this);
   1.983 +        switch_vt_done(this);
   1.984      }
   1.985 -    SDL_mutexV (hw_lock);
   1.986 +    SDL_mutexV(hw_lock);
   1.987  }
   1.988  
   1.989  static void
   1.990 -handle_keyboard (_THIS)
   1.991 +handle_keyboard(_THIS)
   1.992  {
   1.993      unsigned char keybuf[BUFSIZ];
   1.994      int i, nread;
   1.995 @@ -1030,7 +1027,7 @@
   1.996      int scancode;
   1.997      SDL_keysym keysym;
   1.998  
   1.999 -    nread = read (keyboard_fd, keybuf, BUFSIZ);
  1.1000 +    nread = read(keyboard_fd, keybuf, BUFSIZ);
  1.1001      for (i = 0; i < nread; ++i) {
  1.1002          scancode = keybuf[i] & 0x7F;
  1.1003          if (keybuf[i] & 0x80) {
  1.1004 @@ -1038,7 +1035,7 @@
  1.1005          } else {
  1.1006              pressed = SDL_PRESSED;
  1.1007          }
  1.1008 -        TranslateKey (scancode, &keysym);
  1.1009 +        TranslateKey(scancode, &keysym);
  1.1010          /* Handle Ctrl-Alt-FN for vt switch */
  1.1011          switch (keysym.sym) {
  1.1012          case SDLK_F1:
  1.1013 @@ -1053,23 +1050,23 @@
  1.1014          case SDLK_F10:
  1.1015          case SDLK_F11:
  1.1016          case SDLK_F12:
  1.1017 -            if ((SDL_GetModState () & KMOD_CTRL) &&
  1.1018 -                (SDL_GetModState () & KMOD_ALT)) {
  1.1019 +            if ((SDL_GetModState() & KMOD_CTRL) &&
  1.1020 +                (SDL_GetModState() & KMOD_ALT)) {
  1.1021                  if (pressed) {
  1.1022 -                    switch_vt (this, (keysym.sym - SDLK_F1) + 1);
  1.1023 +                    switch_vt(this, (keysym.sym - SDLK_F1) + 1);
  1.1024                  }
  1.1025                  break;
  1.1026              }
  1.1027              /* Fall through to normal processing */
  1.1028          default:
  1.1029 -            posted += SDL_PrivateKeyboard (pressed, &keysym);
  1.1030 +            posted += SDL_PrivateKeyboard(pressed, &keysym);
  1.1031              break;
  1.1032          }
  1.1033      }
  1.1034  }
  1.1035  
  1.1036  void
  1.1037 -FB_PumpEvents (_THIS)
  1.1038 +FB_PumpEvents(_THIS)
  1.1039  {
  1.1040      fd_set fdset;
  1.1041      int max_fd;
  1.1042 @@ -1079,40 +1076,40 @@
  1.1043          if (switched_away) {
  1.1044              struct vt_stat vtstate;
  1.1045  
  1.1046 -            SDL_mutexP (hw_lock);
  1.1047 -            if ((ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) &&
  1.1048 +            SDL_mutexP(hw_lock);
  1.1049 +            if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) &&
  1.1050                  vtstate.v_active == current_vt) {
  1.1051                  switched_away = 0;
  1.1052 -                switch_vt_done (this);
  1.1053 +                switch_vt_done(this);
  1.1054              }
  1.1055 -            SDL_mutexV (hw_lock);
  1.1056 +            SDL_mutexV(hw_lock);
  1.1057          }
  1.1058  
  1.1059          posted = 0;
  1.1060  
  1.1061 -        FD_ZERO (&fdset);
  1.1062 +        FD_ZERO(&fdset);
  1.1063          max_fd = 0;
  1.1064          if (keyboard_fd >= 0) {
  1.1065 -            FD_SET (keyboard_fd, &fdset);
  1.1066 +            FD_SET(keyboard_fd, &fdset);
  1.1067              if (max_fd < keyboard_fd) {
  1.1068                  max_fd = keyboard_fd;
  1.1069              }
  1.1070          }
  1.1071          if (mouse_fd >= 0) {
  1.1072 -            FD_SET (mouse_fd, &fdset);
  1.1073 +            FD_SET(mouse_fd, &fdset);
  1.1074              if (max_fd < mouse_fd) {
  1.1075                  max_fd = mouse_fd;
  1.1076              }
  1.1077          }
  1.1078 -        if (select (max_fd + 1, &fdset, NULL, NULL, &zero) > 0) {
  1.1079 +        if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) {
  1.1080              if (keyboard_fd >= 0) {
  1.1081 -                if (FD_ISSET (keyboard_fd, &fdset)) {
  1.1082 -                    handle_keyboard (this);
  1.1083 +                if (FD_ISSET(keyboard_fd, &fdset)) {
  1.1084 +                    handle_keyboard(this);
  1.1085                  }
  1.1086              }
  1.1087              if (mouse_fd >= 0) {
  1.1088 -                if (FD_ISSET (mouse_fd, &fdset)) {
  1.1089 -                    handle_mouse (this);
  1.1090 +                if (FD_ISSET(mouse_fd, &fdset)) {
  1.1091 +                    handle_mouse(this);
  1.1092                  }
  1.1093              }
  1.1094          }
  1.1095 @@ -1121,14 +1118,14 @@
  1.1096  }
  1.1097  
  1.1098  void
  1.1099 -FB_InitOSKeymap (_THIS)
  1.1100 +FB_InitOSKeymap(_THIS)
  1.1101  {
  1.1102      int i;
  1.1103  
  1.1104      /* Initialize the Linux key translation table */
  1.1105  
  1.1106      /* First get the ascii keys and others not well handled */
  1.1107 -    for (i = 0; i < SDL_arraysize (keymap); ++i) {
  1.1108 +    for (i = 0; i < SDL_arraysize(keymap); ++i) {
  1.1109          switch (i) {
  1.1110              /* These aren't handled by the x86 kernel keymapping (?) */
  1.1111          case SCANCODE_PRINTSCREEN:
  1.1112 @@ -1169,11 +1166,11 @@
  1.1113              break;
  1.1114              /* this should take care of all standard ascii keys */
  1.1115          default:
  1.1116 -            keymap[i] = KVAL (vga_keymap[0][i]);
  1.1117 +            keymap[i] = KVAL(vga_keymap[0][i]);
  1.1118              break;
  1.1119          }
  1.1120      }
  1.1121 -    for (i = 0; i < SDL_arraysize (keymap); ++i) {
  1.1122 +    for (i = 0; i < SDL_arraysize(keymap); ++i) {
  1.1123          switch (keymap_temp[i]) {
  1.1124          case K_F1:
  1.1125              keymap[i] = SDLK_F1;
  1.1126 @@ -1348,7 +1345,7 @@
  1.1127  }
  1.1128  
  1.1129  static SDL_keysym *
  1.1130 -TranslateKey (int scancode, SDL_keysym * keysym)
  1.1131 +TranslateKey(int scancode, SDL_keysym * keysym)
  1.1132  {
  1.1133      /* Set the keysym information */
  1.1134      keysym->scancode = scancode;
  1.1135 @@ -1361,7 +1358,7 @@
  1.1136          int map;
  1.1137          SDLMod modstate;
  1.1138  
  1.1139 -        modstate = SDL_GetModState ();
  1.1140 +        modstate = SDL_GetModState();
  1.1141          map = 0;
  1.1142          if (modstate & KMOD_SHIFT) {
  1.1143              map |= (1 << KG_SHIFT);
  1.1144 @@ -1375,17 +1372,17 @@
  1.1145          if (modstate & KMOD_RALT) {
  1.1146              map |= (1 << KG_ALTGR);
  1.1147          }
  1.1148 -        if (KTYP (vga_keymap[map][scancode]) == KT_LETTER) {
  1.1149 +        if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) {
  1.1150              if (modstate & KMOD_CAPS) {
  1.1151                  map ^= (1 << KG_SHIFT);
  1.1152              }
  1.1153          }
  1.1154 -        if (KTYP (vga_keymap[map][scancode]) == KT_PAD) {
  1.1155 +        if (KTYP(vga_keymap[map][scancode]) == KT_PAD) {
  1.1156              if (modstate & KMOD_NUM) {
  1.1157 -                keysym->unicode = KVAL (vga_keymap[map][scancode]);
  1.1158 +                keysym->unicode = KVAL(vga_keymap[map][scancode]);
  1.1159              }
  1.1160          } else {
  1.1161 -            keysym->unicode = KVAL (vga_keymap[map][scancode]);
  1.1162 +            keysym->unicode = KVAL(vga_keymap[map][scancode]);
  1.1163          }
  1.1164      }
  1.1165      return (keysym);