Skip to content

Instantly share code, notes, and snippets.

@andersstorhaug
Last active February 3, 2021 15:23
Show Gist options
  • Select an option

  • Save andersstorhaug/38ceadbae32790c08c8b130cb4a8486b to your computer and use it in GitHub Desktop.

Select an option

Save andersstorhaug/38ceadbae32790c08c8b130cb4a8486b to your computer and use it in GitHub Desktop.
M2 emulator `.input` files

M2 Emulator binary .input files

Each 4 bytes correspond to an input, in display-order for a specific game.

The file ends with 8 bytes of 00 or 01 flags.
These signify whether an analog input in display-order is enabled.

Keyboard

For keyboard keys, the first byte corresponds to a DirectInput scan code, and bytes 2-4 are 0.

Joypad

For any joypad input, the 2nd nybble of the 2nd byte is the joypad number, starting from 1.

For joypad hats:

  • The first byte is the hat and direction
    • 00 for hat 1 left
    • 01 for hat 1 right
    • 02 for hat 1 up
    • 03 for hat 1 down
    • 04 for hat 2 left
    • 05 for hat 2 right
    • 06 for hat 2 up
    • 07 for hat 2 down
    • (and so forth for additional hats)
  • Bytes 3-4 are zero

For joypad buttons:

  • The first nybble is the button number (1 - F, apparently limited to 16 buttons)
  • The second nybble is 0
  • Bytes 3-4 are zero

For joypad analog inputs:

  • The first byte is the axis
    • 00 for X
    • 01 for Y
    • 02 for RZ
    • 03 for Z
    • 04 for RX
    • 05 for RY
    • 06 for S1 (untested)
    • 07 for S2 (untested)
  • The first nybble of the 2nd byte is a 0 or 1 inversion flag
  • Bytes 3-4 are 00 FF

Examples

4-byte inputs:

  • 02 00 00 00 is keyboad 1
  • 10 01 00 00 is joy 1 button 1
  • 10 02 00 00 is joy 2 button 1
  • 01 01 00 00 is joy 1 hat 1 right
  • 05 01 00 00 is joy 1 hat 2 right
  • 01 01 00 FF is joy 1 Y-axis
  • 01 11 00 FF is joy 1 Y-axis inverted

8-byte file endings:

  • 01 00 01 00 00 00 00 00 specifies that the first and third inputs with checkboxes have analog enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment