Skip to content

Latest commit

 

History

History
190 lines (161 loc) · 9.84 KB

readmeEnglish.md

File metadata and controls

190 lines (161 loc) · 9.84 KB

Gamepad decoder DTMF


Thanks to the MT8870 chip, connecting the outputs of STQ, Q4, Q3, Q2 and Q1 to a transistor allowing to open or close the buttons of a GAMEPAD, DTMF tones can be decoded. We only ineed 5 pins (control buttons). It has been created as proof of concept a simple program in VB6 (to work in old equipment W95) to be able to read the buttons and translate it to DTMF tones. The program is not optimized, so send the tones slowly. You can use the web generator http://mamclain.com/?page=RND_SOFTWARE_DTMF_WEB_APP

Can be tested with Windows' own joystick tester

It is recommended to put 500 ms in the ms Delay Between Digits at the time of sending.

So far we have the hardware logic part. Therefore, we enter in the section to build an application that translates the button presses in the binary codes that at the end are DTMF codes.

  • 0001 1
  • 0010 2
  • 0011 3
  • 0100 4
  • 0101 5
  • 0110 6
  • 0111 7
  • 1000 8
  • 1001 9
  • 1010 10 0
  • 1011 11 *
  • 1100 12 #
  • 1101 13 A
  • 1110 14 B
  • 1111 15 C
  • 0000 16 D
The program in Visual Basic, allows to select which buttons we want to use of the control as well as to which pin of the MT8870 is associated. The command that has been used has been opted for:
  • STQ (10)
  • Q4 (01)
  • Q3 (X1) I used the crosshead to move analog right
  • Q2 (Y1) I've used the crosshead to move down analog
  • Q1 (9)

X1 and Y1 are the X and Y axes (analog). In this case, it is so because I have used the NES usb retro controller and only 4 digital buttons are available, being the analogical cross. On ASIX (axes) it is not possible to press left and right at the same time, as well as up or down (take it into account when soldering), as well as the 4 buttons, I recommend using all digital buttons, and the STQ always use digital.

In the readings of the Asix (X1 and Y1) being analogical a value greater than 33768 is checked by code so that it is a logical 1, since it means that we have pressed the button or to the right (greater than 32768 that would be the center) or downwards.

The concept is very simple, being the most difficult part in the manualities, to leave the control well prepared. The MT8870 can be powered with the 5 volts of usb, which we can take out following the cables of the control with a mulitester. The mass follows the same concept. The buttons of the controls, usually join 2 circuits, leaving the mass in common. To be sure we will look with a multitester the mass. What we are interested in is soldering the part of the button that is not mass. That part will go to the transistor collector. Since masses are common, we don't need to weld all those parts. At the base of each transistor, we must connect a resistance of 100 Ohms, as protection. The transistor is worth any NPN, in particular I have used the 2N3904, which is the simplest and cheapest to get. Each output of the MT8870 (STQ, Q4, Q3, Q2 and Q1), goes to the resistance of 100 Ohms, and this in series goes to the base of the transistor (2N3904), while the collector joins it to the part of the button of the control that we want to activate and the emitter to the mass of the control.

It is necessary to emphasize, that the cheaper the control, the less possibilities exist that it is possible to weld well to the part of the button, reason why we will have to make sure to put once welded of simple way, glue above to make pressure.

Then we make a hole with the drill to be able to introduce the audio jack of the MT8870 module when we want to connect it so that it looks good, and finished:

Once we test the program, we must hit the button start joystick and of course have the gamepad connected. If everything is correct, and the buttons have been chosen correctly, we will see the status of up to the first 24 buttons of the gamepad and below all DTMF codes that are decoded in real time, the sound source that we have connected.

RETRO

There is also available a retro version (GAMEPAD.PAS) compatible with 8086, to work in any old equipment (IBM PC XT), as well as emulated by means of the DOSBOX, which means that it works in almost any platform, as for example ANDROID. The prototype is in PASCAL.

The joystick port is used with the interruption 0x15h, using only the 3 high bits 01110000b of the buttons, similar to the version of VB6, but here you can not modify the buttons.
  • STQ (bit 7)
  • Q4 (bit 6)
  • Q3 I used the crosshead to move analogical right
  • Q2 I used the crosshead to move down analog
  • Q1 (bit 5)

We must then remap from the DOSBOX (press ctrl+F1) joystick buttons 1 and 2, so that the buttons of our real gamepad point to the virtual joystick to emulate (IBM PC):

  • 1 (Axis 1/2) - Q1
  • 2 (Axis 1/2) - Q4
  • 3 (Asix 3/4) - STQ
  • right cross - Q3
  • cross down - Q2

As you work from an emulator, there is a lag, that if tones occur very closely without separation (silence), does not detect a change of pulse in STQ, so it will not detect the digit well. It is recommended to use the DTMF keyboard generator by hand, because there if you enter silence.

I left a minimum version (228 bytes), but it is faulty. It is made in C--, but its size can be reduced even more.

ARDUINO HID

If you have an Arduino R3 ATMEGA328 board with the ATMEGA 16u2 communications chip, you can use the modified code big_joystick_dtmf to emulate a joystick with 40 HID buttons, which are activated by the MT8870 signals we have connected to the pins:

  • stq - 2
  • q4 - 3
  • q3 - 4
  • q2 - 5
  • q1 - 6

The buttons on the remote are:

  • stq - 10
  • q4 - 1
  • q3 - 2
  • q2 - 3
  • q1 - 4

It is required to previously flash the chip ATMEGA16u2 with:

https://github.com/harlequin-tech/arduino-usb

Use the FLIP tool and put the chip in DFU mode.


I have created an html5 version that reads from the gamepad. It makes use of p5js.

I created a very simple program to read from the game port of the AMSTRAD CPC 464 in BASIC. It allows to decode the tones following the same concept seen until now. I have tested it in emulator, so you have to remap the buttons or adapt the code to assign the correct pins:

  • stq - Right
  • q4 - Up
  • q3 - Fire 1
  • q2 - Left
  • q1 - Down

To remap the buttons I used the antimicro program https://github.com/AntiMicro/antimicro And the Winape emulator.
I made a very simple program that reads the status of the buttons on the PSX controller. I have made it in emulator and remapping the buttons that I need. The psyq development kit has been used.

  • stq - Select
  • q4 - R2
  • q3 - Triangle
  • q2 - Square
  • q1 - Circle

Conclusion

With this we get to be able to decode DTMF with a control, without lack of any intermediate microcontroller, and most importantly, that the concept can be applied to old gamepads (MIDI connector), and retro equipment (MSDOS), as well as new, such as mobile, being able to portray the concept to HTML5.

If we do not want to compile the program, we can make use of the already compiled version GamePadDTMF.zip

Historical

  • 2019/12/05 PSX port (psyq)
  • 2019/12/04 AMSTRAD CPC 464 port
  • 2019/07/23 HTML5 port
  • 2019/07/21 Arduino R3 ATMEGA16u2 big_joystick_dtmf converts MT8870 into HID joystick
  • 2019/04/23 The world's smallest version of MSDOS and DOSBOX has been created in C-- (228 bytes)
  • 2019/04/22 Corrected version MSDOS (PASCAL) works OK
  • 2019/04/19 Version for MSDOS and DOSBOX (PASCAL).
  • 2019/04/18 Semioptimized version that allows to decode up to 150 milis of waiting