re int h for joysticks is slow in ql i inn uh no names nerdc ufl edu lioness oak circa ufl edu writes i m using int h to read my joystick and it is hideously slow something like of my cpu time is being spent reading the joystick and this is in a program that does nothing but printf and joyread if you only do read print then there is no reason for the joystick stuff not to take of the time even if it is efficient the problem is that a lot of programs trap int h like smartdrv and so it is a slow as hell interface can i read the joystick port in a reasonably safe fashion via polling and that isn t platform or clockspeed specific the truth is that int h joystick reading is slow i read it directly from the hardware port note that doing so exposes you to intermittent disturbance from interrupts so you may want to read say twice in a row and keep the lower results don t just turn interrupts off it may prove detrimental to the health of any high speed comms and other devices here is an example of how to do this joy c an example of how to read pc joystick port by polling the hardware port directly uses inp outp for byte port access will timeout when int count counts up to zero this sample reads one port a is presented and b is in the comments you can read both at once by merging the two but it will time out when either joystick is not connected there is no need to optimize this routine since it runs for as long as the joystick circuitry needs written by eyal lebedinsky eyal ise canberra edu au include stdio h include stdlib h include conio h extern int readjoy int x int y int b int b define joyport x define xjoy x for joystick b use x define yjoy x for joystick b use x define xymask xjoy yjoy define but x for joystick b use x define but x for joystick b use x int returns if ok readjoy int x int y int b int b register int count register char temp joy temp char xymask count outp joyport set trigger do temp joy char inp joyport if temp xjoy x count if temp yjoy y count while count temp joy xymask b joy but b joy but return count this main is for demonstration int main int rc x y b b printf hit any key to exit n while kbhit rc readjoy x y b b printf r d d d d d rc x y b b
