kodi-game / controller-topology-project

The Controller Topology Project models how controllers connect to and map to each other for all gaming history
Open Data Commons Open Database License v1.0
21 stars 15 forks source link

[Feature Request] Default game controller mappings for analog and digital Gameport/MIDI joysticks supported via Necroware GamePort to USB Adapter (open source hardware/firmware project)? #196

Open Hedda opened 1 year ago

Hedda commented 1 year ago

Request you consider adding out-of-the-box default game controller profiles (mappings) to Kodi for the retro analogue and digital "game port" joysticks/gamepads that are supported and been tested with the open-source Necroware GamePort to USB Adapter.

Open-source hardware as featured on Hackaway.io and Adafruit's blog:

image

Necroware GamePort to USB Adapter (as in a game-port DB15 MIDI interface to USB-port converter) is fully open-source hardware. It has extremely low input lag latency and has been tested by the developer on Linux, Mac, Windows 98/XP/10, as well as on Android. All that is needed is Arduino drivers.

The project uses a very simple hardware design in combination with open-source software (C++ firmware for Arduino) for retro Gameport/MIDI analogue and digital joysticks and gamepads (as well as gaming steering wheels). Note! It uses the standard-density 2-row DB-15 / (female / DB15F) connector that is used as a game port for gamepad and joystick connections, not the high-density 3-row connectors used for VGA connections.

Using an open-source firmware written in pure C++ programming language it can be extended to support even more joysticks/gamepads by anyone with the needed programming skills, and as of January 2023 so far it features support for 14 specific popular retro game controllers + an unknown number of rebranded or unbranded retro game controllers and which use the same or generic game controller protocols.

The adapter can easily be a DIY build that you can very easily make yourself on a breadboard, or you can buy either PCB board/kit version or fully prebuilt/preassembled versions online from various resellers and sources, for example; Tindie and eBay.

Examples of resellers of prebuilt/preassembled versions of Necroware GamePort adapter (the USB-C variant recommendedd):

Note! It is not recommended to buy the Mini-USB variant of Arduino Pro Micro as its header is wider than USB-C and Micro-USB variants), and it is not recommended to buy the Micro-USB variant of Arduino Pro Micro as it is too easy to break the connector.

More links and information:

https://twitter.com/necro_ware/

Forum thread -> https://www.vogons.org/viewtopic.php?f=24&t=81547 (also see this other related forum thread about an older competing adapter -> http://descentbb.net/viewtopic.php?t=15526 )

https://github.com/necroware/gameport-adapter/blob/main/README.md

How does it work?

The adapter is built around Arduino Pro Micro development board (though you could alternativly also make a DIY build using Arduino Leonardo), which uses the same ATmega32U4 microcontroller as Leonardo. This microcontroller has built-in USB HID capabilities and can be used to build HID input devices, like joysticks.

The adapter itself is super simple, the main brainwork was invested into the software. Very much simplified, it reads the joystick states and sends the data, via USB, to the computer, which thinks that it is communicating with a USB joystick.

What is special about this one?

There are already plenty of gameport to USB adapters for basic analog joysticks and, as far as I know, there were some efforts to communicate with Sidewinder joysticks by Microsoft as well. But there is no universal adapter, which would work with different types of joysticks. This adapter implements multiple drivers for various analog and digital joysticks, with an option to add more, in the future.

Features overview:

What is the difference between analog and digital joystick?

Many people call button-only joysticks or gamepads digital. This is kind of right, because a button is either pressed or not. You can't have an analog values in between. However by digital, in this case, we mean something different. A gameport contains 15 pins, 8 of which are used for joystick communication. 4 pins are for buttons and carry digital values in sense of on/off and 4 pins are for analog axes, which deliver voltage somewhere between 0V and 5V. Joysticks which were made in the early days used this pinout. They could have a maximum of 4 buttons and 4 axes and were DOS compatible. Later, in the time of Windows 95/98 many joysticks were made to be plugged into a gameport as well, but they were not limited to 4 buttons and 4 axes. They had a lot more exciting features, like hat switches and throttle controls. But how did this work? Well the manufacturers implemented their drivers to communicate with the joystick via gameport using a proprietary communication protocol. For example, by using one pin of the gameport as clock and another one as data, the possibilities were almost limitless. Such joysticks are called digital as well, because they used digital protocols to communicate with the PC. And suddenly, many features were possible, but the price of these features was the lost compatibility to DOS. You couldn't just plug such a joystick into the gameport and expect it to work in old DOS games. The plug was the same, but the signaling was completely different.

Which joysticks does this adapter support?

Currently, the following drivers are implemented. To select the right driver, you have to use four switches, as shown in the table. The switches may be changed or extended in the future, so please pay attention to the updates.

Joystick Model Buttons Axes Hat SW1-4 Comments
Generic Analog 2 2 0 0000
Generic Analog 4 2 0 1000
Generic Analog 4 3 0 0100 3rd Axis is throttle
Generic Analog 4 4 0 1100
CH FlightStick 4 4 1 0010 Analog, DOS-compatible
CH F16 Combat Stick 10 3 1 0110 Analog, DOS-compatible
ThrustMaster 4 3 1 1010 Analog, DOS-compatible
Sidewinder GamePad 10 2 0 1110 Digital protocol
Sidewinder 3D Pro 8 4 1 1110 Digital protocol
Sidewinder 3D Pro Plus 9 4 1 1110 First version of Precision Pro
Sidewinder Precision Pro 9 4 1 1110 Digital protocol
Sidewinder FFB Wheel 8 3 0 1110 Digital, FFB not yet implemented
Gravis GamePad Pro 10 2 0 0001 Digital protocol (GrIP)
Logitech WingMan Extreme 6 3 1 1001 Digital protocol (ADI)
Logitech CyberMan 2 8 6 0 1001 Digital proticol (ADI)

Remarks:

Which joysticks were tested?

Many joysticks in the wild are using the same digital protocol or are backwards compatible to the analog joysticks as they were used back in the days in DOS. Following list contains all the devices wich were reported by others as working so far:

Sidewinder 3D Pro can be switched between analog and digital mode and in analog mode it can emulate the ThrustMaster and CH FlightStick. That's why you see them in the table above. Unfortunately I don't possess those joysticks in reality, so it may be that the implementation is not quite correct.

Hedda commented 1 year ago

The adapter can easily be a DIY build that you can very easily make yourself on a breadboard, or you can buy either PCB board/kit version or fully prebuilt/preassembled versions online from various resellers and sources, for example; Tindie and eBay.

Examples of resellers of prebuilt/preassembled versions of Necroware GamePort adapter (the USB-C variant recommendedd):

Note! It is not recommended to buy the Mini-USB variant of Arduino Pro Micro as its header is wider than USB-C and Micro-USB variants), and it is not recommended to buy the Micro-USB variant of Arduino Pro Micro as it is too easy to break the connector.

FYI, as this is open-source hardware you should know as an option that it is today relatively easy and inexpensive to just submit the KiCad PCB layout files directly to some PCB-prototype board manufacturers like Oshpark or PCBWay who will take it then make + ship a few of the PCB boards to you, all without you having to use KiCad yourself or even having to understand the PCB layout:

Kicad format project is used for the board -> https://github.com/necroware/gameport-adapter/tree/main/kicad

FYI, Chinese PCB manufacturers will usually make around 20 simple PCB board like this for less than $10 and ship them to you for around $20, so depending on your country's import tax you have those at home for around $30-40 in around a months time.

It is then relatively easy for most hobby/amateur-tinkers to solder the parts by hand as it only has very few simple component:

https://www.youtube.com/watch?v=HUmbvfqP784&ab_channel=chadaustinak

E.i. just buy the ones from the project BOM (Bill-Of-Matierials) list

https://github.com/necroware/gameport-adapter/blob/main/README.md#bill-of-materials-bom

Note! It is not recommended to buy the Mini-USB variant of Arduino Pro Micro as its header is wider than USB-C and Micro-USB variants), and it is not recommended to buy the Micro-USB variant of Arduino Pro Micro as it is too easy to break the connector.

Bill of materials (BOM)

The hardware is super simple. To build an adapter you'll need the PCB from this project and following parts:

Part Qty LCSC # Digikey # Mouser Electronics # Comment
CONN1 1 C77835 609-5371-ND 523-L77SDA15SA4CH4F DB15 female connector
R1..R4 4 C172965 13-MFR-25FTE52-100KCT-ND 603-MFR-25FTE52-100K 100 kOhm resistors
SW1 1 C15781 2449-KG04ET-ND 642-DS04T DIP-4 switch
U1 1 C72120 ED3051-5-ND 649-DILB24P-223TLF DIP24 Socket (optional)
U1 1 N/A 1568-1060-ND 474-DEV-12640 Arduino Pro Micro (ATmega32U4 16MHz, 5V), including two 12 pin header connectors, MicroUSB version (see "Known issues")

Tip! Some other user recommended buying an enclosure case: Hammond Manufacturing 1551RTBU, Digi-Key Part # HM1142-ND.

You can otherwise 3D-print your own case, see example -> https://www.thingiverse.com/thing:5457006

Firmware

Once you have it and want to flash the firmware yourself (to ensure you have the latest version), you can do that yourself as well.

  1. Download source code files from -> https://github.com/necroware/gameport-adapter/tree/main/firmware/gameport-adapter
  2. Download the Arduino IDE from -> https://www.arduino.cc/en/software
  3. Connect the Adapter with your USB cable.
  4. Open "gameport-adapter.ino" included in the source files.
  5. In "Tools" -> Port -> select the virtual COM port that says (Arduino Micro).
  6. In "Sketch" -> select "Upload" which will compile the firmware and upload it to the Arduino.
  7. You done.