> PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
> PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
> PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
> PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
> The default state and inputmask is the sum of all the port_bits that you are grouping
> together; in this case, u/r/d/l... 1+2+4+8=15, which is f in hex (10=a, 11=b, etc.)
> The state in the element for each position is the sum of all the inputs, minus the
> input you are defining... so RIGHT = 15-2 = 13 = d... UP+LEFT = 15-1-8 = 6
This is not strictly true.
It's true for Bosconian, but your "subtraction" method only holds true if the input definition uses IP_ACTIVE_LOW.
The part that I think you're missing here, and might be helpful to know, is to think of things not in terms of decimal values, or even hexadecimal values to start with, and consider the underlying binary instead.
Modern convention when writing binary numbers is to have the most significant (highest-value) bit to the left, and the least significant (lowest-value) bit to the right. Just like writing any other number, really.
The difference between IP_ACTIVE_HIGH and IP_ACTIVE_LOW is simply which value (0 or 1, respectively) is used to represent a given input "at rest" within the overall port.
Here's where thinking of it as a binary number comes in handy. You can write yourself out a little chart, like this (using Bosconian's input definition as a template):
This represents the state of the input port at rest, because as said above, IP_ACTIVE_LOW means that the corresponding bit will have a value of 1 when at rest.
Just like how each successive digit in a decimal number is worth 10 times the one to the right, each successive digit in a binary number is worth 2 times the one to the right. Just as with decimal, the rightmost position is the "one's" digit. So, going from right to left, we can calculate:
1 + 1*2 + 1*2*2 + 1*2*2*2
1 + 1*2 + 1*4 + 1*8
1 + 2 + 4 + 8 = 15
Now, let's use the chart method to represent Down-Right on the joystick:
1 + 0*2 + 0*2*2 + 1*2*2*2
1 + 0*2 + 0*4 + 1*8
1 + 1*8
1 + 8 = 9
Lastly, the reason for my suggestion to go with a binary representation in your head is that it makes it much easier to convert between binary and hexadecimal. Why? Because rather than having weirdness when representing digits - where a single-digit hex value of "F" becomes a two-digit decimal value of "15", you can convert every group of four bits into a single hex digit:
This same property holds true for longer strings of binary numbers:
1101 1110 1010 1101 1011 1110 1110 1111
D E A D B E E F
Anyway, I don't know if any of this helps to demystify the underlying principles any, or if I've just managed to confuse you more, but hey.