Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading JoyStick Buttons

Posted on 1998-04-03
1
Medium Priority
?
242 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 3400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 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