Mercurial > sdl-ios-xcode
diff src/touchscreen/nds/SDL_systouchscreen.c @ 2675:5e4274591163 gsoc2008_nds
Started minor changes to the coordinate system used by the touchscreen API as discussed on the mailing list. Also beginning to separate the 'Pressed' and 'Moved' event handling on the private level.
author | Darren Alton <dalton@stevens.edu> |
---|---|
date | Sun, 29 Jun 2008 21:32:31 +0000 |
parents | f1d07ba2e275 |
children | 082cc3ffd7d8 |
line wrap: on
line diff
--- 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); } }