Archived

This topic is now archived and is closed to further replies.

DXInput in DelphiX

This topic is 5978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

First of all you need to make a procedure to assign keys to a TKeyAssignList.:-

//####################
procedure AssignKey(var KeyAssignList: TKeyAssignList; State: TDXInputState;
const Keys: array of Integer);
var
i, i2: Integer;
KeyAssign: PKeyAssign;
begin
KeyAssign := @KeyAssignList[State];
FillChar(KeyAssign^, SizeOf(TKeyAssign), 0);

i2 := 0;
for i:=LOW(Keys) to HIGH(Keys) do
begin
if i2<3 then
KeyAssign^[i2] := Keys[i*]//remove the *
else
Exit;
Inc(i2);
end;
end;
//###################


Then in your form create (or whereever) you make a new keylist and set DXInpout to use the new Keylist:

//#####################
procedure TMainForm.FormCreate(Sender: TObject);
var
KeyList :TKeyAssignList;
begin
FillChar(KeyList, SizeOf(KeyList), 0);

AssignKey(KeyList, isUp, [Ord('K'), VK_UP, VK_NUMPAD8]);
AssignKey(KeyList, isDown, [Ord('J'), VK_DOWN, VK_NUMPAD2]);
AssignKey(KeyList, isLeft, [Ord('H'), VK_LEFT, VK_NUMPAD4]);
AssignKey(KeyList, isRight, [Ord('L'), VK_RIGHT, VK_NUMPAD6]);
AssignKey(KeyList, isButton1, [Ord('Q'), VK_SPACE]);
AssignKey(KeyList, isButton2, [Ord('X'), VK_RETURN]);
AssignKey(KeyList, isButton9, [VK_F2]);

DXinput1.Keyboard.KeyAssigns:=KeyList;
end;
//###########################


Hope this helps.

EDIT: seems the forum code tried to replace a few bits

-Sav


Edited by - Savvy on August 5, 2001 1:51:30 AM

Share this post


Link to post
Share on other sites