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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
unit UnitSimul;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, mmsystem, PiconeBarreTache;
type
TForm1 = class(TForm)
Timer1: TTimer;
MouseInfo: TGroupBox;
mouseXlabel: TLabel;
mouseYlabel: TLabel;
JoystickInfo: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Labell5: TLabel;
Label4: TLabel;
joyXlabel: TLabel;
joyYlabel: TLabel;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox2: TGroupBox;
ComboBox1: TComboBox;
GroupBox3: TGroupBox;
ComboBox2: TComboBox;
PiconeBarreTache1: TPiconeBarreTache;
GroupBox4: TGroupBox;
ComboBox3: TComboBox;
procedure Timer1Timer(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure ComboBox3Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mousept : tpoint;
InfoJoystick : JOYINFOEX;
Result:MMRESULT;
JOYID : integer;
vitesse:byte=7;
wheel:byte=WHEEL_DELTA div 10;
LEFTDOWN:boolean=false;
RIGHTDOWN:boolean=false;
MIDDLEDOWN:boolean=false;
dwdata: integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if RadioButton1.Checked = true then JoyID := JOYSTICKID1
else
JoyID := JOYSTICKID2;
InfoJoystick.dwSize:=SizeOf(InfoJoystick);
InfoJoystick.dwFlags:= JOY_RETURNALL;
Result := joyGetPosEx(JoyID, @InfoJoystick);
GetCursorPos(mousept);
mouseXlabel.Caption := FloatToStr(mousept.X);
mouseYlabel.Caption := FloatToStr(mousept.Y);
joyXlabel.Caption := IntToStr(InfoJoystick.wXpos);
joyYlabel.Caption := IntToStr(Infojoystick.wYpos);
if (InfoJoystick.wXpos = 65535) AND (InfoJoystick.wYpos = 0) then//haut,droite
begin
SetCursorPos(mousept.X+vitesse, mousept.Y -vitesse);
end
else if (InfoJoystick.wXpos = 65535) AND (InfoJoystick.wYpos = 32767) then//droite
begin
SetCursorPos(mousept.X +vitesse, mousept.Y);
end
else if (InfoJoystick.wXpos = 65535) AND (InfoJoystick.wYpos = 65535) then//bas,droite
begin
SetCursorPos(mousept.X +vitesse, mousept.Y+vitesse);
end
else if (InfoJoystick.wXpos = 32767) AND (InfoJoystick.wYpos = 65535) then//bas
begin
SetCursorPos(mousept.X , mousept.Y+vitesse);
end
else if (InfoJoystick.wXpos = 0) AND (InfoJoystick.wYpos = 65535) then//bas,gauche
begin
SetCursorPos(mousept.X -vitesse, mousept.Y+vitesse);
end
else if (InfoJoystick.wXpos = 0) AND (InfoJoystick.wYpos = 32767) then//gauche
begin
SetCursorPos(mousept.X -vitesse, mousept.Y);
end
else if (InfoJoystick.wXpos = 0) AND (InfoJoystick.wYpos = 0) then//haut,gauche
begin
SetCursorPos(mousept.X -vitesse, mousept.Y-vitesse);
end
else if (InfoJoystick.wXpos = 32767) AND (InfoJoystick.wYpos = 0) then//haut
begin
SetCursorPos(mousept.X , mousept.Y-vitesse);
end;
if not LEFTDOWN and (InfoJoystick.wButtons=JOY_BUTTON1) then
begin mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);LEFTDOWN:=true;exit;end
else if not RIGHTDOWN and (InfoJoystick.wButtons=JOY_BUTTON2) then
begin mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);RIGHTDOWN:=true;exit;end
else if not MIDDLEDOWN and (InfoJoystick.wButtons=JOY_BUTTON3) then
begin mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0);MIDDLEDOWN:=true;exit;end
else if (InfoJoystick.wButtons=JOY_BUTTON4) then
mouse_event(MOUSEEVENTF_WHEEL,0,0,wheel,0)
else if (InfoJoystick.wButtons=JOY_BUTTON5) then
mouse_event(MOUSEEVENTF_WHEEL,0,0,-wheel,0)
if (InfoJoystick.wButtons <> JOY_BUTTON1) and LEFTDOWN then
begin mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);LEFTDOWN:=false;end;
if (InfoJoystick.wButtons <> JOY_BUTTON2) and RIGHTDOWN then
begin mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);RIGHTDOWN:=false;end;
if (InfoJoystick.wButtons <> JOY_BUTTON3) and MIDDLEDOWN then
begin mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0);MIDDLEDOWN:=false;end;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
vitesse:=ComboBox1.ItemIndex+1;
end;
////////////////////////////////////////////////////////////////////////////////
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
Timer1.Interval:=strtoint(combobox2.Text);
end;
////////////////////////////////////////////////////////////////////////////////
procedure TForm1.ComboBox3Change(Sender: TObject);
begin
wheel:=WHEEL_DELTA div strtoint(combobox3.Text);
end;
end. |
Partager