src/video/cybergfx/SDL_amigaevents.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/cybergfx/SDL_amigaevents.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/cybergfx/SDL_amigaevents.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -37,7 +37,7 @@
     1.4  
     1.5  /* The translation tables from an Amiga keysym to a SDL keysym */
     1.6  static SDLKey MISC_keymap[256];
     1.7 -SDL_keysym *amiga_TranslateKey (int code, SDL_keysym * keysym);
     1.8 +SDL_keysym *amiga_TranslateKey(int code, SDL_keysym * keysym);
     1.9  struct IOStdReq *ConReq = NULL;
    1.10  struct MsgPort *ConPort = NULL;
    1.11  
    1.12 @@ -51,7 +51,7 @@
    1.13  #if 0
    1.14  
    1.15  static inline int
    1.16 -amiga_WarpedMotion (_THIS, struct IntuiMessage *m)
    1.17 +amiga_WarpedMotion(_THIS, struct IntuiMessage *m)
    1.18  {
    1.19      int w, h, i;
    1.20      int deltax, deltay;
    1.21 @@ -62,33 +62,33 @@
    1.22      deltax = xevent->xmotion.x - mouse_last.x;
    1.23      deltay = xevent->xmotion.y - mouse_last.y;
    1.24  #ifdef DEBUG_MOTION
    1.25 -    printf ("Warped mouse motion: %d,%d\n", deltax, deltay);
    1.26 +    printf("Warped mouse motion: %d,%d\n", deltax, deltay);
    1.27  #endif
    1.28      mouse_last.x = xevent->xmotion.x;
    1.29      mouse_last.y = xevent->xmotion.y;
    1.30 -    posted = SDL_PrivateMouseMotion (0, 1, deltax, deltay);
    1.31 +    posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    1.32  
    1.33      if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
    1.34          (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) ||
    1.35          (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
    1.36          (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) {
    1.37          /* Get the events that have accumulated */
    1.38 -        while (XCheckTypedEvent (SDL_Display, MotionNotify, xevent)) {
    1.39 +        while (XCheckTypedEvent(SDL_Display, MotionNotify, xevent)) {
    1.40              deltax = xevent->xmotion.x - mouse_last.x;
    1.41              deltay = xevent->xmotion.y - mouse_last.y;
    1.42  #ifdef DEBUG_MOTION
    1.43 -            printf ("Extra mouse motion: %d,%d\n", deltax, deltay);
    1.44 +            printf("Extra mouse motion: %d,%d\n", deltax, deltay);
    1.45  #endif
    1.46              mouse_last.x = xevent->xmotion.x;
    1.47              mouse_last.y = xevent->xmotion.y;
    1.48 -            posted += SDL_PrivateMouseMotion (0, 1, deltax, deltay);
    1.49 +            posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    1.50          }
    1.51          mouse_last.x = w / 2;
    1.52          mouse_last.y = h / 2;
    1.53 -        XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0,
    1.54 -                      mouse_last.x, mouse_last.y);
    1.55 +        XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
    1.56 +                     mouse_last.x, mouse_last.y);
    1.57          for (i = 0; i < 10; ++i) {
    1.58 -            XMaskEvent (SDL_Display, PointerMotionMask, xevent);
    1.59 +            XMaskEvent(SDL_Display, PointerMotionMask, xevent);
    1.60              if ((xevent->xmotion.x >
    1.61                   (mouse_last.x - MOUSE_FUDGE_FACTOR)) &&
    1.62                  (xevent->xmotion.x <
    1.63 @@ -99,13 +99,13 @@
    1.64                  break;
    1.65              }
    1.66  #ifdef DEBUG_XEVENTS
    1.67 -            printf ("Lost mouse motion: %d,%d\n", xevent->xmotion.x,
    1.68 -                    xevent->xmotion.y);
    1.69 +            printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x,
    1.70 +                   xevent->xmotion.y);
    1.71  #endif
    1.72          }
    1.73  #ifdef DEBUG_XEVENTS
    1.74          if (i == 10) {
    1.75 -            printf ("Warning: didn't detect mouse warp motion\n");
    1.76 +            printf("Warning: didn't detect mouse warp motion\n");
    1.77          }
    1.78  #endif
    1.79      }
    1.80 @@ -115,7 +115,7 @@
    1.81  #endif
    1.82  
    1.83  static int
    1.84 -amiga_GetButton (int code)
    1.85 +amiga_GetButton(int code)
    1.86  {
    1.87      switch (code) {
    1.88      case IECODE_MBUTTON:
    1.89 @@ -128,7 +128,7 @@
    1.90  }
    1.91  
    1.92  static int
    1.93 -amiga_DispatchEvent (_THIS, struct IntuiMessage *msg)
    1.94 +amiga_DispatchEvent(_THIS, struct IntuiMessage *msg)
    1.95  {
    1.96      int class = msg->Class, code = msg->Code;
    1.97      int posted;
    1.98 @@ -137,40 +137,40 @@
    1.99      switch (class) {
   1.100          /* Gaining mouse coverage? */
   1.101      case IDCMP_ACTIVEWINDOW:
   1.102 -        posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
   1.103 +        posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.104          break;
   1.105  
   1.106          /* Losing mouse coverage? */
   1.107      case IDCMP_INACTIVEWINDOW:
   1.108 -        posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
   1.109 +        posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.110          break;
   1.111  #if 0
   1.112          /* Gaining input focus? */
   1.113      case IDCMP_ACTIVEWINDOW:
   1.114 -        posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
   1.115 +        posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   1.116  
   1.117          /* Queue entry into fullscreen mode */
   1.118          switch_waiting = 0x01 | SDL_FULLSCREEN;
   1.119 -        switch_time = SDL_GetTicks () + 1500;
   1.120 +        switch_time = SDL_GetTicks() + 1500;
   1.121          break;
   1.122  
   1.123          /* Losing input focus? */
   1.124      case IDCMP_INACTIVEWINDOW:
   1.125 -        posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
   1.126 +        posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
   1.127  
   1.128          /* Queue leaving fullscreen mode */
   1.129          switch_waiting = 0x01;
   1.130 -        switch_time = SDL_GetTicks () + 200;
   1.131 +        switch_time = SDL_GetTicks() + 200;
   1.132          break;
   1.133  #endif
   1.134          /* Mouse motion? */
   1.135      case IDCMP_MOUSEMOVE:
   1.136          if (SDL_VideoSurface) {
   1.137 -            posted = SDL_PrivateMouseMotion (0, 0,
   1.138 -                                             msg->MouseX -
   1.139 -                                             SDL_Window->BorderLeft,
   1.140 -                                             msg->MouseY -
   1.141 -                                             SDL_Window->BorderTop);
   1.142 +            posted = SDL_PrivateMouseMotion(0, 0,
   1.143 +                                            msg->MouseX -
   1.144 +                                            SDL_Window->BorderLeft,
   1.145 +                                            msg->MouseY -
   1.146 +                                            SDL_Window->BorderTop);
   1.147          }
   1.148          break;
   1.149  
   1.150 @@ -178,14 +178,14 @@
   1.151      case IDCMP_MOUSEBUTTONS:
   1.152  
   1.153          if (!(code & IECODE_UP_PREFIX)) {
   1.154 -            posted = SDL_PrivateMouseButton (SDL_PRESSED,
   1.155 -                                             amiga_GetButton (code), 0, 0);
   1.156 +            posted = SDL_PrivateMouseButton(SDL_PRESSED,
   1.157 +                                            amiga_GetButton(code), 0, 0);
   1.158          }
   1.159          /* Mouse button release? */
   1.160          else {
   1.161              code &= ~IECODE_UP_PREFIX;
   1.162 -            posted = SDL_PrivateMouseButton (SDL_RELEASED,
   1.163 -                                             amiga_GetButton (code), 0, 0);
   1.164 +            posted = SDL_PrivateMouseButton(SDL_RELEASED,
   1.165 +                                            amiga_GetButton(code), 0, 0);
   1.166          }
   1.167          break;
   1.168  
   1.169 @@ -195,8 +195,8 @@
   1.170  
   1.171          if (!(code & IECODE_UP_PREFIX)) {
   1.172              SDL_keysym keysym;
   1.173 -            posted = SDL_PrivateKeyboard (SDL_PRESSED,
   1.174 -                                          amiga_TranslateKey (code, &keysym));
   1.175 +            posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.176 +                                         amiga_TranslateKey(code, &keysym));
   1.177          } else {
   1.178              /* Key release? */
   1.179  
   1.180 @@ -206,8 +206,8 @@
   1.181              /* Check to see if this is a repeated key */
   1.182  /*			if ( ! X11_KeyRepeat(SDL_Display, &xevent) )  */
   1.183  
   1.184 -            posted = SDL_PrivateKeyboard (SDL_RELEASED,
   1.185 -                                          amiga_TranslateKey (code, &keysym));
   1.186 +            posted = SDL_PrivateKeyboard(SDL_RELEASED,
   1.187 +                                         amiga_TranslateKey(code, &keysym));
   1.188          }
   1.189          break;
   1.190          /* Have we been iconified? */
   1.191 @@ -215,10 +215,10 @@
   1.192      case UnmapNotify:
   1.193          {
   1.194  #ifdef DEBUG_XEVENTS
   1.195 -            printf ("UnmapNotify!\n");
   1.196 +            printf("UnmapNotify!\n");
   1.197  #endif
   1.198              posted =
   1.199 -                SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS);
   1.200 +                SDL_PrivateAppActive(0, SDL_APPACTIVE | SDL_APPINPUTFOCUS);
   1.201          }
   1.202          break;
   1.203  
   1.204 @@ -227,41 +227,41 @@
   1.205      case MapNotify:
   1.206          {
   1.207  #ifdef DEBUG_XEVENTS
   1.208 -            printf ("MapNotify!\n");
   1.209 +            printf("MapNotify!\n");
   1.210  #endif
   1.211  
   1.212 -            posted = SDL_PrivateAppActive (1, SDL_APPACTIVE);
   1.213 +            posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
   1.214  
   1.215              if (SDL_VideoSurface &&
   1.216                  (SDL_VideoSurface->flags & SDL_FULLSCREEN)) {
   1.217 -                CGX_EnterFullScreen (this);
   1.218 +                CGX_EnterFullScreen(this);
   1.219              } else {
   1.220 -                X11_GrabInputNoLock (this, this->input_grab);
   1.221 +                X11_GrabInputNoLock(this, this->input_grab);
   1.222              }
   1.223              if (SDL_VideoSurface) {
   1.224 -                CGX_RefreshDisplay (this);
   1.225 +                CGX_RefreshDisplay(this);
   1.226              }
   1.227          }
   1.228          break;
   1.229      case Expose:
   1.230          if (SDL_VideoSurface && (xevent.xexpose.count == 0)) {
   1.231 -            CGX_RefreshDisplay (this);
   1.232 +            CGX_RefreshDisplay(this);
   1.233          }
   1.234          break;
   1.235  #endif
   1.236  
   1.237          /* Have we been resized? */
   1.238      case IDCMP_NEWSIZE:
   1.239 -        SDL_PrivateResize (SDL_Window->Width - SDL_Window->BorderLeft -
   1.240 -                           SDL_Window->BorderRight,
   1.241 -                           SDL_Window->Height - SDL_Window->BorderTop -
   1.242 -                           SDL_Window->BorderBottom);
   1.243 +        SDL_PrivateResize(SDL_Window->Width - SDL_Window->BorderLeft -
   1.244 +                          SDL_Window->BorderRight,
   1.245 +                          SDL_Window->Height - SDL_Window->BorderTop -
   1.246 +                          SDL_Window->BorderBottom);
   1.247  
   1.248          break;
   1.249  
   1.250          /* Have we been requested to quit? */
   1.251      case IDCMP_CLOSEWINDOW:
   1.252 -        posted = SDL_PrivateQuit ();
   1.253 +        posted = SDL_PrivateQuit();
   1.254          break;
   1.255  
   1.256          /* Do we need to refresh ourselves? */
   1.257 @@ -272,43 +272,43 @@
   1.258              if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.259                  SDL_SysWMmsg wmmsg;
   1.260  
   1.261 -                SDL_VERSION (&wmmsg.version);
   1.262 +                SDL_VERSION(&wmmsg.version);
   1.263  #if 0
   1.264                  wmmsg.subsystem = SDL_SYSWM_CGX;
   1.265                  wmmsg.event.xevent = xevent;
   1.266  #endif
   1.267 -                posted = SDL_PrivateSysWMEvent (&wmmsg);
   1.268 +                posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.269              }
   1.270          }
   1.271          break;
   1.272      }
   1.273 -    ReplyMsg ((struct Message *) msg);
   1.274 +    ReplyMsg((struct Message *) msg);
   1.275  
   1.276  
   1.277      return (posted);
   1.278  }
   1.279  
   1.280  void
   1.281 -amiga_PumpEvents (_THIS)
   1.282 +amiga_PumpEvents(_THIS)
   1.283  {
   1.284      int pending;
   1.285      struct IntuiMessage *m;
   1.286  
   1.287      /* Keep processing pending events */
   1.288      pending = 0;
   1.289 -    while (m = (struct IntuiMessage *) GetMsg (SDL_Window->UserPort)) {
   1.290 -        amiga_DispatchEvent (this, m);
   1.291 +    while (m = (struct IntuiMessage *) GetMsg(SDL_Window->UserPort)) {
   1.292 +        amiga_DispatchEvent(this, m);
   1.293          ++pending;
   1.294      }
   1.295  }
   1.296  
   1.297  void
   1.298 -amiga_InitKeymap (void)
   1.299 +amiga_InitKeymap(void)
   1.300  {
   1.301      int i;
   1.302  
   1.303      /* Map the miscellaneous keys */
   1.304 -    for (i = 0; i < SDL_arraysize (MISC_keymap); ++i)
   1.305 +    for (i = 0; i < SDL_arraysize(MISC_keymap); ++i)
   1.306          MISC_keymap[i] = SDLK_UNKNOWN;
   1.307  
   1.308      /* These X keysyms have 0xFF as the high byte */
   1.309 @@ -430,7 +430,7 @@
   1.310  }
   1.311  
   1.312  SDL_keysym *
   1.313 -amiga_TranslateKey (int code, SDL_keysym * keysym)
   1.314 +amiga_TranslateKey(int code, SDL_keysym * keysym)
   1.315  {
   1.316  #ifdef STORMC4_WOS
   1.317      static struct Library *KeymapBase = NULL;   /* Linking failed in WOS version if ConsoleDevice was used */
   1.318 @@ -443,7 +443,7 @@
   1.319      keysym->sym = MISC_keymap[code];
   1.320  
   1.321  #ifdef DEBUG_KEYS
   1.322 -    fprintf (stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode);
   1.323 +    fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode);
   1.324  #endif
   1.325      /* Get the translated SDL virtual keysym */
   1.326      if (keysym->sym == SDLK_UNKNOWN) {
   1.327 @@ -454,21 +454,21 @@
   1.328  #endif
   1.329          {
   1.330  #ifdef STORMC4_WOS
   1.331 -            KeymapBase = OpenLibrary ("keymap.library", 0L);
   1.332 +            KeymapBase = OpenLibrary("keymap.library", 0L);
   1.333  #else
   1.334 -            if (ConPort = CreateMsgPort ()) {
   1.335 +            if (ConPort = CreateMsgPort()) {
   1.336                  if (ConReq =
   1.337 -                    CreateIORequest (ConPort, sizeof (struct IOStdReq))) {
   1.338 +                    CreateIORequest(ConPort, sizeof(struct IOStdReq))) {
   1.339                      if (!OpenDevice
   1.340                          ("console.device", -1,
   1.341                           (struct IORequest *) ConReq, 0))
   1.342                          ConsoleDevice = (struct Library *) ConReq->io_Device;
   1.343                      else {
   1.344 -                        DeleteIORequest (ConReq);
   1.345 +                        DeleteIORequest(ConReq);
   1.346                          ConReq = NULL;
   1.347                      }
   1.348                  } else {
   1.349 -                    DeleteMsgPort (ConPort);
   1.350 +                    DeleteMsgPort(ConPort);
   1.351                      ConPort = NULL;
   1.352                  }
   1.353              }
   1.354 @@ -495,17 +495,16 @@
   1.355                  event.ie_Prev2DownCode = event.ie_Prev2DownQual = 0;
   1.356  
   1.357  #ifdef STORMC4_WOS
   1.358 -            if ((actual = MapRawKey (&event, buffer, 5, NULL)) >= 0)
   1.359 +            if ((actual = MapRawKey(&event, buffer, 5, NULL)) >= 0)
   1.360  #else
   1.361 -            if ((actual = RawKeyConvert (&event, buffer, 5, NULL)) >= 0)
   1.362 +            if ((actual = RawKeyConvert(&event, buffer, 5, NULL)) >= 0)
   1.363  #endif
   1.364              {
   1.365                  if (actual > 1) {
   1.366 -                    D (bug ("Warning (%ld) character conversion!\n", actual));
   1.367 +                    D(bug("Warning (%ld) character conversion!\n", actual));
   1.368                  } else if (actual == 1) {
   1.369                      keysym->sym = *buffer;
   1.370 -                    D (bug
   1.371 -                       ("Converted rawcode %ld to <%lc>\n", code, *buffer));
   1.372 +                    D(bug("Converted rawcode %ld to <%lc>\n", code, *buffer));
   1.373  // Bufferizzo x le successive chiamate!
   1.374                      MISC_keymap[code] = *buffer;
   1.375                  }
   1.376 @@ -522,8 +521,8 @@
   1.377          static XComposeStatus state;
   1.378          /* Until we handle the IM protocol, use XLookupString() */
   1.379          unsigned char keybuf[32];
   1.380 -        if (XLookupString (xkey, (char *) keybuf, sizeof (keybuf),
   1.381 -                           NULL, &state)) {
   1.382 +        if (XLookupString(xkey, (char *) keybuf, sizeof(keybuf),
   1.383 +                          NULL, &state)) {
   1.384              keysym->unicode = keybuf[0];
   1.385          }
   1.386  #endif
   1.387 @@ -532,9 +531,9 @@
   1.388  }
   1.389  
   1.390  void
   1.391 -amiga_InitOSKeymap (_THIS)
   1.392 +amiga_InitOSKeymap(_THIS)
   1.393  {
   1.394 -    amiga_InitKeymap ();
   1.395 +    amiga_InitKeymap();
   1.396  }
   1.397  
   1.398  /* vi: set ts=4 sw=4 expandtab: */