src/touchscreen/nds/SDL_systouchscreen.c
branchgsoc2008_nds
changeset 2678 3895761db26a
parent 2677 6386764eb222
child 2679 bc3e3e889f6d
     1.1 --- a/src/touchscreen/nds/SDL_systouchscreen.c	Wed Jul 02 13:59:30 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,126 +0,0 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 -
     1.8 -    This library is free software; you can redistribute it and/or
     1.9 -    modify it under the terms of the GNU Library General Public
    1.10 -    License as published by the Free Software Foundation; either
    1.11 -    version 2 of the License, or (at your option) any later version.
    1.12 -
    1.13 -    This library is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 -    Library General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU Library General Public
    1.19 -    License along with this library; if not, write to the Free
    1.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 -
    1.22 -    Sam Lantinga
    1.23 -    slouken@devolution.com
    1.24 -*/
    1.25 -
    1.26 -#include "SDL_config.h"
    1.27 -
    1.28 -#ifdef SDL_TOUCHSCREEN_NDS
    1.29 -
    1.30 -/* This is the system specific header for the SDL touchscreen API */
    1.31 -#include <nds.h>
    1.32 -#include <stdio.h>              /* For the definition of NULL */
    1.33 -
    1.34 -#include "SDL_error.h"
    1.35 -#include "SDL_events.h"
    1.36 -#include "SDL_touchscreen.h"
    1.37 -#include "../SDL_systouchscreen.h"
    1.38 -#include "../SDL_touchscreen_c.h"
    1.39 -
    1.40 -#include "../../video/nds/SDL_ndsevents_c.h"
    1.41 -
    1.42 -/* Function to scan the system for touchscreen.
    1.43 - * This function should set SDL_numtouchscreens to the number of available
    1.44 - * touchscreen.  Touchscreen 0 should be the system default touchscreen.
    1.45 - * It should return 0, or -1 on an unrecoverable fatal error.
    1.46 - */
    1.47 -int
    1.48 -SDL_SYS_TouchscreenInit(void)
    1.49 -{
    1.50 -    SDL_numtouchscreens = 1;
    1.51 -    return (1);
    1.52 -}
    1.53 -
    1.54 -/* Function to get the device-dependent name of a touchscreen */
    1.55 -const char *
    1.56 -SDL_SYS_TouchscreenName(int index)
    1.57 -{
    1.58 -    if (!index)
    1.59 -        return "NDS builtin touchscreen";
    1.60 -    SDL_SetError("No touchscreen available with that index");
    1.61 -    return (NULL);
    1.62 -}
    1.63 -
    1.64 -/* Function to open a touchscreen for use.
    1.65 -   The touchscreen to open is specified by the index field of the touchscreen.
    1.66 -   This should fill the maxpoints field of the touchscreen structure.
    1.67 -   It returns 0, or -1 if there is an error.
    1.68 - */
    1.69 -int
    1.70 -SDL_SYS_TouchscreenOpen(SDL_Touchscreen * touchscreen)
    1.71 -{
    1.72 -    touchscreen->maxpoints = 1;
    1.73 -    touchscreen->npoints = 0;
    1.74 -    /* do I call SDL_TouchscreenOpen here? */
    1.75 -    return 0;
    1.76 -}
    1.77 -
    1.78 -
    1.79 -/* Function to update the state of a touchscreen - called as a device poll.
    1.80 - * This function shouldn't update the touchscreen structure directly,
    1.81 - * but instead should call SDL_PrivateTouch*() to deliver events
    1.82 - * and update touchscreen device state.
    1.83 - */
    1.84 -void
    1.85 -SDL_SYS_TouchscreenUpdate(SDL_Touchscreen * touchscreen)
    1.86 -{
    1.87 -    u32 keysd, keysu, keysh;
    1.88 -    Uint16 xpos=0, ypos=0, pressure = 32767;
    1.89 -    touchPosition touch;
    1.90 -
    1.91 -    /*scanKeys();*/
    1.92 -    keysd = keysDown();
    1.93 -    keysh = keysHeld();
    1.94 -    keysu = keysUp();
    1.95 -    touch=touchReadXY();
    1.96 -    xpos = (touch.px << 8) + 1;
    1.97 -    ypos = (touch.py << 16) / 192 + 1;
    1.98 -    /* TODO uses touch.x and touch.y for something.
    1.99 -       we discussed in the mailing list having both "hardware x/y" and
   1.100 -       "screen x/y" coordinates.  maybe modify structs for that too
   1.101 -       also, find out how Colors! gets pressure and see if it's practical here
   1.102 -     */
   1.103 -
   1.104 -    if ((keysd & KEY_TOUCH)) {
   1.105 -        SDL_PrivateTouchPress(touchscreen, 0, xpos, ypos, pressure);
   1.106 -    }
   1.107 -    if ((keysh & KEY_TOUCH)) {
   1.108 -    	/* sometimes the touch jumps to y=1 before it reports as keysUp */
   1.109 -    	if(ypos > 1) {
   1.110 -	    SDL_PrivateTouchMove(touchscreen, 0, xpos, ypos, pressure);
   1.111 -	}
   1.112 -    }
   1.113 -    if ((keysu & KEY_TOUCH)) {
   1.114 -        SDL_PrivateTouchRelease(touchscreen, 0);
   1.115 -    }
   1.116 }
   1.117 -
   1.118 -/* Function to close a touchscreen after use */
   1.119 -void
   1.120 -SDL_SYS_TouchscreenClose(SDL_Touchscreen * touchscreen)
   1.121 -{
   1.122 -}
   1.123 -
   1.124 -/* Function to perform any system-specific touchscreen related cleanup */
   1.125 -void
   1.126 -SDL_SYS_TouchscreenQuit(void)
   1.127 -{
   1.128 -}
   1.129 -#endif /* SDL_TOUCHSCREEN_NDS */
   1.130 -