annotate src/video/ataricommon/SDL_ataridevmouse.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
rev   line source
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1 /*
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
4
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
9
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
13 Lesser General Public License for more details.
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
14
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
18
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
19 Sam Lantinga
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
20 slouken@libsdl.org
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
21 */
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
22 #include "SDL_config.h"
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
23
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
24 /*
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
25 MiNT /dev/mouse driver
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
26
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
27 Patrice Mandin
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
28 */
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
29
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
30 #include <fcntl.h>
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
31 #include <unistd.h>
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
32
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
33 #include "../../events/SDL_events_c.h"
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
34 #include "SDL_ataridevmouse_c.h"
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
36 /* Defines */
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
37
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
38 #define DEVICE_NAME "/dev/mouse"
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
39
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
40 /* Local variables */
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
41
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
42 static int handle = -1;
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
43 static int mouseb, prev_mouseb;
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
44
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
45 /* Functions */
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
46
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
47 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
48 SDL_AtariDevMouse_Open(void)
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
49 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
50 int r;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
51 const char *mousedev;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
52
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
53 /*
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
54 TODO: Fix the MiNT device driver, that locks mouse for other
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
55 applications, so this is disabled till fixed
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
56 */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
57 return 0;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
58
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
59 /* First, try SDL_MOUSEDEV device */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
60 mousedev = SDL_getenv("SDL_MOUSEDEV");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
61 if (!mousedev) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
62 handle = open(mousedev, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
63 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
64
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
65 /* Failed, try default device */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
66 if (handle < 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
67 handle = open(DEVICE_NAME, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
68 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
69
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
70 if (handle < 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
71 handle = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
72 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
73 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
74
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
75 /* Set non blocking mode */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
76 r = fcntl(handle, F_GETFL, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
77 if (r < 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
78 close(handle);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
79 handle = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
80 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
81 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
82
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
83 r |= O_NDELAY;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
84
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
85 r = fcntl(handle, F_SETFL, r);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
86 if (r < 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
87 close(handle);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
88 handle = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
89 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
90 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
91
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
92 prev_mouseb = 7;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
93 return 1;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
94 }
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
95
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
96 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
97 SDL_AtariDevMouse_Close(void)
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
98 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
99 if (handle > 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
100 close(handle);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
101 handle = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
102 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
103 }
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
104
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
105 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
106 atari_GetButton(int button)
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
107 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
108 switch (button) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
109 case 0:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
110 return SDL_BUTTON_RIGHT;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
111 case 1:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
112 return SDL_BUTTON_MIDDLE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
113 default:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
114 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
115 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
116
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
117 return SDL_BUTTON_LEFT;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
118 }
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
119
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
120 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
121 SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents)
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
122 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
123 unsigned char buffer[3];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
124 int mousex, mousey;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
125
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
126 if (handle < 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
127 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
128 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
129
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
130 mousex = mousey = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
131 while (read(handle, buffer, sizeof(buffer)) == sizeof(buffer)) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
132 mouseb = buffer[0] & 7;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
133 mousex += (char) buffer[1];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
134 mousey += (char) buffer[2];
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
135
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
136 /* Mouse button events */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
137 if (buttonEvents && (mouseb != prev_mouseb)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
138 int i;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
139
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
140 for (i = 0; i < 3; i++) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
141 int curbutton, prevbutton;
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
142
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
143 curbutton = mouseb & (1 << i);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
144 prevbutton = prev_mouseb & (1 << i);
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
145
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
146 if (curbutton && !prevbutton) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
147 SDL_PrivateMouseButton(SDL_RELEASED,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
148 atari_GetButton(i), 0, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
149 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
150 if (!curbutton && prevbutton) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
151 SDL_PrivateMouseButton(SDL_PRESSED,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
152 atari_GetButton(i), 0, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
153 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
154 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
155
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
156 prev_mouseb = mouseb;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
157 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
158 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
159
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
160 /* Mouse motion event */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
161 if (mousex || mousey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1662
diff changeset
162 SDL_PrivateMouseMotion(0, 1, mousex, -mousey);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
163 }
1420
2405517b5eab Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
164 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
165
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1420
diff changeset
166 /* vi: set ts=4 sw=4 expandtab: */