Solved

Reading JoyStick Buttons

Posted on 1998-04-03
1
232 Views
Last Modified: 2011-09-20
How do I read buttons 1 and 2 on a joystick? A component would be nice... Is there a way to do it so it is responsive but not at the expense of using up all processing power?
I'm desperate for this..... 850!!!!! points to the person with a good answer.
0
Comment
Question by:davegreen
1 Comment
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 850 total points
ID: 1361260
Hi

The joystick functions are in the MMSystem unit.
Basically, you can get the joystick status by calling JoyGetPos.  This returns the X, Y and Z positions, and the states of buttons 1 to 4.

E.g. suppose you have 3 labels (lblX, lblY and lblZ) and 4 checkboxes (chk1 to chk4):
var
  JI: TJoyInfo;
begin
  joyGetPos(0, @JI);
  lblX.Caption := IntToStr(JI.wXpos);
  lblY.Caption := IntToStr(JI.wYpos);
  lblZ.Caption := IntToStr(JI.wZpos);
  chk1.Checked := (JI.wButtons and JOY_BUTTON1 > 0);
  chk2.Checked := (JI.wButtons and JOY_BUTTON2 > 0);
  chk3.Checked := (JI.wButtons and JOY_BUTTON3 > 0);
  chk4.Checked := (JI.wButtons and JOY_BUTTON4 > 0);
end;

A better way, though, is to use the JoySetCapture api call to send joystick notifications to your app.  I have a component which does this.  If you would like it, mail me at davekw@iafrica.com.

Regards,
JB
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question