Jump to content
  • Advertisement

Archived

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

mrman131

DXInput in DelphiX

This topic is 6194 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

When readings tutorials on DXInput, they say of being able to edit the 32 buttons for the keyboard. How would one go about assigning these buttons to keys?

Share this post


Link to post
Share on other sites
Advertisement
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
thanks, that works. you just had one typo.
KeyAssign^[i2] := Keys
should be
KeyAssign^[i2] := Keys

The rest is great, really appreciate it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!