View unanswered posts | View active topics It is currently Sun Sep 15, 2019 2:07 pm



Reply to topic  [ 6 posts ] 
How are keys/buttons stored in zinput.cfg? 
Author Message
New Member

Joined: Thu Aug 18, 2011 4:24 pm
Posts: 4
Reply with quote
Post How are keys/buttons stored in zinput.cfg?
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.


Thu Aug 18, 2011 5:00 pm
Profile
New Member

Joined: Thu Aug 18, 2011 4:24 pm
Posts: 4
Reply with quote
Post Re: How are keys/buttons stored in zinput.cfg?
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?


Thu Aug 18, 2011 6:45 pm
Profile
New Member

Joined: Thu Aug 18, 2011 4:24 pm
Posts: 4
Reply with quote
Post Re: How are keys/buttons stored in zinput.cfg?
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?


Wed Aug 24, 2011 5:44 pm
Profile
ZSNES Shake Shake Prinny
User avatar

Joined: Wed Jul 28, 2004 4:15 pm
Posts: 5615
Location: PAL50, dood !
Reply with quote
Post Re: How are keys/buttons stored in zinput.cfg?
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:
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54


Wed Aug 24, 2011 6:55 pm
Profile
New Member

Joined: Thu Aug 18, 2011 4:24 pm
Posts: 4
Reply with quote
Post Re: How are keys/buttons stored in zinput.cfg?
I was listening, I promise :)

Quote:
<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.


Thu Aug 25, 2011 12:28 am
Profile
ZSNES Shake Shake Prinny
User avatar

Joined: Wed Jul 28, 2004 4:15 pm
Posts: 5615
Location: PAL50, dood !
Reply with quote
Post Re: How are keys/buttons stored in zinput.cfg?
They were chosen arbitrarily.

Code:
        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:
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)

Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54


Thu Aug 25, 2011 6:05 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.