src/touchscreen/nds/SDL_systouchscreen.c
branchgsoc2008_nds
changeset 2675 5e4274591163
parent 2674 f1d07ba2e275
child 2676 082cc3ffd7d8
--- a/src/touchscreen/nds/SDL_systouchscreen.c	Mon Jun 23 11:55:26 2008 +0000
+++ b/src/touchscreen/nds/SDL_systouchscreen.c	Sun Jun 29 21:32:31 2008 +0000
@@ -82,7 +82,7 @@
 SDL_SYS_TouchscreenUpdate(SDL_Touchscreen * touchscreen)
 {
     u32 keysd, keysu, keysh;
-    int xpos, ypos, pressure = 16384;
+    Uint16 xpos=0, ypos=0, pressure = 32767;
     touchPosition touch;
 
     scanKeys();
@@ -90,12 +90,18 @@
     keysh = keysHeld();
     keysu = keysUp();
     touch=touchReadXY();
-    xpos = (touch.px-128)*256;
-    ypos = (touch.py-96)*(65536/192);
+    xpos = (touch.px << 8) + 1;
+    ypos = (touch.py << 16) / 192 + 1;
+    /* TODO uses touch.x and touch.y for something.
+       we discussed in the mailing list having both "hardware x/y" and
+       "screen x/y" coordinates. */
 
-    if (((keysd|keysh) & KEY_TOUCH)) {
+    if ((keysd & KEY_TOUCH)) {
         SDL_PrivateTouchPress(touchscreen, 0, xpos, ypos, pressure);
     }
+    if ((keysh & KEY_TOUCH)) {
+    	SDL_PrivateTouchMove(touchscreen, 0, xpos, ypos, pressure); 
+    }
     if ((keysu & KEY_TOUCH)) {
         SDL_PrivateTouchRelease(touchscreen, 0);
     }
}