Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read Joystick from within Delphi?

254 views
Skip to first unread message

Dennis Gibson

unread,
Mar 27, 1996, 3:00:00 AM3/27/96
to
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...@anu.edu.au
________________________________________________

alex peper

unread,
Mar 27, 1996, 3:00:00 AM3/27/96
to
In <djg113.25...@rsphysse.anu.edu.au> djg...@rsphysse.anu.edu.au

(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

Steven E. Hugg

unread,
Mar 28, 1996, 3:00:00 AM3/28/96
to

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/

Neil Yeoman

unread,
Mar 29, 1996, 3:00:00 AM3/29/96
to
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
ne...@neily.demon.co.uk


JANI JRVINEN

unread,
Apr 2, 1996, 3:00:00 AM4/2/96
to
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.j...@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 *

Chris Sullens

unread,
Apr 4, 1996, 3:00:00 AM4/4/96
to
On Wed, 27 Mar 1996 14:03:23 LOCAL, djg...@rsphysse.anu.edu.au (Dennis
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...@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

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

Terry Harris

unread,
Apr 4, 1996, 3:00:00 AM4/4/96
to
csul...@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...

0 new messages