How are keys/buttons stored in zinput.cfg?

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.freenode.net in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
davejuk
New Member
Posts: 4
Joined: Thu Aug 18, 2011 4:24 pm

How are keys/buttons stored in zinput.cfg?

Post by davejuk »

Hi

I am writing a little application to modify the controller configuration of ZSNES by manipulating the zinput.cfg

However I am struggling to understand how the values are stored. This is what I think I have figured out so far.

0 = Unassigned
1-255 = Keyboard keys (ASCII codes?)
256+ = DirectX Joystick buttons (256=DPADRight)

Can anyone give me a better explanation of how the values are calculated?

Thanks.
davejuk
New Member
Posts: 4
Joined: Thu Aug 18, 2011 4:24 pm

Re: How are keys/buttons stored in zinput.cfg?

Post by davejuk »

OK so I think I understand the formula now...

256 + (joypad_id * 32) + button_value

I can get the joypad_id from Joystick.Properties.JoystickId() but where do I get the button value?
davejuk
New Member
Posts: 4
Joined: Thu Aug 18, 2011 4:24 pm

Re: How are keys/buttons stored in zinput.cfg?

Post by davejuk »

48 views... can no one help me with this?

Where do I get the button ID's?

Are they generated by DirectX or are they assigned internally?
grinvader
ZSNES Shake Shake Prinny
Posts: 5622
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: How are keys/buttons stored in zinput.cfg?

Post by grinvader »

dood, we covered this in irc. read the sourcefile i told you about - all the 'button_value's are in there. you 'get' them by reading. with your eyes.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
davejuk
New Member
Posts: 4
Joined: Thu Aug 18, 2011 4:24 pm

Re: How are keys/buttons stored in zinput.cfg?

Post by davejuk »

I was listening, I promise :)

<grinvader> read winlink.cpp:2730-2889


I'm struggling to understand what's going on in the source. I understand how the 1-255 corresponds to the ASCII codes but I really can't see where the gamepad button IDs are coming from.
grinvader
ZSNES Shake Shake Prinny
Posts: 5622
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: How are keys/buttons stored in zinput.cfg?

Post by grinvader »

They were chosen arbitrarily.

Code: Select all

        if (!X1Disable[i])
        {
          if (js[i].lX > 0)
          {
            keys[0x100 + i * 32 + 0] = 1;
          }
        }

This means that 'button_value' 0 is tied to "X1". In the same manner, bv 1 is tied to X2, bv 2 is tied to Y1, bv 3 is tied to Y2, and so on. POVs are also tied to button values 0-3 since they both control direction (analog sticks or d-pad). Throttles and sliders look mapped to bv 10-13 and face buttons to bv 16 and up.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Post Reply