src/video/photon/SDL_ph_events.c
changeset 1895 c121d94672cb
parent 1643 51038e80ae59
child 2859 99210400e8b9
     1.1 --- a/src/video/photon/SDL_ph_events.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/src/video/photon/SDL_ph_events.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -44,13 +44,14 @@
     1.4  /* The translation tables from a photon keysym to a SDL keysym */
     1.5  static SDLKey ODD_keymap[256];
     1.6  static SDLKey MISC_keymap[0xFF + 1];
     1.7 -SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym);
     1.8 +SDL_keysym *ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym);
     1.9  
    1.10  /* Check to see if this is a repeated key.
    1.11     (idea shamelessly lifted from GII -- thanks guys! :) */
    1.12 -static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
    1.13 +static int
    1.14 +ph_WarpedMotion(_THIS, PhEvent_t * winEvent)
    1.15  {
    1.16 -    PhRect_t *rect = PhGetRects( winEvent );
    1.17 +    PhRect_t *rect = PhGetRects(winEvent);
    1.18  
    1.19      int centre_x, centre_y;
    1.20      int dx, dy;
    1.21 @@ -63,10 +64,10 @@
    1.22      dx = rect->ul.x - centre_x;
    1.23      dy = rect->ul.y - centre_y;
    1.24  
    1.25 -    posted = SDL_PrivateMouseMotion( 0, 1, dx, dy );
    1.26 +    posted = SDL_PrivateMouseMotion(0, 1, dx, dy);
    1.27  
    1.28      /* Move mouse cursor to middle of the window */
    1.29 -    PtGetAbsPosition( window, &abs_x, &abs_y );
    1.30 +    PtGetAbsPosition(window, &abs_x, &abs_y);
    1.31      PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y);
    1.32  
    1.33      return (posted);
    1.34 @@ -75,25 +76,26 @@
    1.35  /* Control which motion flags the window has set, a flags value of -1 sets
    1.36   * MOTION_BUTTON and MOTION_NOBUTTON */
    1.37  
    1.38 -static void set_motion_sensitivity(_THIS, unsigned int flags)
    1.39 +static void
    1.40 +set_motion_sensitivity(_THIS, unsigned int flags)
    1.41  {
    1.42      int rid;
    1.43      int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
    1.44      PhRegion_t region;
    1.45  
    1.46 -    if( window )
    1.47 -    {
    1.48 +    if (window) {
    1.49          rid = PtWidgetRid(window);
    1.50 -        if( rid != 0 && PhRegionQuery(rid, &region, NULL, NULL, 0) == 0 )
    1.51 -        {
    1.52 -            region.events_sense=(region.events_sense & ~fields)|(flags & fields);
    1.53 +        if (rid != 0 && PhRegionQuery(rid, &region, NULL, NULL, 0) == 0) {
    1.54 +            region.events_sense =
    1.55 +                (region.events_sense & ~fields) | (flags & fields);
    1.56              PhRegionChange(Ph_REGION_EV_SENSE, 0, &region, NULL, NULL);
    1.57          }
    1.58      }
    1.59  }
    1.60  
    1.61  /* Convert the photon button state value to an SDL value */
    1.62 -static Uint8 ph2sdl_mousebutton(unsigned short button_state)
    1.63 +static Uint8
    1.64 +ph2sdl_mousebutton(unsigned short button_state)
    1.65  {
    1.66      Uint8 mouse_button = 0;
    1.67  
    1.68 @@ -107,197 +109,174 @@
    1.69      return (mouse_button);
    1.70  }
    1.71  
    1.72 -static int ph_DispatchEvent(_THIS)
    1.73 +static int
    1.74 +ph_DispatchEvent(_THIS)
    1.75  {
    1.76      int posted;
    1.77 -    PhRect_t* rect;
    1.78 -    PhPointerEvent_t* pointerEvent;
    1.79 -    PhKeyEvent_t* keyEvent;
    1.80 -    PhWindowEvent_t* winEvent;
    1.81 +    PhRect_t *rect;
    1.82 +    PhPointerEvent_t *pointerEvent;
    1.83 +    PhKeyEvent_t *keyEvent;
    1.84 +    PhWindowEvent_t *winEvent;
    1.85      int i, buttons;
    1.86      SDL_Rect sdlrects[PH_SDL_MAX_RECTS];
    1.87 -	
    1.88 +
    1.89      posted = 0;
    1.90 -	
    1.91 -    switch (phevent->type)
    1.92 -    {
    1.93 -        case Ph_EV_BOUNDARY:
    1.94 +
    1.95 +    switch (phevent->type) {
    1.96 +    case Ph_EV_BOUNDARY:
    1.97          {
    1.98 -            if (phevent->subtype == Ph_EV_PTR_ENTER)
    1.99 -            {
   1.100 +            if (phevent->subtype == Ph_EV_PTR_ENTER) {
   1.101                  posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   1.102 -            }
   1.103 -            else if (phevent->subtype ==Ph_EV_PTR_LEAVE)
   1.104 -            {
   1.105 -                posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
   1.106 +            } else if (phevent->subtype == Ph_EV_PTR_LEAVE) {
   1.107 +                posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
   1.108              }
   1.109          }
   1.110          break;
   1.111  
   1.112 -        case Ph_EV_PTR_MOTION_BUTTON:
   1.113 -        case Ph_EV_PTR_MOTION_NOBUTTON:
   1.114 +    case Ph_EV_PTR_MOTION_BUTTON:
   1.115 +    case Ph_EV_PTR_MOTION_NOBUTTON:
   1.116          {
   1.117 -            if (SDL_VideoSurface)
   1.118 -            {
   1.119 +            if (SDL_VideoSurface) {
   1.120                  pointerEvent = PhGetData(phevent);
   1.121                  rect = PhGetRects(phevent);
   1.122  
   1.123 -                if (mouse_relative)
   1.124 -                {
   1.125 +                if (mouse_relative) {
   1.126                      posted = ph_WarpedMotion(this, phevent);
   1.127 -                }
   1.128 -                else
   1.129 -                {
   1.130 -                    posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   1.131 +                } else {
   1.132 +                    posted =
   1.133 +                        SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   1.134                  }
   1.135              }
   1.136          }
   1.137          break;
   1.138  
   1.139 -        case Ph_EV_BUT_PRESS:
   1.140 +    case Ph_EV_BUT_PRESS:
   1.141          {
   1.142              pointerEvent = PhGetData(phevent);
   1.143              buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   1.144 -            if (buttons != 0)
   1.145 -            {
   1.146 +            if (buttons != 0) {
   1.147                  posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   1.148              }
   1.149          }
   1.150          break;
   1.151  
   1.152 -        case Ph_EV_BUT_RELEASE:
   1.153 +    case Ph_EV_BUT_RELEASE:
   1.154          {
   1.155              pointerEvent = PhGetData(phevent);
   1.156              buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   1.157 -            if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
   1.158 -            {
   1.159 +            if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0) {
   1.160                  posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   1.161 -            }
   1.162 -            else if(phevent->subtype == Ph_EV_RELEASE_PHANTOM)
   1.163 -            {
   1.164 +            } else if (phevent->subtype == Ph_EV_RELEASE_PHANTOM) {
   1.165                  /* If the mouse is outside the window,
   1.166                   * only a phantom release event is sent, so
   1.167                   * check if the window doesn't have mouse focus.
   1.168                   * Not perfect, maybe checking the mouse button
   1.169                   * state for Ph_EV_BOUNDARY events would be
   1.170                   * better. */
   1.171 -                if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0)
   1.172 -		{
   1.173 -                    posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   1.174 +                if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) {
   1.175 +                    posted =
   1.176 +                        SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   1.177                  }
   1.178              }
   1.179          }
   1.180          break;
   1.181  
   1.182 -        case Ph_EV_WM:
   1.183 +    case Ph_EV_WM:
   1.184          {
   1.185              winEvent = PhGetData(phevent);
   1.186  
   1.187              /* losing focus */
   1.188 -            if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   1.189 -            {
   1.190 +            if ((winEvent->event_f == Ph_WM_FOCUS)
   1.191 +                && (winEvent->event_state == Ph_WM_EVSTATE_FOCUSLOST)) {
   1.192                  set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   1.193 -                posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
   1.194 +                posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
   1.195              }
   1.196              /* gaining focus */
   1.197 -            else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
   1.198 -            {
   1.199 +            else if ((winEvent->event_f == Ph_WM_FOCUS)
   1.200 +                     && (winEvent->event_state == Ph_WM_EVSTATE_FOCUS)) {
   1.201                  set_motion_sensitivity(this, -1);
   1.202                  posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   1.203              }
   1.204              /* request quit */
   1.205 -            else if (winEvent->event_f==Ph_WM_CLOSE)
   1.206 -            {
   1.207 +            else if (winEvent->event_f == Ph_WM_CLOSE) {
   1.208                  posted = SDL_PrivateQuit();
   1.209              }
   1.210              /* request hide/unhide */
   1.211 -            else if (winEvent->event_f==Ph_WM_HIDE)
   1.212 -            {
   1.213 -                if (currently_hided)
   1.214 -                {
   1.215 -                   /* got unhide window event                                */
   1.216 -                   /* TODO: restore application's palette if in palette mode */
   1.217 -                   currently_hided=0;
   1.218 -                }
   1.219 -                else
   1.220 -                {
   1.221 -                   /* got hide window event                                  */
   1.222 -                   /* TODO: restore original palette if in palette mode      */
   1.223 -                   currently_hided=1;
   1.224 +            else if (winEvent->event_f == Ph_WM_HIDE) {
   1.225 +                if (currently_hided) {
   1.226 +                    /* got unhide window event                                */
   1.227 +                    /* TODO: restore application's palette if in palette mode */
   1.228 +                    currently_hided = 0;
   1.229 +                } else {
   1.230 +                    /* got hide window event                                  */
   1.231 +                    /* TODO: restore original palette if in palette mode      */
   1.232 +                    currently_hided = 1;
   1.233                  }
   1.234              }
   1.235              /* request to resize */
   1.236 -            else if (winEvent->event_f==Ph_WM_RESIZE)
   1.237 -            {
   1.238 -                currently_maximized=0;
   1.239 -                #if (_NTO_VERSION < 630)
   1.240 -                   SDL_PrivateResize(winEvent->size.w+1, winEvent->size.h+1);
   1.241 -                #else
   1.242 -                   /* QNX 6.3.0 have this bug fixed */
   1.243 -                   SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
   1.244 -                #endif /* _NTO_VERSION */
   1.245 +            else if (winEvent->event_f == Ph_WM_RESIZE) {
   1.246 +                currently_maximized = 0;
   1.247 +#if (_NTO_VERSION < 630)
   1.248 +                SDL_PrivateResize(winEvent->size.w + 1, winEvent->size.h + 1);
   1.249 +#else
   1.250 +                /* QNX 6.3.0 have this bug fixed */
   1.251 +                SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
   1.252 +#endif /* _NTO_VERSION */
   1.253              }
   1.254              /* request to move */
   1.255 -            else if (winEvent->event_f==Ph_WM_MOVE)
   1.256 -            {
   1.257 -                if (current_overlay!=NULL)
   1.258 -                {
   1.259 -                   int lockedstate=current_overlay->hwdata->locked;
   1.260 -                   int chromastate=current_overlay->hwdata->ischromakey;
   1.261 -                   int error;
   1.262 -                   SDL_Rect src, dst;
   1.263 +            else if (winEvent->event_f == Ph_WM_MOVE) {
   1.264 +                if (current_overlay != NULL) {
   1.265 +                    int lockedstate = current_overlay->hwdata->locked;
   1.266 +                    int chromastate = current_overlay->hwdata->ischromakey;
   1.267 +                    int error;
   1.268 +                    SDL_Rect src, dst;
   1.269  
   1.270 -                   current_overlay->hwdata->locked=1;
   1.271 -                   src.x = 0;
   1.272 -                   src.y = 0;
   1.273 -                   src.w = current_overlay->w;
   1.274 -                   src.y = current_overlay->h;
   1.275 -                   dst.x=current_overlay->hwdata->CurrentViewPort.pos.x;
   1.276 -                   dst.y=current_overlay->hwdata->CurrentViewPort.pos.y;
   1.277 -                   dst.w=current_overlay->hwdata->CurrentViewPort.size.w;
   1.278 -                   dst.h=current_overlay->hwdata->CurrentViewPort.size.h;
   1.279 -                   current_overlay->hwdata->ischromakey=0;
   1.280 -                   error=ph_DisplayYUVOverlay(this, current_overlay, &src, &dst);
   1.281 -                   if (!error)
   1.282 -                   {
   1.283 -                       current_overlay->hwdata->ischromakey=chromastate;
   1.284 -                       current_overlay->hwdata->locked=lockedstate;
   1.285 -                   }
   1.286 +                    current_overlay->hwdata->locked = 1;
   1.287 +                    src.x = 0;
   1.288 +                    src.y = 0;
   1.289 +                    src.w = current_overlay->w;
   1.290 +                    src.y = current_overlay->h;
   1.291 +                    dst.x = current_overlay->hwdata->CurrentViewPort.pos.x;
   1.292 +                    dst.y = current_overlay->hwdata->CurrentViewPort.pos.y;
   1.293 +                    dst.w = current_overlay->hwdata->CurrentViewPort.size.w;
   1.294 +                    dst.h = current_overlay->hwdata->CurrentViewPort.size.h;
   1.295 +                    current_overlay->hwdata->ischromakey = 0;
   1.296 +                    error =
   1.297 +                        ph_DisplayYUVOverlay(this, current_overlay,
   1.298 +                                             &src, &dst);
   1.299 +                    if (!error) {
   1.300 +                        current_overlay->hwdata->ischromakey = chromastate;
   1.301 +                        current_overlay->hwdata->locked = lockedstate;
   1.302 +                    }
   1.303                  }
   1.304              }
   1.305              /* maximize request */
   1.306 -            else if (winEvent->event_f==Ph_WM_MAX)
   1.307 -            {
   1.308 +            else if (winEvent->event_f == Ph_WM_MAX) {
   1.309                  /* window already moved and resized here */
   1.310 -                currently_maximized=1;
   1.311 +                currently_maximized = 1;
   1.312              }
   1.313              /* restore request */
   1.314 -            else if (winEvent->event_f==Ph_WM_RESTORE)
   1.315 -            {
   1.316 +            else if (winEvent->event_f == Ph_WM_RESTORE) {
   1.317                  /* window already moved and resized here */
   1.318 -                currently_maximized=0;
   1.319 +                currently_maximized = 0;
   1.320              }
   1.321          }
   1.322          break;
   1.323  
   1.324          /* window has been resized, moved or removed */
   1.325 -        case Ph_EV_EXPOSE:
   1.326 +    case Ph_EV_EXPOSE:
   1.327          {
   1.328 -            if (phevent->num_rects!=0)
   1.329 -            {
   1.330 +            if (phevent->num_rects != 0) {
   1.331                  int numrects;
   1.332  
   1.333 -                if (SDL_VideoSurface)
   1.334 -                {
   1.335 +                if (SDL_VideoSurface) {
   1.336                      rect = PhGetRects(phevent);
   1.337 -                    if (phevent->num_rects>PH_SDL_MAX_RECTS)
   1.338 -                    {
   1.339 -                       /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */
   1.340 -                       numrects=PH_SDL_MAX_RECTS;
   1.341 +                    if (phevent->num_rects > PH_SDL_MAX_RECTS) {
   1.342 +                        /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */
   1.343 +                        numrects = PH_SDL_MAX_RECTS;
   1.344                      }
   1.345  
   1.346 -                    for(i=0; i<phevent->num_rects; i++)
   1.347 -                    {
   1.348 +                    for (i = 0; i < phevent->num_rects; i++) {
   1.349                          sdlrects[i].x = rect[i].ul.x;
   1.350                          sdlrects[i].y = rect[i].ul.y;
   1.351                          sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   1.352 @@ -306,35 +285,39 @@
   1.353  
   1.354                      this->UpdateRects(this, phevent->num_rects, sdlrects);
   1.355  
   1.356 -                    if (current_overlay!=NULL)
   1.357 -                    {
   1.358 -                        int lockedstate=current_overlay->hwdata->locked;
   1.359 +                    if (current_overlay != NULL) {
   1.360 +                        int lockedstate = current_overlay->hwdata->locked;
   1.361                          int error;
   1.362                          SDL_Rect src, dst;
   1.363  
   1.364 -                        current_overlay->hwdata->locked=1;
   1.365 +                        current_overlay->hwdata->locked = 1;
   1.366                          src.x = 0;
   1.367                          src.y = 0;
   1.368                          src.w = current_overlay->w;
   1.369                          src.y = current_overlay->h;
   1.370 -                        dst.x=current_overlay->hwdata->CurrentViewPort.pos.x;
   1.371 -                        dst.y=current_overlay->hwdata->CurrentViewPort.pos.y;
   1.372 -                        dst.w=current_overlay->hwdata->CurrentViewPort.size.w;
   1.373 -                        dst.h=current_overlay->hwdata->CurrentViewPort.size.h;
   1.374 -                        current_overlay->hwdata->forcedredraw=1;
   1.375 -                        error=ph_DisplayYUVOverlay(this, current_overlay, &src, &dst);
   1.376 -                        if (!error)
   1.377 -                        {
   1.378 -                            current_overlay->hwdata->forcedredraw=0;
   1.379 -                            current_overlay->hwdata->locked=lockedstate;
   1.380 +                        dst.x =
   1.381 +                            current_overlay->hwdata->CurrentViewPort.pos.x;
   1.382 +                        dst.y =
   1.383 +                            current_overlay->hwdata->CurrentViewPort.pos.y;
   1.384 +                        dst.w =
   1.385 +                            current_overlay->hwdata->CurrentViewPort.size.w;
   1.386 +                        dst.h =
   1.387 +                            current_overlay->hwdata->CurrentViewPort.size.h;
   1.388 +                        current_overlay->hwdata->forcedredraw = 1;
   1.389 +                        error =
   1.390 +                            ph_DisplayYUVOverlay(this,
   1.391 +                                                 current_overlay, &src, &dst);
   1.392 +                        if (!error) {
   1.393 +                            current_overlay->hwdata->forcedredraw = 0;
   1.394 +                            current_overlay->hwdata->locked = lockedstate;
   1.395                          }
   1.396                      }
   1.397                  }
   1.398              }
   1.399          }
   1.400 -	break;
   1.401 +        break;
   1.402  
   1.403 -        case Ph_EV_KEY:
   1.404 +    case Ph_EV_KEY:
   1.405          {
   1.406              SDL_keysym keysym;
   1.407  
   1.408 @@ -342,208 +325,223 @@
   1.409  
   1.410              keyEvent = PhGetData(phevent);
   1.411  
   1.412 -            if (Pk_KF_Key_Down & keyEvent->key_flags)
   1.413 -            {
   1.414 +            if (Pk_KF_Key_Down & keyEvent->key_flags) {
   1.415                  /* split the wheel events from real key events */
   1.416 -                if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   1.417 -                {
   1.418 -                   posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
   1.419 -                   break;
   1.420 +                if ((keyEvent->key_cap == Pk_Up)
   1.421 +                    && (keyEvent->key_scan == 0)
   1.422 +                    && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.423 +                        Pk_KF_Scan_Valid)) {
   1.424 +                    posted =
   1.425 +                        SDL_PrivateMouseButton(SDL_PRESSED,
   1.426 +                                               SDL_BUTTON_WHEELUP, 0, 0);
   1.427 +                    break;
   1.428                  }
   1.429 -                if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   1.430 -                {
   1.431 -                   posted = SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
   1.432 -                   break;
   1.433 +                if ((keyEvent->key_cap == Pk_Down)
   1.434 +                    && (keyEvent->key_scan == 0)
   1.435 +                    && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.436 +                        Pk_KF_Scan_Valid)) {
   1.437 +                    posted =
   1.438 +                        SDL_PrivateMouseButton(SDL_PRESSED,
   1.439 +                                               SDL_BUTTON_WHEELDOWN, 0, 0);
   1.440 +                    break;
   1.441                  }
   1.442 -                posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym));
   1.443 -            }
   1.444 -            else /* must be key release */
   1.445 -            {
   1.446 +                posted =
   1.447 +                    SDL_PrivateKeyboard(SDL_PRESSED,
   1.448 +                                        ph_TranslateKey(keyEvent, &keysym));
   1.449 +            } else {            /* must be key release */
   1.450 +
   1.451                  /* split the wheel events from real key events */
   1.452 -                if ((keyEvent->key_cap==Pk_Up) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   1.453 -                {
   1.454 -                   posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
   1.455 -                   break;
   1.456 +                if ((keyEvent->key_cap == Pk_Up)
   1.457 +                    && (keyEvent->key_scan == 0)
   1.458 +                    && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.459 +                        Pk_KF_Scan_Valid)) {
   1.460 +                    posted =
   1.461 +                        SDL_PrivateMouseButton(SDL_RELEASED,
   1.462 +                                               SDL_BUTTON_WHEELUP, 0, 0);
   1.463 +                    break;
   1.464                  }
   1.465 -                if ((keyEvent->key_cap==Pk_Down) && (keyEvent->key_scan==0) && ((keyEvent->key_flags & Pk_KF_Scan_Valid)==Pk_KF_Scan_Valid))
   1.466 -                {
   1.467 -                   posted = SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
   1.468 -                   break;
   1.469 +                if ((keyEvent->key_cap == Pk_Down)
   1.470 +                    && (keyEvent->key_scan == 0)
   1.471 +                    && ((keyEvent->key_flags & Pk_KF_Scan_Valid) ==
   1.472 +                        Pk_KF_Scan_Valid)) {
   1.473 +                    posted =
   1.474 +                        SDL_PrivateMouseButton(SDL_RELEASED,
   1.475 +                                               SDL_BUTTON_WHEELDOWN, 0, 0);
   1.476 +                    break;
   1.477                  }
   1.478 -                posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym));
   1.479 +                posted =
   1.480 +                    SDL_PrivateKeyboard(SDL_RELEASED,
   1.481 +                                        ph_TranslateKey(keyEvent, &keysym));
   1.482              }
   1.483          }
   1.484          break;
   1.485 -        
   1.486 -        case Ph_EV_INFO:
   1.487 +
   1.488 +    case Ph_EV_INFO:
   1.489          {
   1.490 -           if (phevent->subtype==Ph_OFFSCREEN_INVALID)
   1.491 -           {
   1.492 -              unsigned long* EvInfoData;
   1.493 +            if (phevent->subtype == Ph_OFFSCREEN_INVALID) {
   1.494 +                unsigned long *EvInfoData;
   1.495  
   1.496 -              EvInfoData=(unsigned long*)PhGetData(phevent);
   1.497 +                EvInfoData = (unsigned long *) PhGetData(phevent);
   1.498  
   1.499 -              switch (*EvInfoData)
   1.500 -              {
   1.501 -                 case Pg_VIDEO_MODE_SWITCHED:
   1.502 -                      {
   1.503 -                      }
   1.504 -                      break;
   1.505 -                 case Pg_ENTERED_DIRECT:
   1.506 -                      {
   1.507 -                      }
   1.508 -                      break;
   1.509 -                 case Pg_EXITED_DIRECT:
   1.510 -                      {
   1.511 -                      }
   1.512 -                      break;
   1.513 -                 case Pg_DRIVER_STARTED:
   1.514 -                      {
   1.515 -                      }
   1.516 -                      break;
   1.517 -              }
   1.518 -           }
   1.519 +                switch (*EvInfoData) {
   1.520 +                case Pg_VIDEO_MODE_SWITCHED:
   1.521 +                    {
   1.522 +                    }
   1.523 +                    break;
   1.524 +                case Pg_ENTERED_DIRECT:
   1.525 +                    {
   1.526 +                    }
   1.527 +                    break;
   1.528 +                case Pg_EXITED_DIRECT:
   1.529 +                    {
   1.530 +                    }
   1.531 +                    break;
   1.532 +                case Pg_DRIVER_STARTED:
   1.533 +                    {
   1.534 +                    }
   1.535 +                    break;
   1.536 +                }
   1.537 +            }
   1.538          }
   1.539          break;
   1.540      }
   1.541  
   1.542 -    return(posted);
   1.543 +    return (posted);
   1.544  }
   1.545  
   1.546  /* perform a blocking read if no events available */
   1.547 -int ph_Pending(_THIS)
   1.548 +int
   1.549 +ph_Pending(_THIS)
   1.550  {
   1.551      /* Flush the display connection and look to see if events are queued */
   1.552      PgFlush();
   1.553  
   1.554 -    while (1)
   1.555 -    {
   1.556 -        switch(PhEventPeek(phevent, EVENT_SIZE))
   1.557 -        {
   1.558 -            case Ph_EVENT_MSG:
   1.559 -                 return 1;
   1.560 -            case -1:
   1.561 -                 SDL_SetError("ph_Pending(): PhEventNext failed.\n");
   1.562 -                 return 0;
   1.563 -            default:
   1.564 -                 return 0;
   1.565 +    while (1) {
   1.566 +        switch (PhEventPeek(phevent, EVENT_SIZE)) {
   1.567 +        case Ph_EVENT_MSG:
   1.568 +            return 1;
   1.569 +        case -1:
   1.570 +            SDL_SetError("ph_Pending(): PhEventNext failed.\n");
   1.571 +            return 0;
   1.572 +        default:
   1.573 +            return 0;
   1.574          }
   1.575      }
   1.576  
   1.577      /* Oh well, nothing is ready .. */
   1.578 -    return(0);
   1.579 +    return (0);
   1.580  }
   1.581  
   1.582 -void ph_PumpEvents(_THIS)
   1.583 +void
   1.584 +ph_PumpEvents(_THIS)
   1.585  {
   1.586      /* Flush the display connection and look to see if events are queued */
   1.587      PgFlush();
   1.588  
   1.589 -    while (ph_Pending(this))
   1.590 -    {
   1.591 +    while (ph_Pending(this)) {
   1.592          PtEventHandler(phevent);
   1.593          ph_DispatchEvent(this);
   1.594      }
   1.595  }
   1.596  
   1.597 -void ph_InitKeymap(void)
   1.598 +void
   1.599 +ph_InitKeymap(void)
   1.600  {
   1.601      int i;
   1.602  
   1.603      /* Odd keys used in international keyboards */
   1.604 -    for (i=0; i<SDL_arraysize(ODD_keymap); ++i)
   1.605 -    {
   1.606 +    for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) {
   1.607          ODD_keymap[i] = SDLK_UNKNOWN;
   1.608      }
   1.609  
   1.610      /* Map the miscellaneous keys */
   1.611 -    for (i=0; i<SDL_arraysize(MISC_keymap); ++i)
   1.612 -    {
   1.613 +    for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) {
   1.614          MISC_keymap[i] = SDLK_UNKNOWN;
   1.615      }
   1.616  
   1.617 -    MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE;
   1.618 -    MISC_keymap[Pk_Tab&0xFF] = SDLK_TAB;
   1.619 -    MISC_keymap[Pk_Clear&0xFF] = SDLK_CLEAR;
   1.620 -    MISC_keymap[Pk_Return&0xFF] = SDLK_RETURN;
   1.621 -    MISC_keymap[Pk_Pause&0xFF] = SDLK_PAUSE;
   1.622 -    MISC_keymap[Pk_Escape&0xFF] = SDLK_ESCAPE;
   1.623 -    MISC_keymap[Pk_Delete&0xFF] = SDLK_DELETE;
   1.624 +    MISC_keymap[Pk_BackSpace & 0xFF] = SDLK_BACKSPACE;
   1.625 +    MISC_keymap[Pk_Tab & 0xFF] = SDLK_TAB;
   1.626 +    MISC_keymap[Pk_Clear & 0xFF] = SDLK_CLEAR;
   1.627 +    MISC_keymap[Pk_Return & 0xFF] = SDLK_RETURN;
   1.628 +    MISC_keymap[Pk_Pause & 0xFF] = SDLK_PAUSE;
   1.629 +    MISC_keymap[Pk_Escape & 0xFF] = SDLK_ESCAPE;
   1.630 +    MISC_keymap[Pk_Delete & 0xFF] = SDLK_DELETE;
   1.631  
   1.632 -    MISC_keymap[Pk_KP_0&0xFF] = SDLK_KP0;
   1.633 -    MISC_keymap[Pk_KP_1&0xFF] = SDLK_KP1;
   1.634 -    MISC_keymap[Pk_KP_2&0xFF] = SDLK_KP2;
   1.635 -    MISC_keymap[Pk_KP_3&0xFF] = SDLK_KP3;
   1.636 -    MISC_keymap[Pk_KP_4&0xFF] = SDLK_KP4;
   1.637 -    MISC_keymap[Pk_KP_5&0xFF] = SDLK_KP5;
   1.638 -    MISC_keymap[Pk_KP_6&0xFF] = SDLK_KP6;
   1.639 -    MISC_keymap[Pk_KP_7&0xFF] = SDLK_KP7;
   1.640 -    MISC_keymap[Pk_KP_8&0xFF] = SDLK_KP8;
   1.641 -    MISC_keymap[Pk_KP_9&0xFF] = SDLK_KP9;
   1.642 +    MISC_keymap[Pk_KP_0 & 0xFF] = SDLK_KP0;
   1.643 +    MISC_keymap[Pk_KP_1 & 0xFF] = SDLK_KP1;
   1.644 +    MISC_keymap[Pk_KP_2 & 0xFF] = SDLK_KP2;
   1.645 +    MISC_keymap[Pk_KP_3 & 0xFF] = SDLK_KP3;
   1.646 +    MISC_keymap[Pk_KP_4 & 0xFF] = SDLK_KP4;
   1.647 +    MISC_keymap[Pk_KP_5 & 0xFF] = SDLK_KP5;
   1.648 +    MISC_keymap[Pk_KP_6 & 0xFF] = SDLK_KP6;
   1.649 +    MISC_keymap[Pk_KP_7 & 0xFF] = SDLK_KP7;
   1.650 +    MISC_keymap[Pk_KP_8 & 0xFF] = SDLK_KP8;
   1.651 +    MISC_keymap[Pk_KP_9 & 0xFF] = SDLK_KP9;
   1.652  
   1.653 -    MISC_keymap[Pk_KP_Decimal&0xFF] = SDLK_KP_PERIOD;
   1.654 -    MISC_keymap[Pk_KP_Divide&0xFF] = SDLK_KP_DIVIDE;
   1.655 -    MISC_keymap[Pk_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY;
   1.656 -    MISC_keymap[Pk_KP_Subtract&0xFF] = SDLK_KP_MINUS;
   1.657 -    MISC_keymap[Pk_KP_Add&0xFF] = SDLK_KP_PLUS;
   1.658 -    MISC_keymap[Pk_KP_Enter&0xFF] = SDLK_KP_ENTER;
   1.659 -    MISC_keymap[Pk_KP_Equal&0xFF] = SDLK_KP_EQUALS;
   1.660 +    MISC_keymap[Pk_KP_Decimal & 0xFF] = SDLK_KP_PERIOD;
   1.661 +    MISC_keymap[Pk_KP_Divide & 0xFF] = SDLK_KP_DIVIDE;
   1.662 +    MISC_keymap[Pk_KP_Multiply & 0xFF] = SDLK_KP_MULTIPLY;
   1.663 +    MISC_keymap[Pk_KP_Subtract & 0xFF] = SDLK_KP_MINUS;
   1.664 +    MISC_keymap[Pk_KP_Add & 0xFF] = SDLK_KP_PLUS;
   1.665 +    MISC_keymap[Pk_KP_Enter & 0xFF] = SDLK_KP_ENTER;
   1.666 +    MISC_keymap[Pk_KP_Equal & 0xFF] = SDLK_KP_EQUALS;
   1.667  
   1.668 -    MISC_keymap[Pk_Up&0xFF] = SDLK_UP;
   1.669 -    MISC_keymap[Pk_Down&0xFF] = SDLK_DOWN;
   1.670 -    MISC_keymap[Pk_Right&0xFF] = SDLK_RIGHT;
   1.671 -    MISC_keymap[Pk_Left&0xFF] = SDLK_LEFT;
   1.672 -    MISC_keymap[Pk_Insert&0xFF] = SDLK_INSERT;
   1.673 -    MISC_keymap[Pk_Home&0xFF] = SDLK_HOME;
   1.674 -    MISC_keymap[Pk_End&0xFF] = SDLK_END;
   1.675 -    MISC_keymap[Pk_Pg_Up&0xFF] = SDLK_PAGEUP;
   1.676 -    MISC_keymap[Pk_Pg_Down&0xFF] = SDLK_PAGEDOWN;
   1.677 +    MISC_keymap[Pk_Up & 0xFF] = SDLK_UP;
   1.678 +    MISC_keymap[Pk_Down & 0xFF] = SDLK_DOWN;
   1.679 +    MISC_keymap[Pk_Right & 0xFF] = SDLK_RIGHT;
   1.680 +    MISC_keymap[Pk_Left & 0xFF] = SDLK_LEFT;
   1.681 +    MISC_keymap[Pk_Insert & 0xFF] = SDLK_INSERT;
   1.682 +    MISC_keymap[Pk_Home & 0xFF] = SDLK_HOME;
   1.683 +    MISC_keymap[Pk_End & 0xFF] = SDLK_END;
   1.684 +    MISC_keymap[Pk_Pg_Up & 0xFF] = SDLK_PAGEUP;
   1.685 +    MISC_keymap[Pk_Pg_Down & 0xFF] = SDLK_PAGEDOWN;
   1.686  
   1.687 -    MISC_keymap[Pk_F1&0xFF] = SDLK_F1;
   1.688 -    MISC_keymap[Pk_F2&0xFF] = SDLK_F2;
   1.689 -    MISC_keymap[Pk_F3&0xFF] = SDLK_F3;
   1.690 -    MISC_keymap[Pk_F4&0xFF] = SDLK_F4;
   1.691 -    MISC_keymap[Pk_F5&0xFF] = SDLK_F5;
   1.692 -    MISC_keymap[Pk_F6&0xFF] = SDLK_F6;
   1.693 -    MISC_keymap[Pk_F7&0xFF] = SDLK_F7;
   1.694 -    MISC_keymap[Pk_F8&0xFF] = SDLK_F8;
   1.695 -    MISC_keymap[Pk_F9&0xFF] = SDLK_F9;
   1.696 -    MISC_keymap[Pk_F10&0xFF] = SDLK_F10;
   1.697 -    MISC_keymap[Pk_F11&0xFF] = SDLK_F11;
   1.698 -    MISC_keymap[Pk_F12&0xFF] = SDLK_F12;
   1.699 -    MISC_keymap[Pk_F13&0xFF] = SDLK_F13;
   1.700 -    MISC_keymap[Pk_F14&0xFF] = SDLK_F14;
   1.701 -    MISC_keymap[Pk_F15&0xFF] = SDLK_F15;
   1.702 +    MISC_keymap[Pk_F1 & 0xFF] = SDLK_F1;
   1.703 +    MISC_keymap[Pk_F2 & 0xFF] = SDLK_F2;
   1.704 +    MISC_keymap[Pk_F3 & 0xFF] = SDLK_F3;
   1.705 +    MISC_keymap[Pk_F4 & 0xFF] = SDLK_F4;
   1.706 +    MISC_keymap[Pk_F5 & 0xFF] = SDLK_F5;
   1.707 +    MISC_keymap[Pk_F6 & 0xFF] = SDLK_F6;
   1.708 +    MISC_keymap[Pk_F7 & 0xFF] = SDLK_F7;
   1.709 +    MISC_keymap[Pk_F8 & 0xFF] = SDLK_F8;
   1.710 +    MISC_keymap[Pk_F9 & 0xFF] = SDLK_F9;
   1.711 +    MISC_keymap[Pk_F10 & 0xFF] = SDLK_F10;
   1.712 +    MISC_keymap[Pk_F11 & 0xFF] = SDLK_F11;
   1.713 +    MISC_keymap[Pk_F12 & 0xFF] = SDLK_F12;
   1.714 +    MISC_keymap[Pk_F13 & 0xFF] = SDLK_F13;
   1.715 +    MISC_keymap[Pk_F14 & 0xFF] = SDLK_F14;
   1.716 +    MISC_keymap[Pk_F15 & 0xFF] = SDLK_F15;
   1.717  
   1.718 -    MISC_keymap[Pk_Num_Lock&0xFF] = SDLK_NUMLOCK;
   1.719 -    MISC_keymap[Pk_Caps_Lock&0xFF] = SDLK_CAPSLOCK;
   1.720 -    MISC_keymap[Pk_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
   1.721 -    MISC_keymap[Pk_Shift_R&0xFF] = SDLK_RSHIFT;
   1.722 -    MISC_keymap[Pk_Shift_L&0xFF] = SDLK_LSHIFT;
   1.723 -    MISC_keymap[Pk_Control_R&0xFF] = SDLK_RCTRL;
   1.724 -    MISC_keymap[Pk_Control_L&0xFF] = SDLK_LCTRL;
   1.725 -    MISC_keymap[Pk_Alt_R&0xFF] = SDLK_RALT;
   1.726 -    MISC_keymap[Pk_Alt_L&0xFF] = SDLK_LALT;
   1.727 -    MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA;
   1.728 -    MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA;
   1.729 -    MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER;
   1.730 -    MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER;
   1.731 -    MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key    */
   1.732 +    MISC_keymap[Pk_Num_Lock & 0xFF] = SDLK_NUMLOCK;
   1.733 +    MISC_keymap[Pk_Caps_Lock & 0xFF] = SDLK_CAPSLOCK;
   1.734 +    MISC_keymap[Pk_Scroll_Lock & 0xFF] = SDLK_SCROLLOCK;
   1.735 +    MISC_keymap[Pk_Shift_R & 0xFF] = SDLK_RSHIFT;
   1.736 +    MISC_keymap[Pk_Shift_L & 0xFF] = SDLK_LSHIFT;
   1.737 +    MISC_keymap[Pk_Control_R & 0xFF] = SDLK_RCTRL;
   1.738 +    MISC_keymap[Pk_Control_L & 0xFF] = SDLK_LCTRL;
   1.739 +    MISC_keymap[Pk_Alt_R & 0xFF] = SDLK_RALT;
   1.740 +    MISC_keymap[Pk_Alt_L & 0xFF] = SDLK_LALT;
   1.741 +    MISC_keymap[Pk_Meta_R & 0xFF] = SDLK_RMETA;
   1.742 +    MISC_keymap[Pk_Meta_L & 0xFF] = SDLK_LMETA;
   1.743 +    MISC_keymap[Pk_Super_L & 0xFF] = SDLK_LSUPER;
   1.744 +    MISC_keymap[Pk_Super_R & 0xFF] = SDLK_RSUPER;
   1.745 +    MISC_keymap[Pk_Mode_switch & 0xFF] = SDLK_MODE;     /* "Alt Gr" key    */
   1.746  
   1.747 -    MISC_keymap[Pk_Help&0xFF] = SDLK_HELP;
   1.748 -    MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT;
   1.749 -    MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK;
   1.750 -    MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU;        /* Windows "Menu" key */
   1.751 +    MISC_keymap[Pk_Help & 0xFF] = SDLK_HELP;
   1.752 +    MISC_keymap[Pk_Print & 0xFF] = SDLK_PRINT;
   1.753 +    MISC_keymap[Pk_Break & 0xFF] = SDLK_BREAK;
   1.754 +    MISC_keymap[Pk_Menu & 0xFF] = SDLK_MENU;    /* Windows "Menu" key */
   1.755  
   1.756 -    MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_RSUPER;   /* Right "Windows" */
   1.757 +    MISC_keymap[Pk_Hyper_R & 0xFF] = SDLK_RSUPER;       /* Right "Windows" */
   1.758  
   1.759      /* Left "Windows" key, but it can't be catched by application */
   1.760 -    MISC_keymap[Pk_Hyper_L&0xFF] = SDLK_LSUPER;
   1.761 +    MISC_keymap[Pk_Hyper_L & 0xFF] = SDLK_LSUPER;
   1.762  }
   1.763  
   1.764  static unsigned long cap;
   1.765  
   1.766 -SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)
   1.767 +SDL_keysym *
   1.768 +ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym)
   1.769  {
   1.770      /* 'sym' is set to the value of the key with modifiers applied to it.
   1.771         This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
   1.772 @@ -553,64 +551,62 @@
   1.773  
   1.774      cap = key->key_cap;
   1.775  
   1.776 -    switch (cap>>8)
   1.777 -    {
   1.778 -        case 0x00:  /* Latin 1 */
   1.779 -        case 0x01:  /* Latin 2 */
   1.780 -        case 0x02:  /* Latin 3 */
   1.781 -        case 0x03:  /* Latin 4 */
   1.782 -        case 0x04:  /* Katakana */
   1.783 -        case 0x05:  /* Arabic */
   1.784 -        case 0x06:  /* Cyrillic */
   1.785 -        case 0x07:  /* Greek */
   1.786 -        case 0x08:  /* Technical */
   1.787 -        case 0x0A:  /* Publishing */
   1.788 -        case 0x0C:  /* Hebrew */
   1.789 -        case 0x0D:  /* Thai */
   1.790 -                   keysym->sym = (SDLKey)(cap&0xFF);
   1.791 -                   /* Map capital letter syms to lowercase */
   1.792 -                   if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z'))
   1.793 -                       keysym->sym += ('a'-'A');
   1.794 -                   break;
   1.795 -        case 0xF0:
   1.796 -                   keysym->sym = MISC_keymap[cap&0xFF];
   1.797 -                   break;
   1.798 -        default:
   1.799 -                   keysym->sym = SDLK_UNKNOWN;                
   1.800 -                   break;
   1.801 +    switch (cap >> 8) {
   1.802 +    case 0x00:                 /* Latin 1 */
   1.803 +    case 0x01:                 /* Latin 2 */
   1.804 +    case 0x02:                 /* Latin 3 */
   1.805 +    case 0x03:                 /* Latin 4 */
   1.806 +    case 0x04:                 /* Katakana */
   1.807 +    case 0x05:                 /* Arabic */
   1.808 +    case 0x06:                 /* Cyrillic */
   1.809 +    case 0x07:                 /* Greek */
   1.810 +    case 0x08:                 /* Technical */
   1.811 +    case 0x0A:                 /* Publishing */
   1.812 +    case 0x0C:                 /* Hebrew */
   1.813 +    case 0x0D:                 /* Thai */
   1.814 +        keysym->sym = (SDLKey) (cap & 0xFF);
   1.815 +        /* Map capital letter syms to lowercase */
   1.816 +        if ((keysym->sym >= 'A') && (keysym->sym <= 'Z'))
   1.817 +            keysym->sym += ('a' - 'A');
   1.818 +        break;
   1.819 +    case 0xF0:
   1.820 +        keysym->sym = MISC_keymap[cap & 0xFF];
   1.821 +        break;
   1.822 +    default:
   1.823 +        keysym->sym = SDLK_UNKNOWN;
   1.824 +        break;
   1.825      }
   1.826  
   1.827      keysym->scancode = key->key_scan;
   1.828      keysym->unicode = 0;
   1.829  
   1.830 -    if (SDL_TranslateUNICODE)
   1.831 -    {
   1.832 +    if (SDL_TranslateUNICODE) {
   1.833          char utf8[MB_CUR_MAX];
   1.834          int utf8len;
   1.835          wchar_t unicode;
   1.836  
   1.837 -        switch (keysym->scancode)
   1.838 -        {
   1.839 -           /* Esc key */
   1.840 -           case 0x01: keysym->unicode = 27;
   1.841 -                      break;
   1.842 -           /* BackSpace key */
   1.843 -           case 0x0E: keysym->unicode = 127;
   1.844 -                      break;
   1.845 -           /* Enter key */
   1.846 -           case 0x1C: keysym->unicode = 10;
   1.847 -                      break;
   1.848 -           default:
   1.849 -                      utf8len = PhKeyToMb(utf8, key);
   1.850 -                      if (utf8len > 0)
   1.851 -                      {
   1.852 -                         utf8len = mbtowc(&unicode, utf8, utf8len);
   1.853 -                         if (utf8len > 0)
   1.854 -                         {
   1.855 -                             keysym->unicode = unicode;
   1.856 -                         }
   1.857 -                      }
   1.858 -                      break;
   1.859 +        switch (keysym->scancode) {
   1.860 +            /* Esc key */
   1.861 +        case 0x01:
   1.862 +            keysym->unicode = 27;
   1.863 +            break;
   1.864 +            /* BackSpace key */
   1.865 +        case 0x0E:
   1.866 +            keysym->unicode = 127;
   1.867 +            break;
   1.868 +            /* Enter key */
   1.869 +        case 0x1C:
   1.870 +            keysym->unicode = 10;
   1.871 +            break;
   1.872 +        default:
   1.873 +            utf8len = PhKeyToMb(utf8, key);
   1.874 +            if (utf8len > 0) {
   1.875 +                utf8len = mbtowc(&unicode, utf8, utf8len);
   1.876 +                if (utf8len > 0) {
   1.877 +                    keysym->unicode = unicode;
   1.878 +                }
   1.879 +            }
   1.880 +            break;
   1.881          }
   1.882  
   1.883      }
   1.884 @@ -618,7 +614,10 @@
   1.885      return (keysym);
   1.886  }
   1.887  
   1.888 -void ph_InitOSKeymap(_THIS)
   1.889 +void
   1.890 +ph_InitOSKeymap(_THIS)
   1.891  {
   1.892      ph_InitKeymap();
   1.893  }
   1.894 +
   1.895 +/* vi: set ts=4 sw=4 expandtab: */