Home > Back-end >  Delphi how to map the keys?
Delphi how to map the keys?

Time:10-13

Example: how to realize the direction key on the keyboard, a button on the left key mapped to handle. In the online, such as 90 points.
Mapping tool, not a third party. I want to pass code control

CodePudding user response:

Third party control in the source of the answer, anyway have to DX,

CodePudding user response:

The third party controls, this can have. Sololie elder brother and you. To detail the DEMO.

CodePudding user response:

There are no other master answer ah.

CodePudding user response:

The so-called map key is to understand how to operate the handle to put it bluntly, just know handles, you need to download the DirectX SDK, or with a third party components provide packaging good DX related function,
Third-party components is relatively simple and easy to use old DelphiX, installed after the DXINPU controls can operating handle with it, see it in the directory demo, simple a few words

 
The unit Main;

Interface

USES the
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;
The Timer: TDXTimer;
Procedure TimerTimer (Sender: TObject; LagCount: Integer);
end;

Var
MainForm: TMainForm;

Implementation

{$R *. DFM}

Procedure TMainForm. TimerTimer (Sender: TObject; LagCount: Integer);
The begin
DXInput1. Update;

If AnalogMode. Checked and ((DXInput1. Joystick. X<> 0) or (DXInput1 Joystick. Y<> 0)) then
The begin
{Analog}
Label1. Left:=Label1. Left + DXInput1. The Joystick. X.
Label1. Top:=Label1. Top + DXInput1. The Joystick. Y;
End the else
The begin
{Digital}
If isLeft DXInput1. In States then
Label1. Left:=Label1. Left - 10;

If isRight DXInput1. In States then
Label1. Left:=Label1. Left + 10;

If isUp in DXInput1. States then
Label1. Top:=Label1. Top - 10;

If isDown DXInput1. In States then
Label1. Top:=Label1. Top + 10;
end;

If isButton1 DXInput1. In States then
The begin
DXWaveList1. Items [0]. Play (False);

{Next, button 1 is invalidated until the button is pushed. 1}
DXInput1. States:=DXInput1. States - [isButton1];
end;

POVLabel. Caption:=Format (' POV (Point of view) : % d ', [DXInput1. Joystick. Joystate. RgdwPOV [0]]).
end;

End.


Test operation me xbox360 handle no problem,

CodePudding user response:

Control's full name?

CodePudding user response:

Keybd_event (VK_CONTROL, MapVirtualKey (VK_CONTROL, 0), 0, 0).//press CTRL health
Keybd_event (word (' F '), MapVirtualKey (word (' F '), 0), 0, 0).//press the f key
Keybd_event (word (' F '), MapVirtualKey (word (' F '), 0), KEYEVENTF_KEYUP, 0).//let go of the f key

CodePudding user response:

reference 5 floor cuiba1105 reply:
control's full name?


DelphiX
  • Related