📄 readme.joystick
字号:
Hi! I wrote a set of SVGAlibish joystick routines while I played with portingDOSDoom to SVGAlib. It is compatible with both the older joystick driver for Linux 1.x and 2.0 and the newer joystick driver that is in recent 2.1.x kernels.Some of the code is ripped from the userland tools joystick-0.6.7 and joystick-2.0.6 none of wich has any special license attaced to them. The files are:joydev.h: my userland version of the kernel joystick.hvgajoystick.h: library include file analog to vgakeyboard.h and vgamouse.hjoystick.c: the library routines.joytest.c: a simple test program/exampleI dunno how useful these will be, but I could at least use them in doom. (Notthat joystick control in doom adds anything, I just implemented it forcompleteness.)BUGS:Only one joystick device at any time (but the new 2.1.x driver will let youmap 4 axis and 4 buttons to one logical device).The routines: int joystick_init(const char *joydev, int verbose, FILE *file);This one inits the joystick routines and opens the device. Returna thefiledescriptor of the joystick device if successfull or -1 if not.Outputs some messages to stdout id verbose is != 0. If file != NULL it will try to recalibrate the joystick and output the recalibration instructions tothe struct file pointed to by file.E.g. if (-1 == joystick_init("/dev/js0, 1, stdout)){ printf("Joystick init failed\n"); exit(1);}void joystick_close(void);Shuts down the joystick.int joystick_update(void);Reads the joystick and calls the joystick handler if anything events areavailible. Should be called every now and then. void joystick_sethandler(__joystick_handler jh);Install a user supplied joystick handler.A user supplied joystick handler would look like this.void joystick_handler(int event, int number, char value); int event - event type: JOY_EVENTAXIS an axis has moved JOY_EVENTBUTTONDOWN a button has been pushed JOY_EVENTBUTTONUP a button has been releasedint number - the axis or button number for this event 0=x axis or button 1, etc.char value - value for axis events (-128 .. 0 .. 127)void joystick_setdefaulthandler(void);Restore the default joystick handler.char joystick_getnumaxes(void);char joystick_getnumbuttons(void);Retrun the number of axes/buttons on the joystick.char joystick_getaxis(int a);char joystick_getbutton(int b);Querys the jostick state from the default joystick handler if it is used. The following macros calls joystick_getaxis() or joystick_getbutton().joystick_getb1() - Gets button 1joystick_getb2() - Gets button 2joystick_getb3() - Gets button 3joystick_getb4() - Gets button 4joystick_getx() - Returns the X axisjoystick_gety() - Returns the Y axisjoystick_getz() - Returns the Z axisThat all folks,Daniel Engstr鰉 daniel.engstrom@riksnett.no
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -