Solved

Reading JoyStick Buttons

Posted on 1998-04-03
1
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 73
how to update exe applicatio from internet ? 6 92
Firemonkey webbrowser scrollbars ? 1 57
Can Live bindings change TGrid Cell Colour ? 1 31
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 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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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