src/events/SDL_mouse.c
branchgsoc2008_manymouse
changeset 3769 fe32943f86ec
parent 3767 abc8acb8e3d7
child 3770 81b649bad6d2
     1.1 --- a/src/events/SDL_mouse.c	Wed Jul 30 16:09:24 2008 +0000
     1.2 +++ b/src/events/SDL_mouse.c	Wed Jul 30 16:20:32 2008 +0000
     1.3 @@ -56,7 +56,8 @@
     1.4  {
     1.5      SDL_Mouse **mice;
     1.6      int selected_mouse;
     1.7 -    //char* temp_name;
     1.8 +	int length;
     1.9 +
    1.10      /* Add the mouse to the list of mice */
    1.11      if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) {
    1.12          mice =
    1.13 @@ -76,8 +77,10 @@
    1.14          return -1;
    1.15      }
    1.16      *SDL_mice[index] = *mouse;
    1.17 -    SDL_mice[index]->name=SDL_malloc(SDL_strlen(name)*sizeof(char));
    1.18 -    SDL_strlcpy(SDL_mice[index]->name,name,255);
    1.19 +	length=0;
    1.20 +	length=SDL_strlen(name);
    1.21 +    SDL_mice[index]->name=SDL_malloc((length+1)*sizeof(char));
    1.22 +    SDL_strlcpy(SDL_mice[index]->name,name,length);
    1.23      SDL_mice[index]->pressure_max=pressure_max;
    1.24      SDL_mice[index]->pressure_min=pressure_min;
    1.25      SDL_mice[index]->cursor_shown = SDL_TRUE;
    1.26 @@ -356,7 +359,14 @@
    1.27      int posted;
    1.28      int xrel;
    1.29      int yrel;
    1.30 -
    1.31 +	if(x>x_max)
    1.32 +	{
    1.33 +		x=x_max;
    1.34 +	}
    1.35 +	if(y>y_max)
    1.36 +	{
    1.37 +		y=y_max;
    1.38 +	}
    1.39      if (!mouse || mouse->flush_motion) {
    1.40          return 0;
    1.41      }
    1.42 @@ -430,7 +440,7 @@
    1.43      if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && SDL_mice[index]->proximity==SDL_TRUE) {
    1.44          SDL_Event event;
    1.45          event.motion.type = SDL_MOUSEMOTION;
    1.46 -event.motion.which = (Uint8) index;
    1.47 +		event.motion.which = (Uint8) index;
    1.48          event.motion.state = mouse->buttonstate;
    1.49          event.motion.x = mouse->x;
    1.50          event.motion.y = mouse->y;
    1.51 @@ -572,7 +582,7 @@
    1.52      /* Make sure the width is a multiple of 8 */
    1.53      w = ((w + 7) & ~7);
    1.54  
    1.55 -    /* Create the surface from a bitmap */
    1.56 +    /* Create the surface from a bitmap*/
    1.57      surface =
    1.58          SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
    1.59                               0xFF000000);
    1.60 @@ -777,3 +787,4 @@
    1.61      y_max=y;
    1.62  }
    1.63  /* vi: set ts=4 sw=4 expandtab: */
    1.64 +