src/events/SDL_mouse.c
branchgsoc2008_manymouse
changeset 3769 fe32943f86ec
parent 3767 abc8acb8e3d7
child 3770 81b649bad6d2
equal deleted inserted replaced
3768:1b87a8beab9d 3769:fe32943f86ec
    54 int
    54 int
    55 SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
    55 SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
    56 {
    56 {
    57     SDL_Mouse **mice;
    57     SDL_Mouse **mice;
    58     int selected_mouse;
    58     int selected_mouse;
    59     //char* temp_name;
    59 	int length;
       
    60 
    60     /* Add the mouse to the list of mice */
    61     /* Add the mouse to the list of mice */
    61     if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) {
    62     if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) {
    62         mice =
    63         mice =
    63             (SDL_Mouse **) SDL_realloc(SDL_mice,
    64             (SDL_Mouse **) SDL_realloc(SDL_mice,
    64                                        (SDL_num_mice + 1) * sizeof(*mice));
    65                                        (SDL_num_mice + 1) * sizeof(*mice));
    74     if (!SDL_mice[index]) {
    75     if (!SDL_mice[index]) {
    75         SDL_OutOfMemory();
    76         SDL_OutOfMemory();
    76         return -1;
    77         return -1;
    77     }
    78     }
    78     *SDL_mice[index] = *mouse;
    79     *SDL_mice[index] = *mouse;
    79     SDL_mice[index]->name=SDL_malloc(SDL_strlen(name)*sizeof(char));
    80 	length=0;
    80     SDL_strlcpy(SDL_mice[index]->name,name,255);
    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);
    81     SDL_mice[index]->pressure_max=pressure_max;
    84     SDL_mice[index]->pressure_max=pressure_max;
    82     SDL_mice[index]->pressure_min=pressure_min;
    85     SDL_mice[index]->pressure_min=pressure_min;
    83     SDL_mice[index]->cursor_shown = SDL_TRUE;
    86     SDL_mice[index]->cursor_shown = SDL_TRUE;
    84     selected_mouse = SDL_SelectMouse(index);
    87     selected_mouse = SDL_SelectMouse(index);
    85     SDL_mice[index]->cur_cursor = NULL;
    88     SDL_mice[index]->cur_cursor = NULL;
   354     int index=SDL_GetIndexById(id);
   357     int index=SDL_GetIndexById(id);
   355     SDL_Mouse *mouse = SDL_GetMouse(index);
   358     SDL_Mouse *mouse = SDL_GetMouse(index);
   356     int posted;
   359     int posted;
   357     int xrel;
   360     int xrel;
   358     int yrel;
   361     int yrel;
   359 
   362 	if(x>x_max)
       
   363 	{
       
   364 		x=x_max;
       
   365 	}
       
   366 	if(y>y_max)
       
   367 	{
       
   368 		y=y_max;
       
   369 	}
   360     if (!mouse || mouse->flush_motion) {
   370     if (!mouse || mouse->flush_motion) {
   361         return 0;
   371         return 0;
   362     }
   372     }
   363     if(mouse->proximity==SDL_FALSE)
   373     if(mouse->proximity==SDL_FALSE)
   364     {
   374     {
   428     /* Post the event, if desired */
   438     /* Post the event, if desired */
   429     posted = 0;
   439     posted = 0;
   430     if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && SDL_mice[index]->proximity==SDL_TRUE) {
   440     if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && SDL_mice[index]->proximity==SDL_TRUE) {
   431         SDL_Event event;
   441         SDL_Event event;
   432         event.motion.type = SDL_MOUSEMOTION;
   442         event.motion.type = SDL_MOUSEMOTION;
   433 event.motion.which = (Uint8) index;
   443 		event.motion.which = (Uint8) index;
   434         event.motion.state = mouse->buttonstate;
   444         event.motion.state = mouse->buttonstate;
   435         event.motion.x = mouse->x;
   445         event.motion.x = mouse->x;
   436         event.motion.y = mouse->y;
   446         event.motion.y = mouse->y;
   437         event.motion.pressure= mouse->pressure;
   447         event.motion.pressure= mouse->pressure;
   438         event.motion.xrel = xrel;
   448         event.motion.xrel = xrel;
   570     }
   580     }
   571 
   581 
   572     /* Make sure the width is a multiple of 8 */
   582     /* Make sure the width is a multiple of 8 */
   573     w = ((w + 7) & ~7);
   583     w = ((w + 7) & ~7);
   574 
   584 
   575     /* Create the surface from a bitmap */
   585     /* Create the surface from a bitmap*/
   576     surface =
   586     surface =
   577         SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
   587         SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
   578                              0xFF000000);
   588                              0xFF000000);
   579     if (!surface) {
   589     if (!surface) {
   580         return NULL;
   590         return NULL;
   775 {
   785 {
   776     x_max=x;
   786     x_max=x;
   777     y_max=y;
   787     y_max=y;
   778 }
   788 }
   779 /* vi: set ts=4 sw=4 expandtab: */
   789 /* vi: set ts=4 sw=4 expandtab: */
       
   790