PDA

View Full Version : DXinput - Implementing user definable controls



Damot
30-03-2007, 04:27 PM
Hi all,

What would you all suggest is the best way of implementing user definable controls for my game?

Do I need to somehow read the complete keyboard state using DXinput when the user selects a key for left/right/up/down etc? Or do I use the form keydown event and convert that somehow?

Should I be querying dxinput.Keyboard.States?

Incidentally, can you just check dxinput1.Keyboard.States to see if any of the keys are pressed? The reason I ask is I had problems trying to check for the ' and / keys before. Any links to the correct scancodes?

Thanks.

seiferalmasy
30-03-2007, 05:59 PM
I made my own system along the lines you suggested by asking the user to input a button on the controller to define control. i set a seperate part for keyboard setting whereby a person clicks inside a edit box (read only edit) and then entered a key.

The code for Keyboard controls is as follows [place the code in editbox keydown event]:


Edit1.text:=inttostr(ord(key) );//this will show the ascii key number
Mainfm.dxinput1.Keyboard.KeyAssigns[isbutton29,0]: =(ord(key));

keyassigns will assign a new key in this instance to isbutton29 and the first of the 3 options for it (0).

I use memo or richedits to save the selectiona dn then load the key back up when the app is run.

-----------
For control you will probably have to set variables such as "input1Player1" and then set those. input1player1 would be a Tdxinputstate