Mercurial > sdl-ios-xcode
annotate src/events/SDL_touch.c @ 4642:057e8762d2a1
Added reading of event* for touch events.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Fri, 28 May 2010 01:26:52 -0400 |
parents | 49a97daea6ec |
children | 8806b78988f7 |
rev | line source |
---|---|
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
1 /* |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 1997-2010 Sam Lantinga |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
4 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
9 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
14 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
18 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
21 */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
23 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
24 /* General touch handling code for SDL */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
25 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
26 #include "SDL_events.h" |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
27 #include "SDL_events_c.h" |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
28 #include "../video/SDL_sysvideo.h" |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
29 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
30 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
31 static int SDL_num_touch = 0; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
32 static SDL_Touch **SDL_touchPads = NULL; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
33 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
34 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
35 /* Public functions */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
36 int |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
37 SDL_TouchInit(void) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
38 { |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
39 SDL_Touch touch; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
40 touch.pressure_max = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
41 touch.pressure_min = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
42 touch.id = 0; //Should be function? |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
43 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
44 SDL_AddTouch(&touch, "Touch1"); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
45 return (0); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
46 } |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
47 |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
48 SDL_Touch * |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
49 SDL_GetTouch(int id) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
50 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
51 int index = SDL_GetTouchIndexId(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
52 if (index < 0 || index >= SDL_num_touch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
53 return NULL; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
54 } |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
55 return SDL_touchPads[index]; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
56 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
57 |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
58 SDL_Touch * |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
59 SDL_GetTouchIndex(int index) |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
60 { |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
61 if (index < 0 || index >= SDL_num_touch) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
62 return NULL; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
63 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
64 return SDL_touchPads[index]; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
65 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
66 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
67 int |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
68 SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid) |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
69 { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
70 int i; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
71 for(i = 0;i < touch->num_fingers;i++) |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
72 if(touch->fingers[i]->id == fingerid) |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
73 return i; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
74 return -1; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
75 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
76 |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
77 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
78 SDL_Finger * |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
79 SDL_GetFinger(SDL_Touch* touch,int id) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
80 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
81 int index = SDL_GetFingerIndexId(touch,id); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
82 if(index < 0 || index >= touch->num_fingers) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
83 return NULL; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
84 return touch->fingers[index]; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
85 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
86 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
87 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
88 int |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
89 SDL_GetTouchIndexId(int id) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
90 { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
91 int index; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
92 SDL_Touch *touch; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
93 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
94 for (index = 0; index < SDL_num_touch; ++index) { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
95 touch = SDL_touchPads[index]; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
96 if (touch->id == id) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
97 return index; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
98 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
99 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
100 return -1; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
101 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
102 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
103 int |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
104 SDL_AddTouch(const SDL_Touch * touch, char *name) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
105 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
106 SDL_Touch **touchPads; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
107 int selected_touch; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
108 int index; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
109 size_t length; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
110 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
111 if (SDL_GetTouchIndexId(touch->id) != -1) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
112 SDL_SetError("Touch ID already in use"); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
113 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
114 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
115 /* Add the touch to the list of touch */ |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
116 touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads, |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
117 (SDL_num_touch + 1) * sizeof(*touch)); |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
118 if (!touchPads) { |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
119 SDL_OutOfMemory(); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
120 return -1; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
121 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
122 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
123 SDL_touchPads = touchPads; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
124 index = SDL_num_touch++; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
125 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
126 SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index])); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
127 if (!SDL_touchPads[index]) { |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
128 SDL_OutOfMemory(); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
129 return -1; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
130 } |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
131 *SDL_touchPads[index] = *touch; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
132 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
133 /* we're setting the touch properties */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
134 length = 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
135 length = SDL_strlen(name); |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
136 SDL_touchPads[index]->focus = 0; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
137 SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char)); |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
138 SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
139 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
140 SDL_touchPads[index]->num_fingers = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
141 SDL_touchPads[index]->buttonstate = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
142 SDL_touchPads[index]->relative_mode = SDL_FALSE; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
143 SDL_touchPads[index]->flush_motion = SDL_FALSE; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
144 |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
145 return index; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
146 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
147 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
148 void |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
149 SDL_DelTouch(int id) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
150 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
151 int index = SDL_GetTouchIndexId(id); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
152 SDL_Touch *touch = SDL_GetTouch(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
153 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
154 if (!touch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
155 return; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
156 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
157 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
158 |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
159 SDL_free(touch->name); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
160 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
161 if (touch->FreeTouch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
162 touch->FreeTouch(touch); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
163 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
164 SDL_free(touch); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
165 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
166 SDL_num_touch--; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
167 SDL_touchPads[index] = SDL_touchPads[SDL_num_touch]; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
168 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
169 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
170 void |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
171 SDL_TouchQuit(void) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
172 { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
173 int i; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
174 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
175 for (i = SDL_num_touch-1; i > 0 ; --i) { |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
176 SDL_DelTouch(i); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
177 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
178 SDL_num_touch = 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
179 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
180 if (SDL_touchPads) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
181 SDL_free(SDL_touchPads); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
182 SDL_touchPads = NULL; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
183 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
184 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
185 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
186 int |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
187 SDL_GetNumTouch(void) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
188 { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
189 return SDL_num_touch; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
190 } |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
191 SDL_Window * |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
192 SDL_GetTouchFocusWindow(int id) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
193 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
194 SDL_Touch *touch = SDL_GetTouch(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
195 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
196 if (!touch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
197 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
198 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
199 return touch->focus; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
200 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
201 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
202 void |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
203 SDL_SetTouchFocus(int id, SDL_Window * window) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
204 { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
205 int index = SDL_GetTouchIndexId(id); |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
206 SDL_Touch *touch = SDL_GetTouch(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
207 int i; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
208 SDL_bool focus; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
209 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
210 if (!touch || (touch->focus == window)) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
211 return; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
212 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
213 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
214 /* See if the current window has lost focus */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
215 if (touch->focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
216 focus = SDL_FALSE; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
217 for (i = 0; i < SDL_num_touch; ++i) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
218 SDL_Touch *check; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
219 if (i != index) { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
220 check = SDL_touchPads[i]; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
221 if (check && check->focus == touch->focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
222 focus = SDL_TRUE; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
223 break; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
224 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
225 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
226 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
227 if (!focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
228 SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_LEAVE, 0, 0); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
229 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
230 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
231 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
232 touch->focus = window; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
233 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
234 if (touch->focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
235 focus = SDL_FALSE; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
236 for (i = 0; i < SDL_num_touch; ++i) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
237 SDL_Touch *check; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
238 if (i != index) { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
239 check = SDL_touchPads[i]; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
240 if (check && check->focus == touch->focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
241 focus = SDL_TRUE; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
242 break; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
243 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
244 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
245 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
246 if (!focus) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
247 SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_ENTER, 0, 0); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
248 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
249 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
250 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
251 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
252 int |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
253 SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
254 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
255 int index; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
256 SDL_Finger **fingers; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
257 size_t length; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
258 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
259 if (SDL_GetFingerIndexId(touch,finger->id) != -1) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
260 SDL_SetError("Finger ID already in use"); |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
261 } |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
262 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
263 /* Add the touch to the list of touch */ |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
264 fingers = (SDL_Finger **) SDL_realloc(touch->fingers, |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
265 (touch->num_fingers + 1) * sizeof(*touch)); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
266 if (!fingers) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
267 SDL_OutOfMemory(); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
268 return -1; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
269 } |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
270 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
271 touch->fingers = fingers; |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
272 index = touch->num_fingers++; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
273 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
274 touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index]))); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
275 if (!touch->fingers[index]) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
276 SDL_OutOfMemory(); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
277 return -1; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
278 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
279 *touch->fingers[index] = *finger; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
280 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
281 return index; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
282 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
283 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
284 int |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
285 SDL_DelFinger(SDL_Touch* touch,int fingerid) |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
286 { |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
287 int index = SDL_GetFingerIndexId(touch,fingerid); |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
288 SDL_Finger* finger = SDL_GetFinger(touch,fingerid); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
289 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
290 if (!finger) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
291 return; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
292 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
293 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
294 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
295 SDL_free(finger); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
296 touch->num_fingers--; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
297 touch->fingers[index] = touch->fingers[touch->num_fingers]; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
298 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
299 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
300 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
301 int |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
302 SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure) |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
303 { |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
304 int posted; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
305 SDL_Touch* touch = SDL_GetTouch(id); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
306 if(down) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
307 SDL_Finger nf; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
308 nf.id = id; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
309 nf.x = x; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
310 nf.y = y; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
311 nf.pressure = pressure; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
312 nf.xdelta = 0; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
313 nf.ydelta = 0; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
314 nf.last_x = x; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
315 nf.last_y = y; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
316 SDL_AddFinger(touch,&nf); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
317 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
318 posted = 0; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
319 if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
320 SDL_Event event; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
321 event.tfinger.type = SDL_FINGERDOWN; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
322 event.tfinger.touchId = (Uint8) id; |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
323 event.tfinger.x = x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
324 event.tfinger.y = y; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
325 event.tfinger.state = touch->buttonstate; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
326 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
327 event.tfinger.fingerId = id; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
328 posted = (SDL_PushEvent(&event) > 0); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
329 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
330 return posted; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
331 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
332 else { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
333 SDL_DelFinger(touch,id); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
334 posted = 0; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
335 if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) { |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
336 SDL_Event event; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
337 event.tfinger.type = SDL_FINGERUP; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
338 event.tfinger.touchId = (Uint8) id; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
339 event.tfinger.state = touch->buttonstate; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
340 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
341 event.tfinger.fingerId = id; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
342 posted = (SDL_PushEvent(&event) > 0); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
343 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
344 return posted; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
345 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
346 } |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
347 |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
348 int |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
349 SDL_SendTouchMotion(int id, int fingerid, int relative, |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
350 int x, int y, int pressure) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
351 { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
352 int index = SDL_GetTouchIndexId(id); |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
353 SDL_Touch *touch = SDL_GetTouch(id); |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
354 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
355 int posted; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
356 int xrel; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
357 int yrel; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
358 int x_max = 0, y_max = 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
359 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
360 if (!touch || touch->flush_motion) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
361 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
362 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
363 |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
364 if(finger == NULL) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
365 SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
366 else { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
367 /* the relative motion is calculated regarding the last position */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
368 if (relative) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
369 xrel = x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
370 yrel = y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
371 x = (finger->last_x + x); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
372 y = (finger->last_y + y); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
373 } else { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
374 if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
375 if(y < 0) y = finger->last_y; /*The other is marked as -1*/ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
376 xrel = x - finger->last_x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
377 yrel = y - finger->last_y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
378 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
379 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
380 /* Drop events that don't change state */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
381 if (!xrel && !yrel) { |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
382 #if 0 |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
383 printf("Touch event didn't change state - dropped!\n"); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
384 #endif |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
385 return 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
386 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
387 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
388 /* Update internal touch coordinates */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
389 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
390 finger->x = x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
391 finger->y = y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
392 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
393 /*Should scale to window? Normalize? Maintain Aspect?*/ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
394 //SDL_GetWindowSize(touch->focus, &x_max, &y_max); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
395 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
396 /* make sure that the pointers find themselves inside the windows */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
397 /* only check if touch->xmax is set ! */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
398 /* |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
399 if (x_max && touch->x > x_max) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
400 touch->x = x_max; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
401 } else if (touch->x < 0) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
402 touch->x = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
403 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
404 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
405 if (y_max && touch->y > y_max) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
406 touch->y = y_max; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
407 } else if (touch->y < 0) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
408 touch->y = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
409 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
410 */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
411 finger->xdelta += xrel; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
412 finger->ydelta += yrel; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
413 finger->pressure = pressure; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
414 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
415 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
416 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
417 /* Post the event, if desired */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
418 posted = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
419 if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
420 SDL_Event event; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
421 event.tfinger.type = SDL_FINGERMOTION; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
422 event.tfinger.touchId = (Uint8) index; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
423 event.tfinger.x = x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
424 event.tfinger.y = y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
425 event.tfinger.state = touch->buttonstate; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
426 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
427 posted = (SDL_PushEvent(&event) > 0); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
428 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
429 finger->last_x = finger->x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
430 finger->last_y = finger->y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
431 return posted; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
432 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
433 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
434 int |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
435 SDL_SendTouchButton(int id, Uint8 state, Uint8 button) |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
436 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
437 SDL_Touch *touch = SDL_GetTouch(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
438 int posted; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
439 Uint32 type; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
440 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
441 if (!touch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
442 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
443 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
444 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
445 /* Figure out which event to perform */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
446 switch (state) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
447 case SDL_PRESSED: |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
448 if (touch->buttonstate & SDL_BUTTON(button)) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
449 /* Ignore this event, no state change */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
450 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
451 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
452 type = SDL_TOUCHBUTTONDOWN; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
453 touch->buttonstate |= SDL_BUTTON(button); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
454 break; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
455 case SDL_RELEASED: |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
456 if (!(touch->buttonstate & SDL_BUTTON(button))) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
457 /* Ignore this event, no state change */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
458 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
459 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
460 type = SDL_TOUCHBUTTONUP; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
461 touch->buttonstate &= ~SDL_BUTTON(button); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
462 break; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
463 default: |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
464 /* Invalid state -- bail */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
465 return 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
466 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
467 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
468 /* Post the event, if desired */ |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
469 posted = 0; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
470 if (SDL_GetEventState(type) == SDL_ENABLE) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
471 SDL_Event event; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
472 event.type = type; |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4641
diff
changeset
|
473 event.tbutton.touchId = (Uint8) index; |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
474 event.tbutton.state = state; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
475 event.tbutton.button = button; |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
476 event.tbutton.windowID = touch->focus ? touch->focus->id : 0; |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
477 posted = (SDL_PushEvent(&event) > 0); |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
478 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
479 return posted; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
480 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
481 |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
482 char * |
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
483 SDL_GetTouchName(int id) |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
484 { |
4641
49a97daea6ec
Added touch event definitions. Heavily modified events/SDL_touch*.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
485 SDL_Touch *touch = SDL_GetTouch(id); |
4640
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
486 if (!touch) { |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
487 return NULL; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
488 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
489 return touch->name; |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
490 } |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
491 |
f068a6dfc858
Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
492 /* vi: set ts=4 sw=4 expandtab: */ |