SDL port for the Sony PSP contributed by 
   Marcus R. Brown <mrbrown@ocgnet.org>
   Jim Paris <jim@jtan.com>
   Matthew H <matthewh@webone.com.au>

Building
--------
To build for the PSP, make sure psp-config is in the path and run:

   ./autogen.sh
   LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspglue -lpspuser" \
     ./configure --host psp --prefix=`psp-config --pspsdk-path`/..
   make
   make install

Status
------
   Video - yes, single 32-bit ABGR framebuffer surface only; SDL will
           emulate other formats as necessary.  No HW accel.  No 3D.
  Timers - yes, with multiple callbacks
 Threads - yes, with mutexes and semaphores
   Input - yes, see "Input" below
   Audio - yes


SDL_main
--------
When writing an SDL program, the typical use is to write your main
function as "SDL_main", then link -lSDLmain which provides the real
main().  In this implementation, -lSDLmain will:
  - Define the required PSP_* macros
  - Set up the "home" button callback.
  - Initialize the debugging screen
  - Call the user-supplied SDL_main
  - When it returns, delay 2.5 seconds, then exit to VSH.

Of course, you can leave off -lSDLmain, and write the real main()
yourself if you need more control than this.

By default, the PSP "sdl-config --cflags" will define main=SDL_main.


Building applications
---------------------
Write your source file as you would a normal SDL program.  Use the standard
Makefile as supplied with any PSPSDK sample program.  Above the final "include"
line, add:

PSPBIN = $(PSPSDK)/../bin
CFLAGS += `$(PSPBIN)/sdl-config --cflags`
LIBS += `$(PSPBIN)/sdl-config --libs`


Building autoconf applications
------------------------------
The general way to build autoconf applications is to add the psp
architecture to configure.in, then use --with-sdl-prefix to point to
the proper sdl-config.  For example, to build the applications in the
test/ subdirectory, use:

   ./autogen.sh
   LDFLAGS="-L`psp-config --pspsdk-path`/lib -lc -lpspglue -lpspuser" \
     ./configure --host psp --with-sdl-prefix=`psp-config --pspsdk-path`/.. 


Libc
----
SDL is linked against newlib's libc, and your SDL programs should be
too.  Linking against psplibc will appear to work but may behave
strangely at runtime.


Input
-----
The PSP's input scheme can be configured through environment
variables.  These environment variables will typically be created by
the application prior to calling SDL_Init, with calls like
    setenv("PSP_CROSS","K88",1);
    setenv("PSP_ANALOG","1",1);
    setenv("PSP_LTRIGGER","M0",1);
    setenv("PSP_RTRIGGER","M2",1);
The above examples would make the cross button send an "X" keypress,
make the analog stick the mouse, and make the left and right triggers
the left and right mouse buttons.

These variables and values are recognized:

PSP_DPAD:
   0 - dpad is just buttons (default)
   1 - dpad is joystick axes 

PSP_ANALOG:
   0 - analog stick is axes (default)
   1 - analog stick is mouse
   2 - analog stick is mouse with absolute positioning

PSP_name: (where "name" is from the list below)
   J0 - J13:  map to joystick button 0-13 (defaults, see below)
   M0 - M4:   map to mouse button 0-4
   K0 - K511: map to keyboard keycode 0-511 (matches SDLKey enum)

Available PSP button names, and default mapping:
   TRIANGLE J0
   CIRCLE   J1
   CROSS    J2
   SQUARE   J3
   LTRIGGER J4
   RTRIGGER J5
   DOWN     J6  (only if PSP_DPAD=0)
   LEFT     J7  (only if PSP_DPAD=0)
   UP       J8  (only if PSP_DPAD=0)
   RIGHT    J9  (only if PSP_DPAD=0)
   SELECT   J10
   START    J11
   HOME     J12
   HOLD     J13

The joystick device always has 14 buttons.  The mouse always has 5
(left=0, middle=1, right=2, wheelup=3, wheeldown=4).  Joystick or
mouse buttons that have nothing assigned to them will never generate
events.  If both PSP_DPAD and PSP_ANALOG are axes, the dpad axes come
first.  To remove the default mapping without setting a new one, just
use an empty value.

Note: A "home" button press is sometimes generated when the screen
turns off after being idle ("backlight auto-off" setting).  This
generated event does not trigger the usual PSP exit callback.