Solved

Reading JoyStick Buttons

Posted on 1998-04-03
1
230 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now