Mercurial > sdl-ios-xcode
annotate src/video/android/SDL_androidtouch.c @ 5086:ac2c68eb1bb9
Fixed bug #1080
Markus Rathgeb 2011-01-23 14:34:23 PST
With kernel 2.6.31 the struct input_absinfo defined in linux/input.h changed.
A field "__s32 resolution" was added at the end of the struct.
Because the macro EVIOCGABS(abs) is using the struct input_absinfo, it would be
better (IMHO) to change the declaration of variable values to
"int values[sizeof(struct input_absinfo) / sizeof(int)];" or using "struct
input_absinfo" directly.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 24 Jan 2011 14:36:12 -0800 |
parents | 77df56570442 |
children | b530ef003506 |
rev | line source |
---|---|
5001
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2010 Sam Lantinga |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include <android/log.h> |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_events.h" |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "../../events/SDL_mouse_c.h" |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "SDL_androidtouch.h" |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #define ACTION_DOWN 0 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #define ACTION_UP 1 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #define ACTION_MOVE 2 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #define ACTION_CANCEL 3 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #define ACTION_OUTSIDE 4 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 void Android_OnTouch(int action, float x, float y, float p) |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 { |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 if (!Android_Window) { |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 return; |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 } |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 if ((action != ACTION_CANCEL) && (action != ACTION_OUTSIDE)) { |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 SDL_SetMouseFocus(Android_Window); |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 SDL_SendMouseMotion(Android_Window, 0, (int)x, (int)y); |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 switch(action) { |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 case ACTION_DOWN: |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 SDL_SendMouseButton(Android_Window, SDL_PRESSED, SDL_BUTTON_LEFT); |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 break; |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 case ACTION_UP: |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 SDL_SendMouseButton(Android_Window, SDL_RELEASED, SDL_BUTTON_LEFT); |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 break; |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 } |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 } else { |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 SDL_SetMouseFocus(NULL); |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 } |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 } |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
77df56570442
Added "mouse" support for the Android touch screen
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 /* vi: set ts=4 sw=4 expandtab: */ |