src/events/SDL_mouse.c
author Szymon Wilczek
Wed, 30 Jul 2008 16:20:32 +0000
branchgsoc2008_manymouse
changeset 3769 fe32943f86ec
parent 3767 abc8acb8e3d7
child 3770 81b649bad6d2
permissions -rw-r--r--
Project part 2
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 /* General mouse handling code for SDL */
    25 
    26 #include "SDL_events.h"
    27 #include "SDL_events_c.h"
    28 #include "default_cursor.h"
    29 
    30 
    31 static int SDL_num_mice=0;
    32 static int SDL_current_mouse=-1;
    33 static SDL_Mouse **SDL_mice=NULL;
    34 static int *SDL_IdIndex=NULL;
    35 static int SDL_highestId=-1;
    36 static int last_x, last_y;
    37 int x_max, y_max;
    38 /* Public functions */
    39 int
    40 SDL_MouseInit(void)
    41 {
    42     return (0);
    43 }
    44 
    45 SDL_Mouse *
    46 SDL_GetMouse(int index)
    47 {
    48     if (index < 0 || index >= SDL_num_mice) {
    49         return NULL;
    50     }
    51     return SDL_mice[index];
    52 }
    53 
    54 int
    55 SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
    56 {
    57     SDL_Mouse **mice;
    58     int selected_mouse;
    59 	int length;
    60 
    61     /* Add the mouse to the list of mice */
    62     if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) {
    63         mice =
    64             (SDL_Mouse **) SDL_realloc(SDL_mice,
    65                                        (SDL_num_mice + 1) * sizeof(*mice));
    66         if (!mice) {
    67             SDL_OutOfMemory();
    68             return -1;
    69         }
    70 
    71         SDL_mice = mice;
    72         index = SDL_num_mice++;
    73     }
    74     SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index]));
    75     if (!SDL_mice[index]) {
    76         SDL_OutOfMemory();
    77         return -1;
    78     }
    79     *SDL_mice[index] = *mouse;
    80 	length=0;
    81 	length=SDL_strlen(name);
    82     SDL_mice[index]->name=SDL_malloc((length+1)*sizeof(char));
    83     SDL_strlcpy(SDL_mice[index]->name,name,length);
    84     SDL_mice[index]->pressure_max=pressure_max;
    85     SDL_mice[index]->pressure_min=pressure_min;
    86     SDL_mice[index]->cursor_shown = SDL_TRUE;
    87     selected_mouse = SDL_SelectMouse(index);
    88     SDL_mice[index]->cur_cursor = NULL;
    89     SDL_mice[index]->def_cursor =
    90         SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH,
    91                          DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
    92     SDL_SetCursor(SDL_mice[index]->def_cursor);
    93     SDL_mice[index]->proximity=SDL_TRUE;
    94     SDL_mice[index]->relative_mode=SDL_FALSE;
    95     SDL_SelectMouse(selected_mouse);
    96 
    97     return index;
    98 }
    99 
   100 void
   101 SDL_DelMouse(int index)
   102 {
   103     SDL_Mouse *mouse = SDL_GetMouse(index);
   104 
   105     if (!mouse) {
   106         return;
   107     }
   108 
   109     mouse->def_cursor = NULL;
   110     SDL_free(mouse->name);
   111     while (mouse->cursors) {
   112         SDL_FreeCursor(mouse->cursors);
   113     }
   114 
   115     if (mouse->FreeMouse) {
   116         mouse->FreeMouse(mouse);
   117     }
   118     SDL_free(mouse);
   119 
   120     SDL_mice[index] = NULL;
   121 }
   122 
   123 void
   124 SDL_ResetMouse(int index)
   125 {
   126     SDL_Mouse *mouse = SDL_GetMouse(index);
   127 
   128     if (!mouse) {
   129         return;
   130     }
   131 
   132     /* FIXME */
   133 }
   134 
   135 void
   136 SDL_MouseQuit(void)
   137 {
   138     int i;
   139 
   140     for (i = 0; i < SDL_num_mice; ++i) {
   141         SDL_DelMouse(i);
   142     }
   143     SDL_num_mice = 0;
   144     SDL_current_mouse = 0;
   145 
   146     if (SDL_mice) {
   147         SDL_free(SDL_mice);
   148         SDL_mice = NULL;
   149     }
   150 }
   151 
   152 int
   153 SDL_GetNumMice(void)
   154 {
   155     return SDL_num_mice;
   156 }
   157 
   158 int
   159 SDL_SelectMouse(int index)
   160 {
   161     if (index >= 0 && index < SDL_num_mice) {
   162         SDL_current_mouse = index;
   163     }
   164     return SDL_current_mouse;
   165 }
   166 
   167 SDL_WindowID
   168 SDL_GetMouseFocusWindow()
   169 {
   170     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   171 
   172     if (!mouse) {
   173         return 0;
   174     }
   175     return mouse->focus;
   176 }
   177 
   178 static int SDLCALL
   179 FlushMouseMotion(void *param, SDL_Event * event)
   180 {
   181     if (event->type == SDL_MOUSEMOTION
   182         && event->motion.which == (Uint8) SDL_current_mouse) {
   183         return 0;
   184     } else {
   185         return 1;
   186     }
   187 }
   188 
   189 int
   190 SDL_SetRelativeMouseMode(SDL_bool enabled, int index)
   191 {
   192     SDL_Mouse *mouse = SDL_GetMouse(index);
   193 
   194     if (!mouse) {
   195         return -1;
   196     }
   197 
   198     /* Flush pending mouse motion */
   199     mouse->flush_motion = SDL_TRUE;
   200     SDL_PumpEvents();
   201     mouse->flush_motion = SDL_FALSE;
   202     SDL_FilterEvents(FlushMouseMotion, mouse);
   203 
   204     /* Set the relative mode */
   205     mouse->relative_mode = enabled;
   206 
   207     /* Update cursor visibility */
   208     SDL_SetCursor(NULL);
   209 
   210     if (!enabled) {
   211         /* Restore the expected mouse position */
   212         SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
   213     }
   214     return 0;
   215 }
   216 
   217 SDL_bool
   218 SDL_GetRelativeMouseMode()
   219 {
   220     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   221 
   222     if (!mouse) {
   223         return SDL_FALSE;
   224     }
   225     return mouse->relative_mode;
   226 }
   227 
   228 Uint8
   229 SDL_GetMouseState(int *x, int *y)
   230 {
   231     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   232 
   233     if (!mouse) {
   234         if (x) {
   235             *x = 0;
   236         }
   237         if (y) {
   238             *y = 0;
   239         }
   240         return 0;
   241     }
   242 
   243     if (x) {
   244         *x = mouse->x;
   245     }
   246     if (y) {
   247         *y = mouse->y;
   248     }
   249     return mouse->buttonstate;
   250 }
   251 
   252 Uint8
   253 SDL_GetRelativeMouseState(int *x, int *y)
   254 {
   255     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   256 
   257     if (!mouse) {
   258         if (x) {
   259             *x = 0;
   260         }
   261         if (y) {
   262             *y = 0;
   263         }
   264         return 0;
   265     }
   266 
   267     if (x) {
   268         *x = mouse->xdelta;
   269     }
   270     if (y) {
   271         *y = mouse->ydelta;
   272     }
   273     mouse->xdelta = 0;
   274     mouse->ydelta = 0;
   275     return mouse->buttonstate;
   276 }
   277 
   278 void
   279 SDL_SetMouseFocus(int id, SDL_WindowID windowID)
   280 {
   281     int index = SDL_GetIndexById(id);
   282     SDL_Mouse *mouse = SDL_GetMouse(index);
   283     int i;
   284     SDL_bool focus;
   285 
   286     if (!mouse || (mouse->focus == windowID)) {
   287         return;
   288     }
   289 
   290     /* See if the current window has lost focus */
   291     if (mouse->focus) {
   292         focus = SDL_FALSE;
   293         for (i = 0; i < SDL_num_mice; ++i) {
   294             SDL_Mouse *check;
   295             if (i != index) {
   296                 check = SDL_GetMouse(i);
   297                 if (check && check->focus == mouse->focus) {
   298                     focus = SDL_TRUE;
   299                     break;
   300                 }
   301             }
   302         }
   303         if (!focus) {
   304             SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
   305         }
   306     }
   307 
   308     mouse->focus = windowID;
   309 
   310     if (mouse->focus) {
   311         focus = SDL_FALSE;
   312         for (i = 0; i < SDL_num_mice; ++i) {
   313             SDL_Mouse *check;
   314             if (i != index) {
   315                 check = SDL_GetMouse(i);
   316                 if (check && check->focus == mouse->focus) {
   317                     focus = SDL_TRUE;
   318                     break;
   319                 }
   320             }
   321         }
   322         if (!focus) {
   323             SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
   324         }
   325     }
   326 }
   327 
   328 int
   329 SDL_SendProximity(int id, int x, int y, int type)
   330 {
   331     int index=SDL_GetIndexById(id);
   332     int posted=0;
   333     if(SDL_ProcessEvents[type]==SDL_ENABLE)
   334     {
   335         SDL_Event event;
   336         event.proximity.which=(Uint8)index;
   337         event.proximity.x=x;
   338         event.proximity.y=y;
   339         event.type=type;
   340         event.proximity.type=type;
   341         posted = (SDL_PushEvent(&event) > 0);
   342         if(type==SDL_PROXIMITYIN)
   343         {
   344             SDL_mice[index]->proximity=SDL_TRUE;
   345         }
   346         else
   347         {
   348             SDL_mice[index]->proximity=SDL_FALSE;
   349         }
   350     }
   351     return posted;
   352 }
   353 
   354 int
   355 SDL_SendMouseMotion(int id, int relative, int x, int y,int z)
   356 {
   357     int index=SDL_GetIndexById(id);
   358     SDL_Mouse *mouse = SDL_GetMouse(index);
   359     int posted;
   360     int xrel;
   361     int yrel;
   362 	if(x>x_max)
   363 	{
   364 		x=x_max;
   365 	}
   366 	if(y>y_max)
   367 	{
   368 		y=y_max;
   369 	}
   370     if (!mouse || mouse->flush_motion) {
   371         return 0;
   372     }
   373     if(mouse->proximity==SDL_FALSE)
   374     {
   375         last_x=x;
   376         last_y=y;
   377         return 0;
   378     }
   379     if (mouse->relative_mode==SDL_TRUE && mouse->proximity==SDL_TRUE) {
   380         /* Push the cursor around */
   381         xrel = x - last_x;
   382         yrel = y - last_y;
   383     } else {
   384         xrel = x - last_x;
   385         yrel = y - last_y;
   386     }
   387 
   388     /* Drop events that don't change state */
   389     if (!xrel && !yrel) {
   390 #if 0
   391         printf("Mouse event didn't change state - dropped!\n");
   392 #endif
   393         return 0;
   394     }
   395 
   396     /* Update internal mouse state */
   397     if (mouse->relative_mode==SDL_FALSE) {
   398         mouse->x = x;
   399         mouse->y = y;
   400     }
   401     else
   402     {
   403         if(mouse->x+xrel>x_max)
   404         {
   405             mouse->x=x_max;
   406         }
   407         else if(mouse->x+xrel<0)
   408         {
   409             mouse->x=0;
   410         }
   411         else
   412         {
   413             mouse->x+=xrel;
   414         }
   415         if(mouse->y+yrel>y_max)
   416         {
   417             mouse->y=y_max;
   418         }
   419         else if(mouse->y+yrel<0)
   420         {
   421             mouse->y=0;
   422         }
   423         else
   424         {
   425             mouse->y+=yrel;
   426         }
   427     }
   428     mouse->xdelta += xrel;
   429     mouse->ydelta += yrel;
   430     mouse->pressure=z;
   431 
   432     /* Move the mouse cursor, if needed */
   433     if (mouse->cursor_shown && !mouse->relative_mode &&
   434         mouse->MoveCursor && mouse->cur_cursor) {
   435         mouse->MoveCursor(mouse->cur_cursor);
   436     }
   437 
   438     /* Post the event, if desired */
   439     posted = 0;
   440     if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && SDL_mice[index]->proximity==SDL_TRUE) {
   441         SDL_Event event;
   442         event.motion.type = SDL_MOUSEMOTION;
   443 		event.motion.which = (Uint8) index;
   444         event.motion.state = mouse->buttonstate;
   445         event.motion.x = mouse->x;
   446         event.motion.y = mouse->y;
   447         event.motion.pressure= mouse->pressure;
   448         event.motion.xrel = xrel;
   449         event.motion.yrel = yrel;
   450         event.motion.windowID = mouse->focus;
   451         event.motion.pressure_max=mouse->pressure_max;
   452         event.motion.pressure_min=mouse->pressure_min;
   453         posted = (SDL_PushEvent(&event) > 0);
   454     }
   455     last_x=x;
   456     last_y=y;
   457     return posted;
   458 }
   459 
   460 int
   461 SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
   462 {
   463     int index=SDL_GetIndexById(id);
   464     SDL_Mouse *mouse = SDL_GetMouse(index);
   465     int posted;
   466     Uint8 type;
   467 
   468     if (!mouse) {
   469         return 0;
   470     }
   471 
   472     /* Figure out which event to perform */
   473     switch (state) {
   474     case SDL_PRESSED:
   475         if (mouse->buttonstate & SDL_BUTTON(button)) {
   476             /* Ignore this event, no state change */
   477             return 0;
   478         }
   479         type = SDL_MOUSEBUTTONDOWN;
   480         mouse->buttonstate |= SDL_BUTTON(button);
   481         break;
   482     case SDL_RELEASED:
   483         //if (!(mouse->buttonstate & SDL_BUTTON(button))) {
   484         //    /* Ignore this event, no state change */
   485         //    return 0;
   486         //}*/
   487         type = SDL_MOUSEBUTTONUP;
   488         mouse->buttonstate &= ~SDL_BUTTON(button);
   489         break;
   490     default:
   491         /* Invalid state -- bail */
   492         return 0;
   493     }
   494 
   495     /* Post the event, if desired */
   496     posted = 0;
   497     if (SDL_ProcessEvents[type] == SDL_ENABLE) {
   498         SDL_Event event;
   499         event.type = type;
   500         event.button.which = (Uint8) index;
   501         event.button.state = state;
   502         event.button.button = button;
   503         event.button.x = mouse->x;
   504         event.button.y = mouse->y;
   505         event.button.windowID = mouse->focus;
   506         posted = (SDL_PushEvent(&event) > 0);
   507     }
   508     return posted;
   509 }
   510 
   511 int
   512 SDL_SendMouseWheel(int index, int x, int y)
   513 {
   514     SDL_Mouse *mouse = SDL_GetMouse(index);
   515     int posted;
   516 
   517     if (!mouse || (!x && !y)) {
   518         return 0;
   519     }
   520 
   521     /* Post the event, if desired */
   522     posted = 0;
   523     if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) {
   524         SDL_Event event;
   525         event.type = SDL_MOUSEWHEEL;
   526         event.wheel.which = (Uint8) index;
   527         event.wheel.x = x;
   528         event.wheel.y = y;
   529         event.wheel.windowID = mouse->focus;
   530         posted = (SDL_PushEvent(&event) > 0);
   531     }
   532     return posted;
   533 }
   534 
   535 void
   536 SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
   537 {
   538     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   539 
   540     if (!mouse) {
   541         return;
   542     }
   543 
   544     if (mouse->WarpMouse) {
   545         mouse->WarpMouse(mouse, windowID, x, y);
   546     } else {
   547         SDL_SetMouseFocus(SDL_current_mouse, windowID);
   548         SDL_SendMouseMotion(SDL_current_mouse, 0, x, y,0);
   549     }
   550 }
   551 
   552 SDL_Cursor *
   553 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
   554                  int w, int h, int hot_x, int hot_y)
   555 {
   556     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   557     SDL_Surface *surface;
   558     SDL_Cursor *cursor;
   559     int x, y;
   560     Uint32 *pixel;
   561     Uint8 datab, maskb;
   562     const Uint32 black = 0xFF000000;
   563     const Uint32 white = 0xFFFFFFFF;
   564     const Uint32 transparent = 0x00000000;
   565 
   566     if (!mouse) {
   567         SDL_SetError("No mice are initialized");
   568         return NULL;
   569     }
   570 
   571     if (!mouse->CreateCursor) {
   572         SDL_SetError("Current mouse doesn't have cursor support");
   573         return NULL;
   574     }
   575 
   576     /* Sanity check the hot spot */
   577     if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) {
   578         SDL_SetError("Cursor hot spot doesn't lie within cursor");
   579         return NULL;
   580     }
   581 
   582     /* Make sure the width is a multiple of 8 */
   583     w = ((w + 7) & ~7);
   584 
   585     /* Create the surface from a bitmap*/
   586     surface =
   587         SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
   588                              0xFF000000);
   589     if (!surface) {
   590         return NULL;
   591     }
   592     for (y = 0; y < h; ++y) {
   593         pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch);
   594         for (x = 0; x < w; ++x) {
   595             if ((x % 8) == 0) {
   596                 datab = *data++;
   597                 maskb = *mask++;
   598             }
   599             if (maskb & 0x80) {
   600                 *pixel++ = (datab & 0x80) ? black : white;
   601             } else {
   602                 *pixel++ = (datab & 0x80) ? black : transparent;
   603             }
   604             datab <<= 1;
   605             maskb <<= 1;
   606         }
   607     }
   608 
   609     cursor = mouse->CreateCursor(surface, hot_x, hot_y);
   610     if (cursor) {
   611         cursor->mouse = mouse;
   612         cursor->next = mouse->cursors;
   613         mouse->cursors = cursor;
   614     }
   615 
   616     SDL_FreeSurface(surface);
   617 
   618     return cursor;
   619 }
   620 
   621 /* SDL_SetCursor(NULL) can be used to force the cursor redraw,
   622    if this is desired for any reason.  This is used when setting
   623    the video mode and when the SDL window gains the mouse focus.
   624  */
   625 void
   626 SDL_SetCursor(SDL_Cursor * cursor)
   627 {
   628     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   629 
   630     if (!mouse) {
   631         SDL_SetError("No mice are initialized");
   632         return;
   633     }
   634 
   635     /* Set the new cursor */
   636     if (cursor) {
   637         /* Make sure the cursor is still valid for this mouse */
   638         SDL_Cursor *found;
   639         for (found = mouse->cursors; found; found = found->next) {
   640             if (found == cursor) {
   641                 break;
   642             }
   643         }
   644         if (!found) {
   645             SDL_SetError("Cursor not associated with the current mouse");
   646             return;
   647         }
   648         mouse->cur_cursor = cursor;
   649     } else {
   650         cursor = mouse->cur_cursor;
   651     }
   652 
   653     if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
   654         if (mouse->ShowCursor) {
   655             mouse->ShowCursor(cursor);
   656         }
   657     } else {
   658         if (mouse->ShowCursor) {
   659             mouse->ShowCursor(NULL);
   660         }
   661     }
   662 }
   663 
   664 SDL_Cursor *
   665 SDL_GetCursor(void)
   666 {
   667     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   668 
   669     if (!mouse) {
   670         return NULL;
   671     }
   672     return mouse->cur_cursor;
   673 }
   674 
   675 void
   676 SDL_FreeCursor(SDL_Cursor * cursor)
   677 {
   678     SDL_Mouse *mouse;
   679     SDL_Cursor *curr, *prev;
   680 
   681     if (!cursor) {
   682         return;
   683     }
   684     mouse = cursor->mouse;
   685 
   686     if (cursor == mouse->def_cursor) {
   687         return;
   688     }
   689     if (cursor == mouse->cur_cursor) {
   690         SDL_SetCursor(mouse->def_cursor);
   691     }
   692 
   693     for (prev = NULL, curr = mouse->cursors; curr;
   694          prev = curr, curr = curr->next) {
   695         if (curr == cursor) {
   696             if (prev) {
   697                 prev->next = curr->next;
   698             } else {
   699                 mouse->cursors = curr->next;
   700             }
   701 
   702             if (mouse->FreeCursor) {
   703                 mouse->FreeCursor(curr);
   704             }
   705             return;
   706         }
   707     }
   708 }
   709 
   710 int
   711 SDL_ShowCursor(int toggle)
   712 {
   713     SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
   714     SDL_bool shown;
   715 
   716     if (!mouse) {
   717         return 0;
   718     }
   719 
   720     shown = mouse->cursor_shown;
   721     if (toggle >= 0) {
   722         if (toggle) {
   723             mouse->cursor_shown = SDL_TRUE;
   724         } else {
   725             mouse->cursor_shown = SDL_FALSE;
   726         }
   727         if (mouse->cursor_shown != shown) {
   728             SDL_SetCursor(NULL);
   729         }
   730     }
   731     return shown;
   732 }
   733 
   734 int SDL_SetIndexId(int id, int index)
   735 {
   736     if(id>SDL_highestId)
   737     {
   738         int *indexes;
   739         indexes =
   740             (int*) SDL_realloc(SDL_IdIndex,
   741                                        (id + 1) * sizeof(int));
   742         if (!indexes) {
   743             SDL_OutOfMemory();
   744             return -1;
   745         }
   746         SDL_IdIndex=indexes;
   747         SDL_IdIndex[id]=index;
   748         SDL_highestId=id;
   749     }
   750     else
   751     {
   752         SDL_IdIndex[id]=index;
   753     }
   754 	return 1;
   755 }
   756 
   757 int SDL_GetIndexById(int id)
   758 {
   759     if(id>SDL_highestId)
   760     {
   761         return -1;
   762     }
   763     else
   764     {
   765         return SDL_IdIndex[id];
   766     }
   767 }
   768 
   769 int SDL_GetNumOfMice(void)
   770 {
   771     return SDL_num_mice;
   772 }
   773 
   774 char* SDL_GetMouseName(int index)
   775 {
   776     SDL_Mouse* mouse = SDL_GetMouse(index);
   777     if(!mouse)
   778     {
   779         return NULL;
   780     }
   781     return mouse->name;
   782 }
   783 
   784 void SDL_UpdateCoordinates(int x, int y)
   785 {
   786     x_max=x;
   787     y_max=y;
   788 }
   789 /* vi: set ts=4 sw=4 expandtab: */
   790