author | Xeli |
Sat, 12 Nov 2011 14:52:48 +0100 | |
branch | hedgeroid |
changeset 6234 | 1323a3681327 |
parent 5550 | 50650032c251 |
permissions | -rw-r--r-- |
5540 | 1 |
/* |
2 |
SDL - Simple DirectMedia Layer |
|
3 |
Copyright (C) 1997-2011 Sam Lantinga |
|
4 |
||
5 |
This library is free software; you can redistribute it and/or |
|
6 |
modify it under the terms of the GNU Lesser General Public |
|
7 |
License as published by the Free Software Foundation; either |
|
8 |
version 2.1 of the License, or (at your option) any later version. |
|
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 |
|
13 |
Lesser General Public License for more details. |
|
14 |
||
15 |
You should have received a copy of the GNU Lesser General Public |
|
16 |
License along with this library; if not, write to the Free Software |
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
||
19 |
Sam Lantinga |
|
20 |
slouken@libsdl.org |
|
21 |
*/ |
|
22 |
#include "SDL_config.h" |
|
23 |
||
24 |
#include <android/log.h> |
|
25 |
||
26 |
#include "SDL_events.h" |
|
27 |
#include "../../events/SDL_touch_c.h" |
|
28 |
||
29 |
#include "SDL_androidtouch.h" |
|
5550
50650032c251
Zoom and moving the camera now works with SDL_FINGER* events
Xeli
parents:
5540
diff
changeset
|
30 |
#include "stdlib.h" |
5540 | 31 |
|
32 |
#define ACTION_DOWN 0 |
|
33 |
#define ACTION_UP 1 |
|
34 |
#define ACTION_MOVE 2 |
|
35 |
#define ACTION_CANCEL 3 |
|
36 |
#define ACTION_OUTSIDE 4 |
|
37 |
#define ACTION_POINTER_DOWN 5 |
|
38 |
#define ACTION_POINTER_UP 6 |
|
39 |
||
40 |
||
5550
50650032c251
Zoom and moving the camera now works with SDL_FINGER* events
Xeli
parents:
5540
diff
changeset
|
41 |
void Android_OnTouch(int action, SDL_FingerID pointerId, float x, float y, float p) |
5540 | 42 |
{ |
43 |
if (!Android_Window) { |
|
44 |
return; |
|
45 |
} |
|
46 |
||
47 |
//The first event will provide the x, y and pressure max values, |
|
48 |
if(!SDL_GetTouch(1)){ |
|
49 |
SDL_Touch touch; |
|
50 |
touch.id = 1; |
|
51 |
touch.x_min = 0; |
|
52 |
touch.x_max = x; |
|
53 |
touch.native_xres = touch.x_max - touch.x_min; |
|
54 |
touch.y_min = 0; |
|
55 |
touch.y_max = y; |
|
56 |
touch.native_yres = touch.y_max - touch.y_min; |
|
57 |
touch.pressure_min = 0; |
|
58 |
touch.pressure_max = p; |
|
59 |
touch.native_pressureres = touch.pressure_max - touch.pressure_min; |
|
60 |
||
61 |
if(SDL_AddTouch(&touch, "") < 0) return; |
|
62 |
} |
|
63 |
||
64 |
switch(action){ |
|
65 |
case ACTION_DOWN: |
|
66 |
case ACTION_POINTER_DOWN: |
|
67 |
SDL_SetTouchFocus(pointerId, Android_Window); |
|
68 |
SDL_SendFingerDown(1, pointerId, SDL_TRUE, x, y, p); |
|
69 |
break; |
|
70 |
case ACTION_CANCEL: |
|
71 |
case ACTION_POINTER_UP: |
|
72 |
case ACTION_UP: |
|
73 |
SDL_SendFingerDown(1, pointerId, SDL_FALSE, x, y, p); |
|
74 |
break; |
|
75 |
case ACTION_MOVE: |
|
76 |
SDL_SendTouchMotion(1, pointerId, 0, x, y, p); |
|
77 |
break; |
|
78 |
case ACTION_OUTSIDE: |
|
79 |
break; |
|
80 |
} |
|
81 |
} |
|
82 |
||
83 |
/* vi: set ts=4 sw=4 expandtab: */ |