Solved

Reading JoyStick Buttons

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 39
TServerSocket - file via sendbuf or Text via sendtext ? 1 42
Delphi inherited method 6 63
control image tags in a string ? 12 110
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

16 Experts available now in Live!

Get 1:1 Help Now