Mercurial > sdl-ios-xcode
diff src/video/ataricommon/SDL_ataridevmouse.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 2405517b5eab |
children | 4da1ee79c9af |
line wrap: on
line diff
--- a/src/video/ataricommon/SDL_ataridevmouse.c Sun May 21 17:27:13 2006 +0000 +++ b/src/video/ataricommon/SDL_ataridevmouse.c Sun May 28 13:04:16 2006 +0000 @@ -44,116 +44,123 @@ /* Functions */ -int SDL_AtariDevMouse_Open(void) +int +SDL_AtariDevMouse_Open (void) { - int r; - const char *mousedev; - - /* - TODO: Fix the MiNT device driver, that locks mouse for other - applications, so this is disabled till fixed - */ - return 0; + int r; + const char *mousedev; - /* First, try SDL_MOUSEDEV device */ - mousedev = SDL_getenv("SDL_MOUSEDEV"); - if (!mousedev) { - handle = open(mousedev, 0); - } + /* + TODO: Fix the MiNT device driver, that locks mouse for other + applications, so this is disabled till fixed + */ + return 0; - /* Failed, try default device */ - if (handle<0) { - handle = open(DEVICE_NAME, 0); - } + /* First, try SDL_MOUSEDEV device */ + mousedev = SDL_getenv ("SDL_MOUSEDEV"); + if (!mousedev) { + handle = open (mousedev, 0); + } + + /* Failed, try default device */ + if (handle < 0) { + handle = open (DEVICE_NAME, 0); + } - if (handle<0) { - handle = -1; - return 0; - } + if (handle < 0) { + handle = -1; + return 0; + } - /* Set non blocking mode */ - r = fcntl(handle, F_GETFL, 0); - if (r<0) { - close(handle); - handle = -1; - return 0; - } + /* Set non blocking mode */ + r = fcntl (handle, F_GETFL, 0); + if (r < 0) { + close (handle); + handle = -1; + return 0; + } - r |= O_NDELAY; + r |= O_NDELAY; - r = fcntl(handle, F_SETFL, r); - if (r<0) { - close(handle); - handle = -1; - return 0; - } + r = fcntl (handle, F_SETFL, r); + if (r < 0) { + close (handle); + handle = -1; + return 0; + } - prev_mouseb = 7; - return 1; + prev_mouseb = 7; + return 1; } -void SDL_AtariDevMouse_Close(void) +void +SDL_AtariDevMouse_Close (void) { - if (handle>0) { - close(handle); - handle = -1; - } + if (handle > 0) { + close (handle); + handle = -1; + } } -static int atari_GetButton(int button) +static int +atari_GetButton (int button) { - switch(button) - { - case 0: - return SDL_BUTTON_RIGHT; - case 1: - return SDL_BUTTON_MIDDLE; - default: - break; - } + switch (button) { + case 0: + return SDL_BUTTON_RIGHT; + case 1: + return SDL_BUTTON_MIDDLE; + default: + break; + } - return SDL_BUTTON_LEFT; + return SDL_BUTTON_LEFT; } -void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents) +void +SDL_AtariDevMouse_PostMouseEvents (_THIS, SDL_bool buttonEvents) { - unsigned char buffer[3]; - int mousex, mousey; + unsigned char buffer[3]; + int mousex, mousey; - if (handle<0) { - return; - } + if (handle < 0) { + return; + } - mousex = mousey = 0; - while (read(handle, buffer, sizeof(buffer))==sizeof(buffer)) { - mouseb = buffer[0] & 7; - mousex += (char) buffer[1]; - mousey += (char) buffer[2]; + mousex = mousey = 0; + while (read (handle, buffer, sizeof (buffer)) == sizeof (buffer)) { + mouseb = buffer[0] & 7; + mousex += (char) buffer[1]; + mousey += (char) buffer[2]; - /* Mouse button events */ - if (buttonEvents && (mouseb != prev_mouseb)) { - int i; + /* Mouse button events */ + if (buttonEvents && (mouseb != prev_mouseb)) { + int i; + + for (i = 0; i < 3; i++) { + int curbutton, prevbutton; - for (i=0;i<3;i++) { - int curbutton, prevbutton; + curbutton = mouseb & (1 << i); + prevbutton = prev_mouseb & (1 << i); - curbutton = mouseb & (1<<i); - prevbutton = prev_mouseb & (1<<i); - - if (curbutton && !prevbutton) { - SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); - } - if (!curbutton && prevbutton) { - SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); - } - } + if (curbutton && !prevbutton) { + SDL_PrivateMouseButton (SDL_RELEASED, + atari_GetButton (i), 0, 0); + } + if (!curbutton && prevbutton) { + SDL_PrivateMouseButton (SDL_PRESSED, + atari_GetButton (i), 0, 0); + } + } - prev_mouseb = mouseb; - } - } + prev_mouseb = mouseb; + } + } - /* Mouse motion event */ - if (mousex || mousey) { - SDL_PrivateMouseMotion(0, 1, mousex, -mousey); - } + /* Mouse motion event */ + if (mousex || mousey) { + SDL_PrivateMouseMotion (0, 1, mousex, -mousey); + } } + +/* vi: set ts=4 sw=4 expandtab: */