home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / DELPHIX.ZIP / Samples / Input / Basic / Main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-06  |  1.6 KB  |  67 lines

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