comparison src/video/uikit/SDL_uikitview.m @ 4677:31607094315c

Added Iphone project. Iphone multi-touch is now functional.
author jimtla
date Sat, 31 Jul 2010 01:24:50 +0400
parents 3c4e0130c9b1
children f8431f66613d
comparison
equal deleted inserted replaced
4676:99b4560b7aa1 4677:31607094315c
22 22
23 #import "SDL_uikitview.h" 23 #import "SDL_uikitview.h"
24 24
25 #include "../../events/SDL_keyboard_c.h" 25 #include "../../events/SDL_keyboard_c.h"
26 #include "../../events/SDL_mouse_c.h" 26 #include "../../events/SDL_mouse_c.h"
27 #include "../../events/SDL_touch_c.h"
27 28
28 #if SDL_IPHONE_KEYBOARD 29 #if SDL_IPHONE_KEYBOARD
29 #import "keyinfotable.h" 30 #import "keyinfotable.h"
30 #import "SDL_uikitappdelegate.h" 31 #import "SDL_uikitappdelegate.h"
31 #import "SDL_uikitwindow.h" 32 #import "SDL_uikitwindow.h"
46 47
47 #if SDL_IPHONE_KEYBOARD 48 #if SDL_IPHONE_KEYBOARD
48 [self initializeKeyboard]; 49 [self initializeKeyboard];
49 #endif 50 #endif
50 51
51 #if FIXED_MULTITOUCH 52 #ifdef FIXED_MULTITOUCH
52 SDL_Touch touch; 53 SDL_Touch touch;
53 touch.id = 0; //TODO: Should be -1? 54 touch.id = 0; //TODO: Should be -1?
54 55
55 //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); 56 //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
56 //EventTouchData* data = (EventTouchData*)(touch.driverdata); 57 //EventTouchData* data = (EventTouchData*)(touch.driverdata);
76 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 77 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
77 78
78 NSEnumerator *enumerator = [touches objectEnumerator]; 79 NSEnumerator *enumerator = [touches objectEnumerator];
79 UITouch *touch = (UITouch*)[enumerator nextObject]; 80 UITouch *touch = (UITouch*)[enumerator nextObject];
80 81
82 //NSLog("Click");
83
81 if (touch) { 84 if (touch) {
82 CGPoint locationInView = [touch locationInView: self]; 85 CGPoint locationInView = [touch locationInView: self];
83 86
84 /* send moved event */ 87 /* send moved event */
85 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); 88 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
86 89
87 /* send mouse down event */ 90 /* send mouse down event */
88 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); 91 SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
89 } 92 }
90 93
91 #if FIXED_MULTITOUCH 94 #ifdef FIXED_MULTITOUCH
92 while(touch) { 95 while(touch) {
93 CGPoint locationInView = [touch locationInView: self]; 96 CGPoint locationInView = [touch locationInView: self];
94 97
95 98
96 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS 99 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
129 if (touch) { 132 if (touch) {
130 /* send mouse up */ 133 /* send mouse up */
131 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); 134 SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
132 } 135 }
133 136
134 #if FIXED_MULTITOUCH 137 #ifdef FIXED_MULTITOUCH
135 while(touch) { 138 while(touch) {
136 CGPoint locationInView = [touch locationInView: self]; 139 CGPoint locationInView = [touch locationInView: self];
137 140
138 141
139 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS 142 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
176 179
177 /* send moved event */ 180 /* send moved event */
178 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); 181 SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
179 } 182 }
180 183
181 #if FIXED_MULTITOUCH 184 #ifdef FIXED_MULTITOUCH
182 while(touch) { 185 while(touch) {
183 CGPoint locationInView = [touch locationInView: self]; 186 CGPoint locationInView = [touch locationInView: self];
184 187
185 188
186 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS 189 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS