Archived

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

How to correctly assign keys with delphix ? (Newbie)

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

Hi, Another newbie question please. I''ve had great success figuring Delphix out, but I''m not sure how to correctly assign/detect key presses. I want my player to be able to use the cursor keys and "ZX''/" in my Repton clone, but I''m not sure how to reassign these keys for "isUP","IsDown" etc... I''m detecting movement with "if IsUp then etc"... Delphix defaults to "GHJK" for an alternative to the arrow keys. I can''t seem to find and answer to this very basic question anywhere! Thanks in advance... dbok

Share this post


Link to post
Share on other sites
Here''s what happening by default in DelphiX


  
function DefKeyAssign: TKeyAssignList;
begin
FillChar(Result, SizeOf(Result), 0);

AssignKey(Result, isUp, [Ord(''K''), VK_UP, VK_NUMPAD8]);
AssignKey(Result, isDown, [Ord(''J''), VK_DOWN, VK_NUMPAD2]);
AssignKey(Result, isLeft, [Ord(''H''), VK_LEFT, VK_NUMPAD4]);
AssignKey(Result, isRight, [Ord(''L''), VK_RIGHT, VK_NUMPAD6]);
AssignKey(Result, isButton1, [Ord(''Z''), VK_SPACE]);
AssignKey(Result, isButton2, [Ord(''X''), VK_RETURN]);
AssignKey(Result, isButton9, [VK_F2]);
end;
....
DXInput.KeyBoard.KeyAssigns:=DefKeyAssign;


To change the keyconfig you can declare your own KeyAssignList object (doesn''t need a constructor, its a static object), use the AssignKey procedure to set it up and then assign it to KeyBoard.KeyAssigns

Share this post


Link to post
Share on other sites
Thanks for your reply.

I had already tried that by looking at the original source
and working it out, however, I assumed I''m doing something wrong because if I do....


-------------

function REPTONkeys: TKeyAssignList;
begin
FillChar(Result, SizeOf(Result), 0);

AssignKey(Result, isUp, [39), VK_UP, VK_NUMPAD8]);
{ 39 IS '' }
AssignKey(Result, isDown, [Ord(''/''), VK_DOWN, VK_NUMPAD2]);
AssignKey(Result, isLeft, [Ord(''Z''), VK_LEFT, VK_NUMPAD4]);
AssignKey(Result, isRight, [Ord(''X''), VK_RIGHT, VK_NUMPAD6]);
AssignKey(Result, isButton1, [Ord(''Q''), VK_SPACE]);
AssignKey(Result, isButton2, [Ord(''W''), VK_RETURN]);
AssignKey(Result, isButton9, [VK_F2]);
end;
....
DXInput.KeyBoard.KeyAssigns:=REPTONkeys;


---------------

The game works with ZX''/ but the RIGHT arrow key (NOT KEYPAD)
makes me go up as well. Ie, sets isUP . ???????

I don''t understand why?

tHANK,


David

Share this post


Link to post
Share on other sites
The reason things like Ord(''Z'') don''t work is that the KeyAssign expects 2 byte word values (keyboard scancodes), and you''re giving one byte ascii values. Using the Windows SDK (Help->Windows SDK), lookup the page about scancodes (or do a search for VK_A and click see also). Basically you need to use the VK constants listed on that page (inthe help file) rather than ascii codes. In this case Ord(''Z'')=VK_Z.

Share this post


Link to post
Share on other sites