Mercurial > sdl-ios-xcode
annotate src/events/SDL_mouse.c @ 3777:54d08ecec1cb gsoc2008_manymouse
Sharpened code looks and a minor events upgrade
author | Szymon Wilczek <kazeuser@gmail.com> |
---|---|
date | Wed, 06 Aug 2008 09:29:32 +0000 |
parents | a9c2a7071874 |
children | a9370b995ded |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* General mouse handling code for SDL */ | |
25 | |
26 #include "SDL_events.h" | |
27 #include "SDL_events_c.h" | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
28 #include "default_cursor.h" |
0 | 29 |
30 | |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
31 static int SDL_num_mice=0; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
32 static int SDL_current_mouse=-1; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
33 static SDL_Mouse **SDL_mice=NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
34 static int *SDL_IdIndex=NULL; |
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
35 static int SDL_highestId=-1; |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
36 static int last_x, last_y;/*the last reported x and y coordinates by the system cursor*/ |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
37 int x_max, y_max; /*current window width and height*/ |
0 | 38 /* Public functions */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
39 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
40 SDL_MouseInit(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
41 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
42 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
43 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
44 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
45 SDL_Mouse * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
46 SDL_GetMouse(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
47 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
48 if (index < 0 || index >= SDL_num_mice) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
49 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
50 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
51 return SDL_mice[index]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
52 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
53 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
54 int |
3774 | 55 SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,\ |
56 int pressure_min, int ends) | |
0 | 57 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
58 SDL_Mouse **mice; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
59 int selected_mouse; |
3769 | 60 int length; |
61 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
62 /* Add the mouse to the list of mice */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
63 if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
64 mice = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
65 (SDL_Mouse **) SDL_realloc(SDL_mice, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
66 (SDL_num_mice + 1) * sizeof(*mice)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
67 if (!mice) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
68 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
69 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
70 } |
0 | 71 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
72 SDL_mice = mice; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
73 index = SDL_num_mice++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
74 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
75 SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index])); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
76 if (!SDL_mice[index]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
77 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
78 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
79 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
80 *SDL_mice[index] = *mouse; |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
81 |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
82 /*we're setting the mouse properties*/ |
3769 | 83 length=0; |
84 length=SDL_strlen(name); | |
85 SDL_mice[index]->name=SDL_malloc((length+1)*sizeof(char)); | |
86 SDL_strlcpy(SDL_mice[index]->name,name,length); | |
3766
24db5d326f57
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents:
3765
diff
changeset
|
87 SDL_mice[index]->pressure_max=pressure_max; |
24db5d326f57
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents:
3765
diff
changeset
|
88 SDL_mice[index]->pressure_min=pressure_min; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
89 SDL_mice[index]->cursor_shown = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
90 selected_mouse = SDL_SelectMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
91 SDL_mice[index]->cur_cursor = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
92 SDL_mice[index]->def_cursor = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
93 SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
94 DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
95 SDL_SetCursor(SDL_mice[index]->def_cursor); |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
96 /*we're assuming that all mouses are in the computer sensing zone*/ |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
97 SDL_mice[index]->proximity=SDL_TRUE; |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
98 /*we're assuming that all mouses are working in the absolute position mode |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
99 thanx to that, the users that don't want to use many mouses don't have to |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
100 worry about anything*/ |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
101 SDL_mice[index]->relative_mode=SDL_FALSE; |
3774 | 102 SDL_mice[index]->current_end=0; |
103 SDL_mice[index]->total_ends=ends; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
104 SDL_SelectMouse(selected_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
105 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
106 return index; |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
943
diff
changeset
|
107 } |
0 | 108 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
109 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
110 SDL_DelMouse(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
111 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
112 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
113 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
114 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
115 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
116 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
117 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
118 mouse->def_cursor = NULL; |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
119 SDL_free(mouse->name); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
120 while (mouse->cursors) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
121 SDL_FreeCursor(mouse->cursors); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
122 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
123 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
124 if (mouse->FreeMouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
125 mouse->FreeMouse(mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
126 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
127 SDL_free(mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
128 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
129 SDL_mice[index] = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
130 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
131 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
132 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
133 SDL_ResetMouse(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
134 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
135 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
136 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
137 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
138 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
139 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
140 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
141 /* FIXME */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
142 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
143 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
144 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
145 SDL_MouseQuit(void) |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
146 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
147 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
148 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
149 for (i = 0; i < SDL_num_mice; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
150 SDL_DelMouse(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
151 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
152 SDL_num_mice = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
153 SDL_current_mouse = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
154 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
155 if (SDL_mice) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
156 SDL_free(SDL_mice); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
157 SDL_mice = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
158 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
159 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
160 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
161 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
162 SDL_GetNumMice(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
163 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
164 return SDL_num_mice; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
165 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
166 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
167 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
168 SDL_SelectMouse(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
169 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
170 if (index >= 0 && index < SDL_num_mice) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
171 SDL_current_mouse = index; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
172 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
173 return SDL_current_mouse; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
174 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
175 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
176 SDL_WindowID |
3776 | 177 SDL_GetMouseFocusWindow(int index) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
178 { |
3776 | 179 SDL_Mouse *mouse = SDL_GetMouse(index); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
180 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
181 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
182 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
183 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
184 return mouse->focus; |
460
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
185 } |
a888b3ae31ff
Reset mouse state when changing video modes
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
186 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
187 static int SDLCALL |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
188 FlushMouseMotion(void *param, SDL_Event * event) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
189 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
190 if (event->type == SDL_MOUSEMOTION |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
191 && event->motion.which == (Uint8) SDL_current_mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
192 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
193 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
194 return 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
195 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
196 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
197 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
198 int |
3776 | 199 SDL_SetRelativeMouseMode(int index, SDL_bool enabled) |
0 | 200 { |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
201 SDL_Mouse *mouse = SDL_GetMouse(index); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
202 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
203 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
204 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
205 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
206 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
207 /* Flush pending mouse motion */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
208 mouse->flush_motion = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
209 SDL_PumpEvents(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
210 mouse->flush_motion = SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
211 SDL_FilterEvents(FlushMouseMotion, mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
212 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
213 /* Set the relative mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
214 mouse->relative_mode = enabled; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
215 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
216 /* Update cursor visibility */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
217 SDL_SetCursor(NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
218 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
219 if (!enabled) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
220 /* Restore the expected mouse position */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
221 SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
222 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
223 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
224 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
225 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
226 SDL_bool |
3776 | 227 SDL_GetRelativeMouseMode(int index) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
228 { |
3776 | 229 SDL_Mouse *mouse = SDL_GetMouse(index); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
230 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
231 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
232 return SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
233 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
234 return mouse->relative_mode; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
235 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
236 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
237 Uint8 |
3776 | 238 SDL_GetMouseState(int index, int *x, int *y) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
239 { |
3776 | 240 SDL_Mouse *mouse = SDL_GetMouse(index); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
241 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
242 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
243 if (x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
244 *x = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
245 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
246 if (y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
247 *y = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
248 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
249 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
250 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
251 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
252 if (x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
253 *x = mouse->x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
254 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
255 if (y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
256 *y = mouse->y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
257 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
258 return mouse->buttonstate; |
0 | 259 } |
260 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
261 Uint8 |
3776 | 262 SDL_GetRelativeMouseState(int index, int *x, int *y) |
0 | 263 { |
3776 | 264 SDL_Mouse *mouse = SDL_GetMouse(index); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
265 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
266 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
267 if (x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
268 *x = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
269 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
270 if (y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
271 *y = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
272 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
273 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
274 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
275 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
276 if (x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
277 *x = mouse->xdelta; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
278 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
279 if (y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
280 *y = mouse->ydelta; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
281 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
282 mouse->xdelta = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
283 mouse->ydelta = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
284 return mouse->buttonstate; |
0 | 285 } |
286 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
287 void |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
288 SDL_SetMouseFocus(int id, SDL_WindowID windowID) |
0 | 289 { |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
290 int index = SDL_GetIndexById(id); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
291 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
292 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
293 SDL_bool focus; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
294 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
295 if (!mouse || (mouse->focus == windowID)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
296 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
297 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
298 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
299 /* See if the current window has lost focus */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
300 if (mouse->focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
301 focus = SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
302 for (i = 0; i < SDL_num_mice; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
303 SDL_Mouse *check; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
304 if (i != index) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
305 check = SDL_GetMouse(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
306 if (check && check->focus == mouse->focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
307 focus = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
308 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
309 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
310 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
311 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
312 if (!focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
313 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
314 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
315 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
316 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
317 mouse->focus = windowID; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
318 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
319 if (mouse->focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
320 focus = SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
321 for (i = 0; i < SDL_num_mice; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
322 SDL_Mouse *check; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
323 if (i != index) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
324 check = SDL_GetMouse(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
325 if (check && check->focus == mouse->focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
326 focus = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
327 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
328 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
329 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
330 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
331 if (!focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
332 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
333 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
334 } |
0 | 335 } |
336 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
337 int |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
338 SDL_SendProximity(int id, int x, int y, int type) |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
339 { |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
340 int index=SDL_GetIndexById(id); |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
341 SDL_Mouse* mouse=SDL_GetMouse(index); |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
342 int posted=0; |
3770
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3769
diff
changeset
|
343 last_x=x; |
81b649bad6d2
Implementation finished
Szymon Wilczek <kazeuser@gmail.com>
parents:
3769
diff
changeset
|
344 last_y=y; |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
345 if(SDL_ProcessEvents[type]==SDL_ENABLE) |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
346 { |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
347 SDL_Event event; |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
348 event.proximity.which=(Uint8)index; |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
349 event.proximity.x=x; |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
350 event.proximity.y=y; |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
351 event.proximity.cursor=mouse->current_end; |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
352 event.type=type; |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
353 event.proximity.type=type; |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
354 posted = (SDL_PushEvent(&event) > 0); |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
355 if(type==SDL_PROXIMITYIN) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
356 { |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
357 mouse->proximity=SDL_TRUE; |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
358 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
359 else |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
360 { |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
361 mouse->proximity=SDL_FALSE; |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
362 } |
3763
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
363 } |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
364 return posted; |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
365 } |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
366 |
81ea7d9a6624
Proximity events and evil-temporary makefile repair
Szymon Wilczek <kazeuser@gmail.com>
parents:
3760
diff
changeset
|
367 int |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
368 SDL_SendMouseMotion(int id, int relative, int x, int y,int pressure) |
0 | 369 { |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
370 int index=SDL_GetIndexById(id); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
371 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
372 int posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
373 int xrel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
374 int yrel; |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
375 /*while using the relative mode and many windows, we have to be sure, |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
376 that the pointers find themselves inside the windows*/ |
3769 | 377 if(x>x_max) |
378 { | |
379 x=x_max; | |
380 } | |
381 if(y>y_max) | |
382 { | |
383 y=y_max; | |
384 } | |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
385 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
386 if (!mouse || mouse->flush_motion) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
387 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
388 } |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
389 |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
390 /*if the mouse is out of proximity we don't to want to have any motion from it*/ |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
391 if(mouse->proximity==SDL_FALSE) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
392 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
393 last_x=x; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
394 last_y=y; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
395 return 0; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
396 } |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
397 |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
398 /*the relative motion is calculated regarding the system cursor last position*/ |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
399 |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
400 xrel = x - last_x; |
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
401 yrel = y - last_y; |
0 | 402 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
403 /* Drop events that don't change state */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
404 if (!xrel && !yrel) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
405 #if 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
406 printf("Mouse event didn't change state - dropped!\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
407 #endif |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
408 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
409 } |
0 | 410 |
3771
8cc36a399a12
comments added and improved code look(windows part)
Szymon Wilczek <kazeuser@gmail.com>
parents:
3770
diff
changeset
|
411 /* Update internal mouse coordinates */ |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
412 if (mouse->relative_mode==SDL_FALSE) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
413 mouse->x = x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
414 mouse->y = y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
415 } |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
416 else |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
417 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
418 if(mouse->x+xrel>x_max) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
419 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
420 mouse->x=x_max; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
421 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
422 else if(mouse->x+xrel<0) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
423 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
424 mouse->x=0; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
425 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
426 else |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
427 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
428 mouse->x+=xrel; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
429 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
430 if(mouse->y+yrel>y_max) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
431 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
432 mouse->y=y_max; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
433 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
434 else if(mouse->y+yrel<0) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
435 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
436 mouse->y=0; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
437 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
438 else |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
439 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
440 mouse->y+=yrel; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
441 } |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
442 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
443 mouse->xdelta += xrel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
444 mouse->ydelta += yrel; |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
445 mouse->pressure=pressure; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
446 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
447 /* Move the mouse cursor, if needed */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
448 if (mouse->cursor_shown && !mouse->relative_mode && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
449 mouse->MoveCursor && mouse->cur_cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
450 mouse->MoveCursor(mouse->cur_cursor); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
451 } |
0 | 452 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
453 /* Post the event, if desired */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
454 posted = 0; |
3777
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
455 if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && \ |
54d08ecec1cb
Sharpened code looks and a minor events upgrade
Szymon Wilczek <kazeuser@gmail.com>
parents:
3776
diff
changeset
|
456 mouse->proximity==SDL_TRUE) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
457 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
458 event.motion.type = SDL_MOUSEMOTION; |
3769 | 459 event.motion.which = (Uint8) index; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
460 event.motion.state = mouse->buttonstate; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
461 event.motion.x = mouse->x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
462 event.motion.y = mouse->y; |
3765
ed9b7fe8f902
Estethic changes noted on the SDL meeting 05.07.08
Szymon Wilczek <kazeuser@gmail.com>
parents:
3764
diff
changeset
|
463 event.motion.pressure= mouse->pressure; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
464 event.motion.xrel = xrel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
465 event.motion.yrel = yrel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
466 event.motion.windowID = mouse->focus; |
3766
24db5d326f57
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents:
3765
diff
changeset
|
467 event.motion.pressure_max=mouse->pressure_max; |
24db5d326f57
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
Szymon Wilczek <kazeuser@gmail.com>
parents:
3765
diff
changeset
|
468 event.motion.pressure_min=mouse->pressure_min; |
3774 | 469 event.motion.cursor=SDL_mice[index]->current_end; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
470 posted = (SDL_PushEvent(&event) > 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
471 } |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
472 last_x=x; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
473 last_y=y; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
474 return posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
475 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
476 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
477 int |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
478 SDL_SendMouseButton(int id, Uint8 state, Uint8 button) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
479 { |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
480 int index=SDL_GetIndexById(id); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
481 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
482 int posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
483 Uint8 type; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
484 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
485 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
486 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
487 } |
0 | 488 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
489 /* Figure out which event to perform */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
490 switch (state) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
491 case SDL_PRESSED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
492 if (mouse->buttonstate & SDL_BUTTON(button)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
493 /* Ignore this event, no state change */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
494 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
495 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
496 type = SDL_MOUSEBUTTONDOWN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
497 mouse->buttonstate |= SDL_BUTTON(button); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
498 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
499 case SDL_RELEASED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
500 type = SDL_MOUSEBUTTONUP; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
501 mouse->buttonstate &= ~SDL_BUTTON(button); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
502 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
503 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
504 /* Invalid state -- bail */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
505 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
506 } |
0 | 507 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
508 /* Post the event, if desired */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
509 posted = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
510 if (SDL_ProcessEvents[type] == SDL_ENABLE) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
511 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
512 event.type = type; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
513 event.button.which = (Uint8) index; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
514 event.button.state = state; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
515 event.button.button = button; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
516 event.button.x = mouse->x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
517 event.button.y = mouse->y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
518 event.button.windowID = mouse->focus; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
519 posted = (SDL_PushEvent(&event) > 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
520 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
521 return posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
522 } |
1283
f214b6fae45a
Date: Fri, 14 Jan 2005 21:52:46 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
523 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
524 int |
2152 | 525 SDL_SendMouseWheel(int index, int x, int y) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
526 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
527 SDL_Mouse *mouse = SDL_GetMouse(index); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
528 int posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
529 |
2152 | 530 if (!mouse || (!x && !y)) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
531 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
532 } |
0 | 533 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
534 /* Post the event, if desired */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
535 posted = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
536 if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
537 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
538 event.type = SDL_MOUSEWHEEL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
539 event.wheel.which = (Uint8) index; |
2152 | 540 event.wheel.x = x; |
541 event.wheel.y = y; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
542 event.wheel.windowID = mouse->focus; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
543 posted = (SDL_PushEvent(&event) > 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
544 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
545 return posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
546 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
547 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
548 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
549 SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
550 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
551 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
552 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
553 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
554 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
555 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
556 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
557 if (mouse->WarpMouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
558 mouse->WarpMouse(mouse, windowID, x, y); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
559 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
560 SDL_SetMouseFocus(SDL_current_mouse, windowID); |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
561 SDL_SendMouseMotion(SDL_current_mouse, 0, x, y,0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
562 } |
0 | 563 } |
564 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
565 SDL_Cursor * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
566 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
567 int w, int h, int hot_x, int hot_y) |
0 | 568 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
569 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
570 SDL_Surface *surface; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
571 SDL_Cursor *cursor; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
572 int x, y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
573 Uint32 *pixel; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
574 Uint8 datab, maskb; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
575 const Uint32 black = 0xFF000000; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
576 const Uint32 white = 0xFFFFFFFF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
577 const Uint32 transparent = 0x00000000; |
0 | 578 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
579 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
580 SDL_SetError("No mice are initialized"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
581 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
582 } |
0 | 583 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
584 if (!mouse->CreateCursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
585 SDL_SetError("Current mouse doesn't have cursor support"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
586 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
587 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
588 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
589 /* Sanity check the hot spot */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
590 if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
591 SDL_SetError("Cursor hot spot doesn't lie within cursor"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
592 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
593 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
594 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
595 /* Make sure the width is a multiple of 8 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
596 w = ((w + 7) & ~7); |
0 | 597 |
3769 | 598 /* Create the surface from a bitmap*/ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
599 surface = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
600 SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
601 0xFF000000); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
602 if (!surface) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
603 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
604 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
605 for (y = 0; y < h; ++y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
606 pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
607 for (x = 0; x < w; ++x) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
608 if ((x % 8) == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
609 datab = *data++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
610 maskb = *mask++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
611 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
612 if (maskb & 0x80) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
613 *pixel++ = (datab & 0x80) ? black : white; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
614 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
615 *pixel++ = (datab & 0x80) ? black : transparent; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
616 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
617 datab <<= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
618 maskb <<= 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
619 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
620 } |
0 | 621 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
622 cursor = mouse->CreateCursor(surface, hot_x, hot_y); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
623 if (cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
624 cursor->mouse = mouse; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
625 cursor->next = mouse->cursors; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
626 mouse->cursors = cursor; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
627 } |
0 | 628 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
629 SDL_FreeSurface(surface); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
630 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
631 return cursor; |
0 | 632 } |
633 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
634 /* SDL_SetCursor(NULL) can be used to force the cursor redraw, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
635 if this is desired for any reason. This is used when setting |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
636 the video mode and when the SDL window gains the mouse focus. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
637 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
638 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
639 SDL_SetCursor(SDL_Cursor * cursor) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
640 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
641 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
642 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
643 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
644 SDL_SetError("No mice are initialized"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
645 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
646 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
647 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
648 /* Set the new cursor */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
649 if (cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
650 /* Make sure the cursor is still valid for this mouse */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
651 SDL_Cursor *found; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
652 for (found = mouse->cursors; found; found = found->next) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
653 if (found == cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
654 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
655 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
656 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
657 if (!found) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
658 SDL_SetError("Cursor not associated with the current mouse"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
659 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
660 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
661 mouse->cur_cursor = cursor; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
662 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
663 cursor = mouse->cur_cursor; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
664 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
665 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
666 if (cursor && mouse->cursor_shown && !mouse->relative_mode) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
667 if (mouse->ShowCursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
668 mouse->ShowCursor(cursor); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
669 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
670 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
671 if (mouse->ShowCursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
672 mouse->ShowCursor(NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
673 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
674 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
675 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
676 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
677 SDL_Cursor * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
678 SDL_GetCursor(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
679 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
680 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
681 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
682 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
683 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
684 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
685 return mouse->cur_cursor; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
686 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
687 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
688 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
689 SDL_FreeCursor(SDL_Cursor * cursor) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
690 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
691 SDL_Mouse *mouse; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
692 SDL_Cursor *curr, *prev; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
693 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
694 if (!cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
695 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
696 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
697 mouse = cursor->mouse; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
698 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
699 if (cursor == mouse->def_cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
700 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
701 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
702 if (cursor == mouse->cur_cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
703 SDL_SetCursor(mouse->def_cursor); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
704 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
705 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
706 for (prev = NULL, curr = mouse->cursors; curr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
707 prev = curr, curr = curr->next) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
708 if (curr == cursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
709 if (prev) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
710 prev->next = curr->next; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
711 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
712 mouse->cursors = curr->next; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
713 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
714 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
715 if (mouse->FreeCursor) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
716 mouse->FreeCursor(curr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
717 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
718 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
719 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
720 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
721 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
722 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
723 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
724 SDL_ShowCursor(int toggle) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
725 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
726 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
727 SDL_bool shown; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
728 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
729 if (!mouse) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
730 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
731 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
732 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
733 shown = mouse->cursor_shown; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
734 if (toggle >= 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
735 if (toggle) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
736 mouse->cursor_shown = SDL_TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
737 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
738 mouse->cursor_shown = SDL_FALSE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
739 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
740 if (mouse->cursor_shown != shown) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
741 SDL_SetCursor(NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
742 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
743 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
744 return shown; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
745 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
746 |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
747 int SDL_SetIndexId(int id, int index) |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
748 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
749 if(id>SDL_highestId) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
750 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
751 int *indexes; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
752 indexes = |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
753 (int*) SDL_realloc(SDL_IdIndex, |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
754 (id + 1) * sizeof(int)); |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
755 if (!indexes) { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
756 SDL_OutOfMemory(); |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
757 return -1; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
758 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
759 SDL_IdIndex=indexes; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
760 SDL_IdIndex[id]=index; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
761 SDL_highestId=id; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
762 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
763 else |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
764 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
765 SDL_IdIndex[id]=index; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
766 } |
3767
abc8acb8e3d7
Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3766
diff
changeset
|
767 return 1; |
3760
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
768 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
769 |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
770 int SDL_GetIndexById(int id) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
771 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
772 if(id>SDL_highestId) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
773 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
774 return -1; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
775 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
776 else |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
777 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
778 return SDL_IdIndex[id]; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
779 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
780 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
781 |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
782 int SDL_GetNumOfMice(void) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
783 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
784 return SDL_num_mice; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
785 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
786 |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
787 char* SDL_GetMouseName(int index) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
788 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
789 SDL_Mouse* mouse = SDL_GetMouse(index); |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
790 if(!mouse) |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
791 { |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
792 return NULL; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
793 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
794 return mouse->name; |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
795 } |
64f346a83ed3
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
Szymon Wilczek <kazeuser@gmail.com>
parents:
2152
diff
changeset
|
796 |
3764
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
797 void SDL_UpdateCoordinates(int x, int y) |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
798 { |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
799 x_max=x; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
800 y_max=y; |
2970fcfbdd54
Relative mode for tablets. Info on wiki.
Szymon Wilczek <kazeuser@gmail.com>
parents:
3763
diff
changeset
|
801 } |
3774 | 802 |
803 void SDL_ChangeEnd(int id, int end) | |
804 { | |
805 int index=SDL_GetIndexById(id); | |
806 SDL_mice[index]->current_end=end; | |
807 } | |
808 | |
809 int SDL_GetCursorsNumber(int index) | |
810 { | |
3776 | 811 SDL_Mouse* mouse = SDL_GetMouse(index); |
812 if(!mouse) | |
813 { | |
814 return -1; | |
815 } | |
816 return mouse->total_ends; | |
817 } | |
818 | |
819 int SDL_GetCurrentCursor(int index) | |
820 { | |
821 SDL_Mouse* mouse = SDL_GetMouse(index); | |
822 if(!mouse) | |
823 { | |
824 return -1; | |
825 } | |
826 return mouse->current_end; | |
3774 | 827 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1525
diff
changeset
|
828 /* vi: set ts=4 sw=4 expandtab: */ |
3769 | 829 |