1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| unit Main;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, DXInput, DXSounds, DXClass;
type TMainForm = class(TForm) DXInput1: TDXInput; Label1: TLabel; Label2: TLabel; AnalogMode: TCheckBox; POVLabel: TLabel; DXWaveList1: TDXWaveList; DXSound1: TDXSound; Label4: TLabel; Timer: TDXTimer; Panel1: TPanel; procedure TimerTimer(Sender: TObject; LagCount: Integer); end;
var MainForm: TMainForm;
implementation
{$R *.DFM}
procedure TMainForm.TimerTimer(Sender: TObject; LagCount: Integer); begin DXInput1.Update;
if AnalogMode.Checked and ((DXInput1.Joystick.X<>0) or (DXInput1.Joystick.Y<>0)) then begin Label1.Left := Label1.Left + DXInput1.Joystick.X; Label1.Top := Label1.Top + DXInput1.Joystick.Y; end else begin if isLeft in DXInput1.States then Label1.Left := Label1.Left - 10;
if isRight in DXInput1.States then Label1.Left := Label1.Left + 10;
if isUp in DXInput1.States then Label1.Top := Label1.Top - 10;
if isDown in DXInput1.States then Label1.Top := Label1.Top + 10; end;
if isButton1 in DXInput1.States then begin Panel1.Color:= clFuchsia; DXWaveList1.Items[0].Play(False);
DXInput1.States := DXInput1.States - [isButton1]; end; POVLabel.Caption := Format('POV (Point of view): %d', [DXInput1.Joystick.Joystate.rgdwPOV[0]]); end;
end. |