Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sdl_joystickopen(3) [centos man page]

SDL_JoystickOpen(3)						 SDL API Reference					       SDL_JoystickOpen(3)

NAME
SDL_JoystickOpen - Opens a joystick for use. SYNOPSIS
#include "SDL.h" SDL_Joystick *SDL_JoystickOpen(int index); DESCRIPTION
Opens a joystick for use within SDL. The index refers to the N'th joystick in the system. A joystick must be opened before it game be used. RETURN VALUE
Returns a SDL_Joystick structure on success. NULL on failure. EXAMPLES
SDL_Joystick *joy; // Check for joystick if(SDL_NumJoysticks()>0){ // Open joystick joy=SDL_JoystickOpen(0); if(joy) { printf("Opened Joystick 0 "); printf("Name: %s ", SDL_JoystickName(0)); printf("Number of Axes: %d ", SDL_JoystickNumAxes(joy)); printf("Number of Buttons: %d ", SDL_JoystickNumButtons(joy)); printf("Number of Balls: %d ", SDL_JoystickNumBalls(joy)); } else printf("Couldn't open Joystick 0 "); // Close if opened if(SDL_JoystickOpened(0)) SDL_JoystickClose(joy); } SEE ALSO
SDL_JoystickClose SDL
Tue 11 Sep 2001, 23:00 SDL_JoystickOpen(3)

Check Out this Related Man Page

JOY(4)							   BSD Kernel Interfaces Manual 						    JOY(4)

NAME
joy -- joystick device driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device joy Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): joy_load="YES" In /boot/device.hints: hint.joy.0.at="isa" hint.joy.0.port="0x201" hint.joy.1.at="isa" hint.joy.1.port="0x201" #include <sys/joystick.h> DESCRIPTION
The joystick device driver allows applications to read the status of the PC joystick. This device may be opened by only one process at a time. The joystick status is read from a structure via a read() call. The structure is defined in the header file as follows: struct joystick { int x; /* x position */ int y; /* y position */ int b1; /* button 1 status */ int b2; /* button 2 status */ }; Positions are typically in the range 0-2000. One line perl example: perl -e 'open(JOY,"/dev/joy0")||die;while(1) {sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j ";sleep(1);}' ioctl calls Several ioctl() calls are also available. They take an argument of type int * JOY_SETTIMEOUT int *limit Set the time limit (in microseconds) for reading the joystick status. Setting a value too small may prevent to get correct values for the positions (which are then set to -2147483648), however this can be useful if one is only interested by the buttons status. JOY_GETTIMEOUT int *limit Get the time limit (in microseconds) used for reading the joystick status. JOY_SET_X_OFFSET int *offset Set the value to be added to the X position when reading the joystick status. JOY_SET_Y_OFFSET int *offset Set the value to be added to the Y position when reading the joystick status. JOY_GET_X_OFFSET int *offset Get the value which is added to the X position when reading the joystick status. JOY_GET_Y_OFFSET int *offset Get the value which is added to the Y position when reading the joystick status. TECHNICAL SPECIFICATIONS
The pinout of the DB-15 connector is as follow: 1 XY1 (+5v) 2 Switch 1 3 X1 (potentiometer #1) 4 Switch 1 (GND) 5 Switch 2 (GND) 6 Y1 (potentiometer #2) 7 Switch 2 8 N.C. 9 XY2 (+5v) 10 Switch 4 11 X2 (potentiometer #3) 12 Switch 3&4 (GND) 13 Y2 (potentiometer #4) 14 Switch 3 15 N.C. Pots are normally 0-150k variable resistors (0-100k sometimes), and according to the IBM technical reference, the time is given by Time = 24.2e-6s + 0.011e-6s * R/Ohms FILES
/dev/joy? joystick device files HISTORY
The joy driver appeared in FreeBSD 2.0.5. AUTHORS
Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr> BSD
January 23, 1995 BSD
Man Page