Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Sharpened code looks and a minor events upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Wilczek committed Aug 6, 2008
1 parent 0f199b1 commit b7354d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/SDL_events.h
Expand Up @@ -331,6 +331,7 @@ typedef struct SDL_ProximityEvent
{
Uint8 which;
Uint8 type;
int cursor;
int x;
int y;
} SDL_ProximityEvent;
Expand Down
13 changes: 8 additions & 5 deletions src/events/SDL_mouse.c
Expand Up @@ -338,6 +338,7 @@ int
SDL_SendProximity(int id, int x, int y, int type)
{
int index=SDL_GetIndexById(id);
SDL_Mouse* mouse=SDL_GetMouse(index);
int posted=0;
last_x=x;
last_y=y;
Expand All @@ -347,23 +348,24 @@ SDL_SendProximity(int id, int x, int y, int type)
event.proximity.which=(Uint8)index;
event.proximity.x=x;
event.proximity.y=y;
event.proximity.cursor=mouse->current_end;
event.type=type;
event.proximity.type=type;
posted = (SDL_PushEvent(&event) > 0);
if(type==SDL_PROXIMITYIN)
{
SDL_mice[index]->proximity=SDL_TRUE;
mouse->proximity=SDL_TRUE;
}
else
{
SDL_mice[index]->proximity=SDL_FALSE;
mouse->proximity=SDL_FALSE;
}
}
return posted;
}

int
SDL_SendMouseMotion(int id, int relative, int x, int y,int z)
SDL_SendMouseMotion(int id, int relative, int x, int y,int pressure)
{
int index=SDL_GetIndexById(id);
SDL_Mouse *mouse = SDL_GetMouse(index);
Expand Down Expand Up @@ -440,7 +442,7 @@ SDL_SendMouseMotion(int id, int relative, int x, int y,int z)
}
mouse->xdelta += xrel;
mouse->ydelta += yrel;
mouse->pressure=z;
mouse->pressure=pressure;

/* Move the mouse cursor, if needed */
if (mouse->cursor_shown && !mouse->relative_mode &&
Expand All @@ -450,7 +452,8 @@ SDL_SendMouseMotion(int id, int relative, int x, int y,int z)

/* Post the event, if desired */
posted = 0;
if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && SDL_mice[index]->proximity==SDL_TRUE) {
if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && \
mouse->proximity==SDL_TRUE) {
SDL_Event event;
event.motion.type = SDL_MOUSEMOTION;
event.motion.which = (Uint8) index;
Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11mouse.c
Expand Up @@ -59,7 +59,7 @@ X11_InitMouse(_THIS)
if(!newDevices)
{
SDL_OutOfMemory();
return -1;
return;
}
SDL_XDevices=newDevices;
SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
Expand Down

0 comments on commit b7354d7

Please sign in to comment.