Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Aug : Polling Joysticks

www.cryer.info
Managed Newsgroup Archive

Polling Joysticks

Subject:Polling Joysticks
Posted by:"David" (david.markie@nospam.com)
Date:Sun, 27 Aug 2006 18:39:46

I have tried several times (D7) to obtain a solid polling routine for 15 pin
game port type joysticks, but have always failed when a joystick is
unplugged.

Using code such as:-

if joyGetPos(joystickid1,@JoyInfo) = JOYERR_NOERROR then
  begin
    read buttons pressed
    ...
  end;

in a 100mS loop is fine when the joystick is plugged into the game port,
however, when the joystick is unplugged the 'joyGetPos' call takes about
50mS to return which begins to hold up the main application.

Moving the code into a separate thread seems no better as the 'joyGetPos'
call appears to have a high priority demand on CPU time, so it still holds
up the main application.

Reducing the thread priority has no effect.

Cancelling the polling loop when the joystick is first detected as being
unplugged is not an option as I wish to subsquently detect it being
replugged and continue to use the joystick

Has anyone else come across this problem or have any suggestions for a cure

Thanks


David

Replies:

www.cryer.info
Managed Newsgroup Archive