summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2012-02-20 23:54:33 -0500
committerSam Lantinga <slouken@libsdl.org>2012-02-20 23:54:33 -0500
commit2cc65863b9b1dbe888ac62a3adcb1f8b9936f1f3 (patch)
tree42968ef3aa1f10ed3df1f39e3fe9b98c7c68ad0f /src
parentc88b732fdc191c5a4b7c421781eb2011bd46663e (diff)
Fixed bug 1423 - Finger touch events don't report pressure
Philip Taylor 2012-02-19 08:34:52 PST SDL_touch.c never actually uses the 'pressurein' arguments to SDL_SendFingerDown/SDL_SendTouchMotion, so it doesn't report the real pressure. Also it uses touch->pressureres which is never initialised. Also it fails to initialise some fields of event.tfinger for certain events, so applications might try to use bogus data. The attached patch seems to be enough to produce generally sensible output on Android.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/events/SDL_touch.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c
index fec2d548..2e9cd10a 100755
--- a/src/events/SDL_touch.c
+++ b/src/events/SDL_touch.c
@@ -141,6 +141,7 @@ SDL_AddTouch(const SDL_Touch * touch, char *name)
SDL_touchPads[index]->xres = (1<<(16-1));
SDL_touchPads[index]->yres = (1<<(16-1));
+ SDL_touchPads[index]->pressureres = (1<<(16-1));
//Do I want this here? Probably
SDL_GestureAddTouch(SDL_touchPads[index]);
@@ -329,7 +330,7 @@ SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
//scale to Integer coordinates
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
- pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
+ pressure = (Uint16)((pressurein+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
finger = SDL_GetFinger(touch,fingerid);
if(down) {
@@ -357,6 +358,8 @@ SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
event.tfinger.touchId = id;
event.tfinger.x = x;
event.tfinger.y = y;
+ event.tfinger.dx = 0;
+ event.tfinger.dy = 0;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
@@ -384,6 +387,7 @@ SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
event.tfinger.y = finger->y;
event.tfinger.dx = 0;
event.tfinger.dy = 0;
+ event.tfinger.pressure = pressure;
if(SDL_DelFinger(touch,fingerid) < 0) return 0;
posted = (SDL_PushEvent(&event) > 0);
@@ -412,7 +416,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
//scale to Integer coordinates
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
- pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
+ pressure = (Uint16)((pressurein+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
if(touch->flush_motion) {
return 0;
}