view docs/html/sdlenvvars.html @ 892:dc29e5907694

Date: Sun, 18 Apr 2004 16:09:53 -0400 (EDT) From: David MacCormack Subject: [SDL] Linux joystick patch I recently got myself a PS2 -> USB converter (a super joybox 5). It accepts 4 PSX/PS2 controllers. It's implemented as a HID, which is nice because it doesn't require its own driver, but the problem is that it's implemented as a *single* HID -- that is, it shows up as a single joystick with 19 axes, 4 hats, and 48 buttons. This poses a problem for a number of apps which use SDL (stella, fce ultra, zsnes, to name a few) and see only a single (physical) joystick even though there are really 4 (logical) joysticks. There are a number of these types of devices on the market, and I've seen others post messages (in the zsnes forum, for example) with the same problem, so I came up with what I think is a pretty generic solution. I patched src/joystick/linux/SDL_sysjoystic.c to include support for logical joysticks; basically, it's a static array and supporting functions that map a single physical joystick to multiple logical joysticks. The attached patch has the new code. It's wrapped inside #ifndef statements so that you can get the old behavior if you want.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 16 May 2004 18:46:24 +0000
parents 355632dca928
children 34cca785be57
line wrap: on
line source

<HTML
><HEAD
><TITLE
>SDL_envvars</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="General"
HREF="general.html"><LINK
REL="PREVIOUS"
TITLE="SDL_GetError"
HREF="sdlgeterror.html"><LINK
REL="NEXT"
TITLE="Video"
HREF="video.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdlgeterror.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="video.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SDLENVVARS"
></A
>SDL_envvars</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN675"
></A
><H2
>Name</H2
>SDL_envvars&nbsp;--&nbsp;SDL environment variables</DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN678"
></A
><H2
>Description</H2
><P
>Not a function, set using setenv()</P
><P
>Several environment variables are available to modify the
behaviour of SDL. Using these variables isn't recommened and the names
and presence of these variables aren't guaranteed from one release to
the next. However, they can be very useful for debugging
purposes.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN682"
></A
><H2
>Video</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SDL_FBACCEL</TT
></DT
><DD
><P
>If set to 0, disable hardware acceleration in the linux fbcon driver.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_FBDEV</TT
></DT
><DD
><P
>Frame buffer device to use in the linux fbcon driver, instead of /dev/fb0</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_FULLSCREEN_UPDATE</TT
></DT
><DD
><P
>In the ps2gs driver, sets the <TT
CLASS="LITERAL"
>SDL_ASYNCBLIT</TT
> flag on the
display surface.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEODRIVER</TT
></DT
><DD
><P
>Selectes the video driver for SDL to use. Possible values, in the
order they are tried if this variable is not set:</P
><DIV
CLASS="INFORMALTABLE"
><A
NAME="AEN706"
></A
><P
></P
><TABLE
BORDER="0"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>x11</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
></P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>dga</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(the XFree86 DGA2)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>nanox</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Linux)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>fbcon</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Linux)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>directfb</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Linux)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>ps2gs</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Playstation 2)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>ggi</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
></P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>vgl</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(BSD)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>svgalib</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Linux)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>aalib</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
></P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>directx</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Win32)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>windib</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Win32)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>bwindow</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(BeOS)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>toolbox</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(MacOS Classic)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>DSp</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(MacOS Classic)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>Quartz</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(MacOS X)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>CGX</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Amiga)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>photon</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(QNX)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>epoc</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Epoc)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>dummy</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
></P
></TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_CENTERED</TT
></DT
><DD
><P
>If set, tries to center the SDL window when running in X11 windowed
mode, or using the CyberGrafix driver.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_GL_DRIVER</TT
></DT
><DD
><P
>The openGL driver (shared library) to use for X11. Default is libGL.so.1</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_X11_DGAMOUSE</TT
></DT
><DD
><P
>With XFree86, enables use of DGA mouse if set.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_X11_MOUSEACCEL</TT
></DT
><DD
><P
>For X11, sets the mouse acceleration. The value should be a string
on the form:</P
><P
>"<TT
CLASS="PARAMETER"
><I
>n</I
></TT
>/<TT
CLASS="PARAMETER"
><I
>d</I
></TT
>/<TT
CLASS="PARAMETER"
><I
>t</I
></TT
>"</P
><P
>where <TT
CLASS="PARAMETER"
><I
>n</I
></TT
> and <TT
CLASS="PARAMETER"
><I
>d</I
></TT
> are the
acceleration numerator/denumerators (so	mouse movement is accelerated by
<TT
CLASS="PARAMETER"
><I
>n</I
></TT
>/<TT
CLASS="PARAMETER"
><I
>d</I
></TT
>), and
<TT
CLASS="PARAMETER"
><I
>t</I
></TT
> is the threshold above which acceleration applies
(counted as number of pixels the mouse moves at once).</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_X11_NODIRECTCOLOR</TT
></DT
><DD
><P
>If set, don't attempt to use DirectColor visuals even if they are
present. (SDL will use them otherwise for gamma correction).
This is needed with older X servers when using the XVideo extension.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_X11_VISUALID</TT
></DT
><DD
><P
>ID of an X11 visual to use, overriding SDL's default visual selection
algorithm. It can be in decimal or in hex (prefixed by 0x).</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_YUV_DIRECT</TT
></DT
><DD
><P
>If set, display YUV overlay directly on the video surface if possible,
instead of on the surface passed to
<A
HREF="sdlcreateyuvoverlay.html"
><TT
CLASS="FUNCTION"
>SDL_CreateYUVOverlay</TT
></A
>.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_VIDEO_YUV_HWACCEL</TT
></DT
><DD
><P
>If not set or set to a nonzero value, SDL will attempt to use
hardware YUV acceleration for video playback.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_WINDOWID</TT
></DT
><DD
><P
>For X11 or Win32, contains the ID number of the window to be used by
SDL instead of creating its own window. Either in decimal or
in hex (prefixed by 0x).</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN866"
></A
><H2
>Events/Input</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SDL_MOUSE_RELATIVE</TT
></DT
><DD
><P
>If set to 0, do not use mouse relative mode in X11. The default is
to use it if the mouse is hidden and input is grabbed.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_MOUSEDEV</TT
></DT
><DD
><P
>The mouse device to use for the linux fbcon driver. If not set,
SDL first tries to use GPM in repeater mode, then various other
devices (/dev/pcaux, /dev/adbmouse, /dev/mouse etc).</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_MOUSEDEV_IMPS2</TT
></DT
><DD
><P
>If set, SDL will not try to auto-detect	the IMPS/2 protocol of
a PS/2 mouse but use it right away. For the fbcon and ps2gs drivers.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_MOUSEDRV</TT
></DT
><DD
><P
>For the linux fbcon driver: if set to ELO, use the ELO touchscreen
controller as a pointer device</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_NO_RAWKBD</TT
></DT
><DD
><P
>For the libvga driver: If set, do not attempt to put the keyboard in raw mode.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_NOMOUSE</TT
></DT
><DD
><P
>If set, the linux fbcon driver will not use a mouse at all.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN899"
></A
><H2
>Audio</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>AUDIODEV</TT
></DT
><DD
><P
>The audio device to use, if <TT
CLASS="LITERAL"
>SDL_PATH_DSP</TT
> isn't set.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_AUDIODRIVER</TT
></DT
><DD
><P
>Selects the audio driver for SDL to use. Possible values, in the
order they are tried if this variable is not set:</P
><DIV
CLASS="INFORMALTABLE"
><A
NAME="AEN913"
></A
><P
></P
><TABLE
BORDER="0"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>openbsd</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(OpenBSD)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>dsp</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(OSS /dev/dsp: Linux, Solaris, BSD etc)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>alsa</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Linux)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>audio</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Unix style /dev/audio: SunOS, Solaris etc)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>AL</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Irix)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>artsc</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(ARTS audio daemon)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>esd</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(esound audio daemon)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>nas</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(NAS audio daemon)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>dma</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(OSS /dev/dsp, using DMA)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>dsound</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Win32 DirectX)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>waveout</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Win32 WaveOut)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>baudio</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(BeOS)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>sndmgr</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(MacOS SoundManager)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>paud</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(AIX)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>AHI</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(Amiga)</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>disk</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>(all; output to file)</P
></TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_DISKAUDIOFILE</TT
></DT
><DD
><P
>The name of the output file for the "disk" audio driver. If not
set, the name <TT
CLASS="LITERAL"
>sdlaudio.raw</TT
> is used.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_DISKAUDIODELAY</TT
></DT
><DD
><P
>For the "disk" audio driver, how long to wait (in ms) before writing
a full sound buffer. The default is 150 ms.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_DSP_NOSELECT</TT
></DT
><DD
><P
>For some audio drivers (alsa, paud, dma and dsp), don't use select()
but a timed method instead. May cure some audio problems, or cause
others.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_PATH_DSP</TT
></DT
><DD
><P
>The audio device to use. If not set, SDL tries AUDIODEV and then
a platform-dependent default value (/dev/audio on Solaris,
/dev/dsp on Linux etc).</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN1017"
></A
><H2
>CD-ROM</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SDL_CDROM</TT
></DT
><DD
><P
>A colon-separated list of CD-ROM devices to use, in addition to
the standard devices (typically /dev/cdrom, platform-dependent).</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN1025"
></A
><H2
>Debugging</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SDL_DEBUG</TT
></DT
><DD
><P
>If set, causes every call to <TT
CLASS="FUNCTION"
>SDL_SetError</TT
> (that
is, every time SDL signals an error) to also print an error message on
stderr.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN1034"
></A
><H2
>Joystick</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SDL_JOYSTICK_DEVICE</TT
></DT
><DD
><P
>Joystick device to use in the linux joystick driver, in addition
to the usual: /dev/js*, /dev/input/event*, /dev/input/js*</P
></DD
><DT
><TT
CLASS="LITERAL"
>SDL_LINUX_JOYSTICK</TT
></DT
><DD
><P
>Special joystick configuration string for linux. The format is</P
><P
>"<TT
CLASS="PARAMETER"
><I
>name</I
></TT
> <TT
CLASS="PARAMETER"
><I
>numaxes</I
></TT
> <TT
CLASS="PARAMETER"
><I
>numhats</I
></TT
> <TT
CLASS="PARAMETER"
><I
>numballs</I
></TT
>"</P
><P
>where <TT
CLASS="PARAMETER"
><I
>name</I
></TT
> is the name string of the joystick
(possibly in single quotes), and the rest are the number of axes, hats
and balls respectively.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdlgeterror.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="video.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_GetError</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="general.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Video</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>