src/video/gem/SDL_gemevents.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/gem/SDL_gemevents.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -56,17 +56,17 @@
     1.4  
     1.5  /* Functions prototypes */
     1.6  
     1.7 -static SDL_keysym *TranslateKey (int scancode, int asciicode,
     1.8 -                                 SDL_keysym * keysym, SDL_bool pressed);
     1.9 -static int do_messages (_THIS, short *message);
    1.10 -static void do_keyboard (short kc, short ks);
    1.11 -static void do_mouse (_THIS, short mx, short my, short mb, short ks);
    1.12 +static SDL_keysym *TranslateKey(int scancode, int asciicode,
    1.13 +                                SDL_keysym * keysym, SDL_bool pressed);
    1.14 +static int do_messages(_THIS, short *message);
    1.15 +static void do_keyboard(short kc, short ks);
    1.16 +static void do_mouse(_THIS, short mx, short my, short mb, short ks);
    1.17  
    1.18  /* Functions */
    1.19  
    1.20  static SDL_keysym *
    1.21 -TranslateKey (int scancode, int asciicode, SDL_keysym * keysym,
    1.22 -              SDL_bool pressed)
    1.23 +TranslateKey(int scancode, int asciicode, SDL_keysym * keysym,
    1.24 +             SDL_bool pressed)
    1.25  {
    1.26      /* Set the keysym information */
    1.27      keysym->scancode = scancode;
    1.28 @@ -86,16 +86,16 @@
    1.29  }
    1.30  
    1.31  void
    1.32 -GEM_InitOSKeymap (_THIS)
    1.33 +GEM_InitOSKeymap(_THIS)
    1.34  {
    1.35      int i;
    1.36  
    1.37 -    SDL_memset (gem_currentkeyboard, 0, sizeof (gem_currentkeyboard));
    1.38 -    SDL_memset (gem_previouskeyboard, 0, sizeof (gem_previouskeyboard));
    1.39 -    SDL_memset (gem_currentascii, 0, sizeof (gem_currentascii));
    1.40 +    SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
    1.41 +    SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
    1.42 +    SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii));
    1.43  
    1.44      /* Initialize keymap */
    1.45 -    for (i = 0; i < sizeof (keymap); i++)
    1.46 +    for (i = 0; i < sizeof(keymap); i++)
    1.47          keymap[i] = SDLK_UNKNOWN;
    1.48  
    1.49      /* Functions keys */
    1.50 @@ -129,14 +129,14 @@
    1.51  }
    1.52  
    1.53  void
    1.54 -GEM_PumpEvents (_THIS)
    1.55 +GEM_PumpEvents(_THIS)
    1.56  {
    1.57      short mousex, mousey, mouseb, dummy;
    1.58      short kstate, prevkc, prevks;
    1.59      int i;
    1.60      SDL_keysym keysym;
    1.61  
    1.62 -    SDL_memset (gem_currentkeyboard, 0, sizeof (gem_currentkeyboard));
    1.63 +    SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
    1.64      prevkc = prevks = 0;
    1.65  
    1.66      for (;;) {
    1.67 @@ -148,31 +148,31 @@
    1.68  
    1.69          event_mask = MU_MESAG | MU_TIMER | MU_KEYBD;
    1.70          if (!GEM_fullscreen && (GEM_handle >= 0)) {
    1.71 -            wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.72 +            wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.73              event_mask |= MU_M1;
    1.74 -            if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS)) {
    1.75 +            if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)) {
    1.76                  mouse_event = MO_LEAVE;
    1.77              } else {
    1.78                  mouse_event = MO_ENTER;
    1.79              }
    1.80          }
    1.81  
    1.82 -        resultat = evnt_multi (event_mask,
    1.83 -                               0, 0, 0,
    1.84 -                               mouse_event, x2, y2, w2, h2,
    1.85 -                               0, 0, 0, 0, 0,
    1.86 -                               buffer,
    1.87 -                               10,
    1.88 -                               &dummy, &dummy, &dummy, &kstate, &kc, &dummy);
    1.89 +        resultat = evnt_multi(event_mask,
    1.90 +                              0, 0, 0,
    1.91 +                              mouse_event, x2, y2, w2, h2,
    1.92 +                              0, 0, 0, 0, 0,
    1.93 +                              buffer,
    1.94 +                              10,
    1.95 +                              &dummy, &dummy, &dummy, &kstate, &kc, &dummy);
    1.96  
    1.97          /* Message event ? */
    1.98          if (resultat & MU_MESAG)
    1.99 -            quit = do_messages (this, buffer);
   1.100 +            quit = do_messages(this, buffer);
   1.101  
   1.102          /* Keyboard event ? */
   1.103          if (resultat & MU_KEYBD) {
   1.104              if ((prevkc != kc) || (prevks != kstate)) {
   1.105 -                do_keyboard (kc, kstate);
   1.106 +                do_keyboard(kc, kstate);
   1.107              } else {
   1.108                  /* Avoid looping, if repeating same key */
   1.109                  break;
   1.110 @@ -182,10 +182,10 @@
   1.111          /* Mouse entering/leaving window */
   1.112          if (resultat & MU_M1) {
   1.113              if (this->input_grab == SDL_GRAB_OFF) {
   1.114 -                if (SDL_GetAppState () & SDL_APPMOUSEFOCUS) {
   1.115 -                    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
   1.116 +                if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
   1.117 +                    SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.118                  } else {
   1.119 -                    SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
   1.120 +                    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.121                  }
   1.122              }
   1.123          }
   1.124 @@ -196,46 +196,46 @@
   1.125      }
   1.126  
   1.127      /* Update mouse */
   1.128 -    graf_mkstate (&mousex, &mousey, &mouseb, &kstate);
   1.129 -    do_mouse (this, mousex, mousey, mouseb, kstate);
   1.130 +    graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
   1.131 +    do_mouse(this, mousex, mousey, mouseb, kstate);
   1.132  
   1.133      /* Now generate keyboard events */
   1.134      for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
   1.135          /* Key pressed ? */
   1.136          if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
   1.137 -            SDL_PrivateKeyboard (SDL_PRESSED,
   1.138 -                                 TranslateKey (i, gem_currentascii[i],
   1.139 -                                               &keysym, SDL_TRUE));
   1.140 +            SDL_PrivateKeyboard(SDL_PRESSED,
   1.141 +                                TranslateKey(i, gem_currentascii[i],
   1.142 +                                             &keysym, SDL_TRUE));
   1.143  
   1.144          /* Key unpressed ? */
   1.145          if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
   1.146 -            SDL_PrivateKeyboard (SDL_RELEASED,
   1.147 -                                 TranslateKey (i, gem_currentascii[i],
   1.148 -                                               &keysym, SDL_FALSE));
   1.149 +            SDL_PrivateKeyboard(SDL_RELEASED,
   1.150 +                                TranslateKey(i, gem_currentascii[i],
   1.151 +                                             &keysym, SDL_FALSE));
   1.152      }
   1.153  
   1.154 -    SDL_memcpy (gem_previouskeyboard, gem_currentkeyboard,
   1.155 -                sizeof (gem_previouskeyboard));
   1.156 +    SDL_memcpy(gem_previouskeyboard, gem_currentkeyboard,
   1.157 +               sizeof(gem_previouskeyboard));
   1.158  
   1.159      /* Refresh window name ? */
   1.160      if (GEM_refresh_name) {
   1.161 -        if (SDL_GetAppState () & SDL_APPACTIVE) {
   1.162 +        if (SDL_GetAppState() & SDL_APPACTIVE) {
   1.163              /* Fullscreen/windowed */
   1.164              if (GEM_title_name) {
   1.165 -                wind_set (GEM_handle, WF_NAME,
   1.166 -                          (short) (((unsigned long) GEM_title_name) >>
   1.167 -                                   16),
   1.168 -                          (short) (((unsigned long) GEM_title_name) &
   1.169 -                                   0xffff), 0, 0);
   1.170 +                wind_set(GEM_handle, WF_NAME,
   1.171 +                         (short) (((unsigned long) GEM_title_name) >>
   1.172 +                                  16),
   1.173 +                         (short) (((unsigned long) GEM_title_name) &
   1.174 +                                  0xffff), 0, 0);
   1.175              }
   1.176          } else {
   1.177              /* Iconified */
   1.178              if (GEM_icon_name) {
   1.179 -                wind_set (GEM_handle, WF_NAME,
   1.180 -                          (short) (((unsigned long) GEM_icon_name) >>
   1.181 -                                   16),
   1.182 -                          (short) (((unsigned long) GEM_icon_name) &
   1.183 -                                   0xffff), 0, 0);
   1.184 +                wind_set(GEM_handle, WF_NAME,
   1.185 +                         (short) (((unsigned long) GEM_icon_name) >>
   1.186 +                                  16),
   1.187 +                         (short) (((unsigned long) GEM_icon_name) &
   1.188 +                                  0xffff), 0, 0);
   1.189              }
   1.190          }
   1.191          GEM_refresh_name = SDL_FALSE;
   1.192 @@ -243,7 +243,7 @@
   1.193  }
   1.194  
   1.195  static int
   1.196 -do_messages (_THIS, short *message)
   1.197 +do_messages(_THIS, short *message)
   1.198  {
   1.199      int quit, posted;
   1.200      short x2, y2, w2, h2;
   1.201 @@ -252,75 +252,75 @@
   1.202      switch (message[0]) {
   1.203      case WM_CLOSED:
   1.204      case AP_TERM:
   1.205 -        posted = SDL_PrivateQuit ();
   1.206 +        posted = SDL_PrivateQuit();
   1.207          quit = 1;
   1.208          break;
   1.209      case WM_MOVED:
   1.210 -        wind_set (message[3], WF_CURRXYWH, message[4], message[5],
   1.211 -                  message[6], message[7]);
   1.212 +        wind_set(message[3], WF_CURRXYWH, message[4], message[5],
   1.213 +                 message[6], message[7]);
   1.214          break;
   1.215      case WM_TOPPED:
   1.216 -        wind_set (message[3], WF_TOP, message[4], 0, 0, 0);
   1.217 +        wind_set(message[3], WF_TOP, message[4], 0, 0, 0);
   1.218          /* Continue with TOP event processing */
   1.219      case WM_ONTOP:
   1.220 -        SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
   1.221 +        SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   1.222          if (VDI_setpalette) {
   1.223 -            VDI_setpalette (this, VDI_curpalette);
   1.224 +            VDI_setpalette(this, VDI_curpalette);
   1.225          }
   1.226          break;
   1.227      case WM_REDRAW:
   1.228          if (!GEM_lock_redraw) {
   1.229 -            GEM_wind_redraw (this, message[3], &message[4]);
   1.230 +            GEM_wind_redraw(this, message[3], &message[4]);
   1.231          }
   1.232          break;
   1.233      case WM_ICONIFY:
   1.234      case WM_ALLICONIFY:
   1.235 -        wind_set (message[3], WF_ICONIFY, message[4], message[5],
   1.236 -                  message[6], message[7]);
   1.237 +        wind_set(message[3], WF_ICONIFY, message[4], message[5],
   1.238 +                 message[6], message[7]);
   1.239          /* If we're active, make ourselves inactive */
   1.240 -        if (SDL_GetAppState () & SDL_APPACTIVE) {
   1.241 +        if (SDL_GetAppState() & SDL_APPACTIVE) {
   1.242              /* Send an internal deactivate event */
   1.243 -            SDL_PrivateAppActive (0, SDL_APPACTIVE);
   1.244 +            SDL_PrivateAppActive(0, SDL_APPACTIVE);
   1.245          }
   1.246          /* Update window title */
   1.247          if (GEM_refresh_name && GEM_icon_name) {
   1.248 -            wind_set (GEM_handle, WF_NAME,
   1.249 -                      (short) (((unsigned long) GEM_icon_name) >> 16),
   1.250 -                      (short) (((unsigned long) GEM_icon_name) & 0xffff),
   1.251 -                      0, 0);
   1.252 +            wind_set(GEM_handle, WF_NAME,
   1.253 +                     (short) (((unsigned long) GEM_icon_name) >> 16),
   1.254 +                     (short) (((unsigned long) GEM_icon_name) & 0xffff),
   1.255 +                     0, 0);
   1.256              GEM_refresh_name = SDL_FALSE;
   1.257          }
   1.258          break;
   1.259      case WM_UNICONIFY:
   1.260 -        wind_set (message[3], WF_UNICONIFY, message[4], message[5],
   1.261 -                  message[6], message[7]);
   1.262 +        wind_set(message[3], WF_UNICONIFY, message[4], message[5],
   1.263 +                 message[6], message[7]);
   1.264          /* If we're not active, make ourselves active */
   1.265 -        if (!(SDL_GetAppState () & SDL_APPACTIVE)) {
   1.266 +        if (!(SDL_GetAppState() & SDL_APPACTIVE)) {
   1.267              /* Send an internal activate event */
   1.268 -            SDL_PrivateAppActive (1, SDL_APPACTIVE);
   1.269 +            SDL_PrivateAppActive(1, SDL_APPACTIVE);
   1.270          }
   1.271          if (GEM_refresh_name && GEM_title_name) {
   1.272 -            wind_set (GEM_handle, WF_NAME,
   1.273 -                      (short) (((unsigned long) GEM_title_name) >> 16),
   1.274 -                      (short) (((unsigned long) GEM_title_name) & 0xffff),
   1.275 -                      0, 0);
   1.276 +            wind_set(GEM_handle, WF_NAME,
   1.277 +                     (short) (((unsigned long) GEM_title_name) >> 16),
   1.278 +                     (short) (((unsigned long) GEM_title_name) & 0xffff),
   1.279 +                     0, 0);
   1.280              GEM_refresh_name = SDL_FALSE;
   1.281          }
   1.282          break;
   1.283      case WM_SIZED:
   1.284 -        wind_set (message[3], WF_CURRXYWH, message[4], message[5],
   1.285 -                  message[6], message[7]);
   1.286 -        wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.287 +        wind_set(message[3], WF_CURRXYWH, message[4], message[5],
   1.288 +                 message[6], message[7]);
   1.289 +        wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.290          GEM_win_fulled = SDL_FALSE;     /* Cancel maximized flag */
   1.291          GEM_lock_redraw = SDL_TRUE;     /* Prevent redraw till buffers resized */
   1.292 -        SDL_PrivateResize (w2, h2);
   1.293 +        SDL_PrivateResize(w2, h2);
   1.294          break;
   1.295      case WM_FULLED:
   1.296          {
   1.297              short x, y, w, h;
   1.298  
   1.299              if (GEM_win_fulled) {
   1.300 -                wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h);
   1.301 +                wind_get(message[3], WF_PREVXYWH, &x, &y, &w, &h);
   1.302                  GEM_win_fulled = SDL_FALSE;
   1.303              } else {
   1.304                  x = GEM_desk_x;
   1.305 @@ -329,19 +329,19 @@
   1.306                  h = GEM_desk_h;
   1.307                  GEM_win_fulled = SDL_TRUE;
   1.308              }
   1.309 -            wind_set (message[3], WF_CURRXYWH, x, y, w, h);
   1.310 -            wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.311 +            wind_set(message[3], WF_CURRXYWH, x, y, w, h);
   1.312 +            wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.313              GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */
   1.314 -            SDL_PrivateResize (w2, h2);
   1.315 +            SDL_PrivateResize(w2, h2);
   1.316          }
   1.317          break;
   1.318      case WM_BOTTOMED:
   1.319 -        wind_set (message[3], WF_BOTTOM, 0, 0, 0, 0);
   1.320 +        wind_set(message[3], WF_BOTTOM, 0, 0, 0, 0);
   1.321          /* Continue with BOTTOM event processing */
   1.322      case WM_UNTOPPED:
   1.323 -        SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
   1.324 +        SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
   1.325          if (VDI_setpalette) {
   1.326 -            VDI_setpalette (this, VDI_oldpalette);
   1.327 +            VDI_setpalette(this, VDI_oldpalette);
   1.328          }
   1.329          break;
   1.330      }
   1.331 @@ -350,7 +350,7 @@
   1.332  }
   1.333  
   1.334  static void
   1.335 -do_keyboard (short kc, short ks)
   1.336 +do_keyboard(short kc, short ks)
   1.337  {
   1.338      int scancode, asciicode;
   1.339  
   1.340 @@ -374,13 +374,13 @@
   1.341  }
   1.342  
   1.343  static void
   1.344 -do_mouse (_THIS, short mx, short my, short mb, short ks)
   1.345 +do_mouse(_THIS, short mx, short my, short mb, short ks)
   1.346  {
   1.347      static short prevmousex = 0, prevmousey = 0, prevmouseb = 0;
   1.348      short x2, y2, w2, h2;
   1.349  
   1.350      /* Don't return mouse events if out of window */
   1.351 -    if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS) == 0) {
   1.352 +    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) {
   1.353          return;
   1.354      }
   1.355  
   1.356 @@ -389,7 +389,7 @@
   1.357      w2 = VDI_w;
   1.358      h2 = VDI_h;
   1.359      if ((!GEM_fullscreen) && (GEM_handle >= 0)) {
   1.360 -        wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.361 +        wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
   1.362  
   1.363          /* Do not generate mouse button event if out of window working area */
   1.364          if ((mx < x2) || (mx >= x2 + w2) || (my < y2) || (my >= y2 + h2)) {
   1.365 @@ -400,9 +400,9 @@
   1.366      /* Mouse motion ? */
   1.367      if (GEM_mouse_relative) {
   1.368          if (GEM_usedevmouse) {
   1.369 -            SDL_AtariDevMouse_PostMouseEvents (this, SDL_FALSE);
   1.370 +            SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE);
   1.371          } else {
   1.372 -            SDL_AtariXbios_PostMouseEvents (this, SDL_FALSE);
   1.373 +            SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE);
   1.374          }
   1.375      } else {
   1.376          if ((prevmousex != mx) || (prevmousey != my)) {
   1.377 @@ -420,7 +420,7 @@
   1.378              if (posy > h2)
   1.379                  posy = h2 - 1;
   1.380  
   1.381 -            SDL_PrivateMouseMotion (0, 0, posx, posy);
   1.382 +            SDL_PrivateMouseMotion(0, 0, posx, posy);
   1.383          }
   1.384          prevmousex = mx;
   1.385          prevmousey = my;
   1.386 @@ -437,10 +437,10 @@
   1.387              prevbutton = prevmouseb & (1 << i);
   1.388  
   1.389              if (curbutton && !prevbutton) {
   1.390 -                SDL_PrivateMouseButton (SDL_PRESSED, i + 1, 0, 0);
   1.391 +                SDL_PrivateMouseButton(SDL_PRESSED, i + 1, 0, 0);
   1.392              }
   1.393              if (!curbutton && prevbutton) {
   1.394 -                SDL_PrivateMouseButton (SDL_RELEASED, i + 1, 0, 0);
   1.395 +                SDL_PrivateMouseButton(SDL_RELEASED, i + 1, 0, 0);
   1.396              }
   1.397          }
   1.398          prevmouseb = mb;