src/touchscreen/nds/SDL_systouchscreen.c
branchgsoc2008_nds
changeset 2676 082cc3ffd7d8
parent 2675 5e4274591163
equal deleted inserted replaced
2675:5e4274591163 2676:082cc3ffd7d8
    83 {
    83 {
    84     u32 keysd, keysu, keysh;
    84     u32 keysd, keysu, keysh;
    85     Uint16 xpos=0, ypos=0, pressure = 32767;
    85     Uint16 xpos=0, ypos=0, pressure = 32767;
    86     touchPosition touch;
    86     touchPosition touch;
    87 
    87 
    88     scanKeys();
    88     /*scanKeys();*/
    89     keysd = keysDown();
    89     keysd = keysDown();
    90     keysh = keysHeld();
    90     keysh = keysHeld();
    91     keysu = keysUp();
    91     keysu = keysUp();
    92     touch=touchReadXY();
    92     touch=touchReadXY();
    93     xpos = (touch.px << 8) + 1;
    93     xpos = (touch.px << 8) + 1;
    94     ypos = (touch.py << 16) / 192 + 1;
    94     ypos = (touch.py << 16) / 192 + 1;
    95     /* TODO uses touch.x and touch.y for something.
    95     /* TODO uses touch.x and touch.y for something.
    96        we discussed in the mailing list having both "hardware x/y" and
    96        we discussed in the mailing list having both "hardware x/y" and
    97        "screen x/y" coordinates. */
    97        "screen x/y" coordinates.  maybe modify structs for that too
       
    98        also, find out how Colors! gets pressure and see if it's practical here
       
    99      */
    98 
   100 
    99     if ((keysd & KEY_TOUCH)) {
   101     if ((keysd & KEY_TOUCH)) {
   100         SDL_PrivateTouchPress(touchscreen, 0, xpos, ypos, pressure);
   102         SDL_PrivateTouchPress(touchscreen, 0, xpos, ypos, pressure);
   101     }
   103     }
   102     if ((keysh & KEY_TOUCH)) {
   104     if ((keysh & KEY_TOUCH)) {
   103     	SDL_PrivateTouchMove(touchscreen, 0, xpos, ypos, pressure); 
   105     	/* sometimes the touch jumps to y=1 before it reports as keysUp */
       
   106     	if(ypos > 1) {
       
   107 	    SDL_PrivateTouchMove(touchscreen, 0, xpos, ypos, pressure);
       
   108 	}
   104     }
   109     }
   105     if ((keysu & KEY_TOUCH)) {
   110     if ((keysu & KEY_TOUCH)) {
   106         SDL_PrivateTouchRelease(touchscreen, 0);
   111         SDL_PrivateTouchRelease(touchscreen, 0);
   107     }
   112     }
   108 }
   113 }