Board index » delphi » How to read Joystick from within Delphi?

How to read Joystick from within Delphi?

Gidday,

Does anyone know ho to read Joystick positions, buttons etc from within
Delphi?

Thanks,

DG
________________________________________________

Dennis Gibson        
Electronics Unit
Research School of Physical Sciences & Engineering
Australian National University , ACT 0200
Australia
Phone / Fax: (06) 249 4433      [ International: +61 6 249 4433]
Email: dennis.gib...@anu.edu.au
________________________________________________

 

Re:How to read Joystick from within Delphi?


In <djg113.25.011E4...@rsphysse.anu.edu.au> djg...@rsphysse.anu.edu.au
Quote
(Dennis Gibson) writes:

>Gidday,

>Does anyone know ho to read Joystick positions, buttons etc from
within Delphi?

For direct access(except NT) call port 201H. Bits 1-4 are buttons
0-3 for position. Delphi 2 can use directX
Alex

Re:How to read Joystick from within Delphi?


Quote
>In <djg113.25.011E4...@rsphysse.anu.edu.au> djg...@rsphysse.anu.edu.au
>(Dennis Gibson) writes:
>For direct access(except NT) call port 201H. Bits 1-4 are buttons
>0-3 for position. Delphi 2 can use directX
>Alex

Writing to hardware will get you into trouble ... open the MMSYSTEM.HLP file
and look up Joystick functions (joyGetNumDevs, joyGetPos, etc).

---------------------------------------------------------------------
Steven E. Hugg
http://pobox.com/~hugg/

Re:How to read Joystick from within Delphi?


There are a couple of pages on joysticks in 'Programming Windows 95
Unleashed' (SAMS Publishing). I'd agree that the first thing do do is
check the help file for all those entries beginning with 'joy'. What
the book suggested is that once you have gained access to the joystick
with joysetcapture, rather than polling it you should just process the
messages defined in the multimedia windows message extensions. These
can be found in the index under 'MM_JOY...'.

Sorry I can't help anymore. I've not tried it, yet...

As comprehensive as many of the windows programming references are, all
that C++ gives me a headache (plus you have to spend the extra $$$ for
a CD which you can't use cos it's all in MS C++). Is anyone aware of
any good books concentrating solely on using windows (95) API's in the
Delphi (2.0) environment? As time goes by I seem to want to use API's
directly more and more, and it's not always clear (to me) how the API's
are implemented by reading the unit pas files.

--
Neil Yeoman
n...@neily.demon.co.uk

Re:How to read Joystick from within Delphi?


DG>Gidday,

DG>Does anyone know ho to read Joystick positions, buttons etc from within
DG>Delphi?

In Windows 3.1 and with Delphi 1 you could use the Joystick functions
found in the MMSystem unit. To get help, open your Delphi help file.
From the WinHelp File menu choose Open, and select the file
"mmsystem.hlp" in your \delphi\bin directory. Click Function Overview
on the Contents page and click again on Joystick services. There are
many interesting functions.

Regards,

Jani

--
---------------------------------------------------------------------
Jani Jarvinen, Helsinki Finland          jani.jrvi...@hiway.fipnet.fi

Check out Help Editor 2.0 for Windows at:
ftp://ftp.mpoli.fi/metropoli/windows/utils/hlped20.zip

1996: Only four years to computer confusion!
What have you done to avoid it?
---------------------------------------------------------------------
---
 * SLMR 2.1a *

Re:How to read Joystick from within Delphi?


On Wed, 27 Mar 1996 14:03:23 LOCAL, djg...@rsphysse.anu.edu.au (Dennis

Quote
Gibson) wrote:
>Gidday,

>Does anyone know ho to read Joystick positions, buttons etc from within
>Delphi?

>Thanks,

>DG
>________________________________________________

>Dennis Gibson        
>Electronics Unit
>Research School of Physical Sciences & Engineering
>Australian National University , ACT 0200
>Australia
>Phone / Fax: (06) 249 4433      [ International: +61 6 249 4433]
>Email: dennis.gib...@anu.edu.au
>________________________________________________

Uses ..., mmsystem;

...

var
  joyinfo:tjoyinfo;
  rvalue:mmresult;
begin
  rvalue:=joygetpos(JOYSTICKID1,@joyinfo);
  if rvalue = joyerr_noerror then begin
    label4.caption:=inttostr(joyinfo.wxpos);
    label5.caption:=inttostr(joyinfo.wypos);
    label6.caption:=inttostr(joyinfo.wzpos);
    with joyinfo do begin
      if (wbuttons and joy_button1)=joy_button1 then
       radiobutton1.checked:=true else
       radiobutton1.checked:=false;
      if (wbuttons and joy_button2)=joy_button2 then
       radiobutton2.checked:=true else
       radiobutton2.checked:=false;
      if (wbuttons and joy_button3)=joy_button3 then
       radiobutton3.checked:=true else
       radiobutton3.checked:=false;
      if (wbuttons and joy_button4)=joy_button4 then
       radiobutton4.checked:=true else
       radiobutton4.checked:=false;
    end;

look at the source for mmsystem.pas...

Has anyone had any luck doing a JoyGetPosEx(JOYSTICKID1,@joyex); where
joyex is of the type tjoyinfoex?  All I get is an error : 11 -
mmsyserr_invalparam.  The joygetpos works fine...?

Chris

~~~~~~~~~~~~~~~~~~~
csull...@eclipse.net  Chris Sullens
*  100,000 Lemmings can't be wrong  *
~~~~~~~~~~~~~~~~~~~

Re:How to read Joystick from within Delphi?


Quote
csull...@eclipse.net (Chris Sullens) wrote:
>Has anyone had any luck doing a JoyGetPosEx(JOYSTICKID1,@joyex); where
>joyex is of the type tjoyinfoex?  All I get is an error : 11 -
>mmsyserr_invalparam.  The joygetpos works fine...?

You have to set bits in dwflags to say what you want returned.
$000000FF should return all axis and buttons.

Cheers Terry...

Other Threads