Как использовать Joystick
Автор: http://www.swissdelphicenter.ch
uses
MMSYSTEM;
var
MyJoy: TJoyInfo;
ErrorResult: MMRESULT;
begin
ErrorResult := joyGetPos(joystickid1, @MyJoy);
if ErrorResult = JOYERR_NOERROR then
begin
TrackBar1.Position := MyJoy.wypos;
TrackBar2.Position := MyJoy.wxpos;
RadioButton1.Checked := (MyJoy.wbuttons and joy_button1) > 0;
RadioButton2.Checked := (MyJoy.wbuttons and joy_button2) > 0;
end
else
case ErrorResult of
MMSYSERR_NODRIVER: ShowMessage('No Joystick driver present');
MMSYSERR_INVALPARAM: ShowMessage('Invalid Joystick Paramameters');
JOYERR_UNPLUGGED: ShowMessage('Joystick is Unplugged');
else
ShowMessage('Unknown error with Joystick');
end;
end;
|