What's new

[DirectInput] How to save/store custom settings

Falcon4ever

Plugin coder / Betatester
heya guys,

I've been busy creating a inputplugin and everything seems to work proper for me, but since other joypads needs other button/axis mapping i need some help how to store this kind of information.

First the mapping of my pad:
Code:
// Logitech Rumblepad 2 USB with ForceFeedback
// Button placements are like ps2

// Pad buttons (0x00 or 0x80)
js.rgbButtons[0];  // Joypad Button 1				BYTE
js.rgbButtons[1];  // Joypad Button 2				BYTE
js.rgbButtons[2];  // Joypad Button 3				BYTE
js.rgbButtons[3];  // Joypad Button 4				BYTE
js.rgbButtons[4];  // Joypad Button 5				BYTE
js.rgbButtons[5];  // Joypad Button 6				BYTE
js.rgbButtons[6];  // Joypad Button 7				BYTE
js.rgbButtons[7];  // Joypad Button 8				BYTE
js.rgbButtons[8];  // Joypad Button 9, select		BYTE
js.rgbButtons[9];  // Joypad Button 10, start		BYTE

js.rgbButtons[10]; // Joypad Button 11, Analog left press (L3)	BYTE
js.rgbButtons[11]; // Joypad Button 12, Analog right press (R3)	BYTE

// Analog Left (Range 0x0000 to 0xFFFF)
js.lX; // X-axis Joypad Analog left				LONG
js.lY; // Y-axis Joypad Analog left				LONG

// Analog right (Range 0x0000 to 0xFFFF)
js.lZ;  // X-axis Joypad Analog right				LONG
js.lRz; // y-axis Joypad Analog right				LONG

// D-Pad
js.rgdwPOV[0];	// Joypad D-Pad (8 values/states)		DWORD

Well this is currently my mapping, but it seems that some joypads are using alternative axises for the 2nd analog. (like lRx or lRy).
(Storing the buttons and pov's isn't causing me trouble, because i can use int's to store them)

How should i store information or smth pointing to for example js.lY ?
I guess i need to map smth to js.XXX

Could someone help me out here? (Btw i don't need scripts which stores the values to a register of ini file because that part is already done ;) )
 
Last edited:

BGNG

New member
I would personally store each value with an additional byte or two designating its origin. Something like 0=Keyboard, 1=Mouse, 2 and up = Joypads, etc. As for the joypad itself, you could also have an identifier for where the value comes from, like 0=Button, 1=Axis X, 2=Axis Y, 3 and up = additional axes, etc. Then for directions, you can say things like 0=Negative, 1=Positive, etc.

So let's say "Left" on the input is mapped with "Negative X Axis" on joypad 0. You could say 0x00020100 as the value, corresponding to Joypad 0, X axis, negative. And there you have your storage.

Or mabye you could use 0x00000104, perhaps, which could represent 01=Mouse, 04=Wheel Up...
__________

Since most inputs for controls aren't specific for the values (for joysticks, half-way to the left and totally to the left are both "X Left"), you don't need to make compensations for all possible values. You can construct a pseudo mapping which corresponds to a certain value on a real input device.
 

Top