====== Description ====== Joy2PS2 is a versatile interface designed to connect one or two gamepads from various retro platforms. This solution converts and redirects gamepad events into keyboard strokes to a PS/2 port. You'll find this type of port on old PCs and some modern ones, as well as on recent devices like the Next or the ZXUno, the latter being the platform for which it was initially designed. This interface is highly compatible and adaptable, including several keyboard maps in its firmware to facilitate interaction with different systems. Note: As of release 2, Joy2PS2 is compatible with real PCs that use a PS/2 connection. {{::case_joy2ps2.jpg?600|}} The original design of the logo and casing for Joy2PS2 version 2.3 was created by [[https://twitter.com/mejias3d|Jorge Mejias Cazorla]]. [[https://www.flickr.com/photos/133386349@N08/shares/13m92J|Photos of the casing and PCB of Joy2PS2 version 2.3]] {{:snes_joy2ps2.jpg?400|}} [[http://www.zxuno.com/forum/viewtopic.php?f=25&t=1625|Integrated version in an SNES controller designed by Antonio Villena]] [[https://www.youtube.com/watch?v=GII2eh_ROhA|Demo of Joy2PS2 version 1.0, using the old Arduino firmware]] ====== Controls ====== The gamepads compatible with the interface include: Atari, NeoGeo OldStyle, MSX, Amstrad CPC, VIC 20, Sega Master System, Sega Megadrive (3 or 6 buttons), Amiga, ZX Spectrum, and NES Famicom DB9. All of these can be directly connected to DB15 or DB9 sockets. However, some like the MSX, will require a special adapter to use the third button. You can enter a special state called SHIFT at any time using any of the following combinations: * Pressing Start + Button 1 * Pressing Select + Start * Pressing and releasing the Keymapper key (necessary only for gamepads without a Start button) In SHIFT mode, it might seem like none of the buttons are working, but this is not the case. In this mode, actions are triggered by pressing button 1 on the gamepad as the final event. To exit SHIFT mode, you can press a SHIFT combination again or press button 2 on the gamepad. Note: The combinations described are performed by pressing and releasing the buttons, not holding them down. Any change in direction resets the count of other actions: * Button 1 only: Switches cursor controls to OPQA and back on Joystick 1 (the main one). [[https://dokuwiki.aitorgomez.net/doku.php?id=joy2ps2_en#keyboard_maps|Keyboard Maps]] * Button 2 only: Cancels SHIFT mode. You can also cancel it by pressing the SHIFT combination again. {{:shiftmode_zxuno.png?800|}} ===== ZXUno Reboot ===== Below are the sequences for rebooting the ZXUno through the SHIFT mode: * **Down once, then button 1**: Reset. Automatically switches to cursor mode * **Down twice, then button 1**: MasterReset. Automatically switches to cursor mode. * **Down three times, then button 1**: MasterReset and access to ROMs. Automatically switches to cursor mode. * **Down four times, then button 1**: MasterReset and access to cores. Automatically switches to cursor mode. * **Down five times, then button 1**: MasterReset and access to BIOS. Automatically switches to cursor mode. * **Down six or more times, then button 1**: Continues with the option of five times. ===== Game Menu ===== The following sequences enable navigating the game menu using SHIFT mode: * **Up once, then button 1**: Triggers the 'R' key. * **Up twice, then button 1**: Triggers the '0' key. * **Repeat up followed by button 1**: Continues sequentially from '1' to '9', where it holds. ===== Game Loader ===== Use the following sequences in SHIFT mode to load games: * **Right once, then button 1**: Activates the NMI. * **Right twice, then button 1**: Executes the 'LOAD ""' keys (128k mode). * **Right three times, then button 1**: Executes the 'J ""' keys (load"" in 48k mode). * **Right four times and subsequent**: Continues with the option from three times. ===== Extra Functions ===== The following functions can be activated in SHIFT mode using the sequences described: * **Left once, then button 1**: Activates Keyboard Mode (details below). * **Left twice, then button 1**: Executes the Escape function (useful for single-button joysticks, used in conjunction with the Keymapper button as shift). * **Left three times, then button 1 for player 1 or 2**: Changes the keyboard map for the corresponding player (see details of available maps below). * **Left four times, then button 1**: Changes video mode (Scroll / Lock). * **Left five times and subsequent**: Continues with the video mode option. ===== Switching between DB15/DB9 and DB9x2 ===== To toggle between DB15/DB9 and DB9x2 configurations, follow these steps while in SHIFT mode: * Press and hold button 1, then press button 2. The selected configuration will persist even after a warm reboot of the ZXUno. ===== Scancode Timing ===== From release 3, the half-clock and clock times for sending Scancodes on the ZXUno, after a cold or warm reboot, comply with the standards of a real keyboard, being 16 and 32 microseconds respectively. * **In SHIFT mode, holding Start and pressing UP**: Decreases the times in multiples of four, to a minimum of 4 and 8 microseconds. * **In SHIFT mode, holding Start and pressing DOWN**: Increases the times in multiples of four, to a maximum of 16 and 32 microseconds. ===== Host Command Listening Enable / Disable ===== From release 5, the host command listening function on the ZXUno is disabled by default and after any reboot, whether cold or warm. * **To enable listening**: In SHIFT mode, press and hold button 1, then press the right key. * **To disable listening**: In SHIFT mode, press and hold button 1, then press the left key. * **To keep listening enabled temporarily**: Stay in SHIFT mode. Listening will automatically disable after the keyboard initialization." ====== Keyboard Mode (KEYSTROKES) ====== This mode allows direct interaction with the keyboard through the following commands: * **Up**: Changes to the next key and prints the character on the screen. * **Down**: Changes to the previous key and prints the character on the screen. * **Left**: Deletes the previous character. * **Right**: Accepts the current character or inserts a space. * **Button 1**: Switches to the key corresponding to the right shift key (for typing uppercase letters or special characters). * **Button 2**: Functions as the Enter key. * **To exit the mode**: Enter SHIFT mode and choose another option, or exit SHIFT mode if already inside. [[https://youtu.be/Av-fX18Ev8M|Hello World' Example in Keyboard Mode]] ====== Official Firmware ====== To upgrade to the latest [[https://github.com/spark2k06/zxuno/tree/master/joy2ps2|Official Firmware]], you can use the AVR binary update software, [[https://github.com/binaryupdates/xLoader|XLoader]]. For updates from the command line in OpenBSD or Linux, use avrdude with the appropriate parameters. * **OpenBSD**: avrdude -p atmega168 -c arduino -P /dev/cuaU0 -v -b 19200 -U flash:w:joy2ps2.hex The parameter /dev/cuaU0 may change to /dev/cuaU1, /dev/cuaU2, etc., depending on the connected serial devices. * **Linux**: The setup is similar, but the device might be /dev/ttyUSB0, /dev/ttyACM0, etc., depending on how it is identified in the system. ====== Keyboard Maps ====== ===== Map 0 ===== (By default, upon connecting or cold rebooting the ZXUno) (Starting from Release 4) {{:mapa0.png?400|}} ===== Map 1 ===== (Starting from Release 4) {{:mapa1.png?400|}} ===== Map 2 ===== (Default M.A.M.E keys) {{:mapa2.png?600|}} ====== List of Tested Cores ====== [[http://www.zxuno.com/forum/viewforum.php?f=13|Link to Spectrum]] [[http://www.zxuno.com/forum/viewforum.php?f=37|Link to others]] * Spectrum * Amstrad CPC * BBC Micro * Atari 2600 ([[http://www.zxuno.com/forum/viewtopic.php?f=48&t=1378|Keyboard compatible version]]) * NES ([[http://www.zxuno.com/forum/viewtopic.php?f=63&p=17554#p17554|Keyboard compatible version]]) * Atari 800 XL * Kyp Spectrum * Jupiter ACE * SAM Coupe * ZX81 * Acorn Electron * Acorn Atom * TBBlue (Next) * PC/XT (From release 2) * Apple II (resynthesizing core with CLK and DATA as PULLUP, [[http://www.zxuno.com/forum/download/file.php?id=1344|Download here]]) * VIC-20 (resynthesizing core with CLK and DATA as PULLUP, [[http://www.zxuno.com/forum/download/file.php?id=1346|Download here]]) * Oric Atmos (resynthesizing core with CLK and DATA as PULLUP, [[http://www.zxuno.com/forum/download/file.php?id=1345|Download here]]) * C64 beta 7 (resynthesizing core with CLK and DATA as PULLUP, [[http://www.zxuno.com/forum/download/file.php?id=1349|Download here]]) * MSX1 * Sega Master System (From release 4, currently only for the first player) * Arcade: Phoenix, Pacman, Galaxian, Frogger, Invaders, Scramble, Galaga (From release 4) ====== Current version ====== * [[https://github.com/spark2k06/zxuno/raw/master/joy2ps2|Release 7]] ====== Acknowledgments ====== Lastly, we would like to thank everyone who, in one way or another, has contributed to making this project a reality:: [[http://zxuno.speccy.org/|ZXUno]] [[https://twitter.com/ZXUno|ZXUno Team]] [[http://www.zxuno.com/forum/|ZXUno Community]] [[https://twitter.com/mejias3d|Jorge Mejias Cazorla (Mejias3D)]] [[https://twitter.com/antoniovil|Antonio Villena]] [[https://twitter.com/zxprojects|mcleod_ideafix]] [[https://twitter.com/SamQuest|Samuel (Quest)]] [[https://twitter.com/eubrunosilvapt|Bruno Silva]] [[https://twitter.com/yombo|Juanjo Luna (Yombo)]] [[http://denki.world3.net/arcade.html|Retro Adapter]] (broken link) [[https://github.com/dkudrow/arduino/tree/master/PS2Emu|Dani's PS2Emu]] ====== Frequently Asked Questions (FAQ) ====== **Does my 6-button Megadrive gamepad fully work or only some buttons as with the ZXUno's DB9 connector?** All buttons are recognized and will be mapped according to the configured key map. The Start and Mode buttons will also work for those Megadrive gamepads that include them. **Is it possible to play with 2 players? What happens if keys from the first player are pressed?** Yes, it is possible. Upon connection, the interface is configured to be used from the main DB9 port or DB15 (Neogeo). If the auxiliary DB9 port (second player) is used, keys associated with the last buttons of DB15 will be activated due to shared pins. To use two players, switch to DB9x2 mode using the corresponding sequence in SHIFT mode. **I selected a core with a different video mode than the one set by default in the BIOS from the core menu. How can I change it without a connected physical keyboard?** There is a sequence to change the video mode while in SHIFT mode. Refer to the SHIFT mode combination section in this wiki for details. **I found a game that I can't start because a mapping for a required key in the options menu is missing, what can I do?** The firmware includes the most common keys used in computer game menus, from '0' to '4' and 'R' to redefine. If other keys are needed, they can be requested to be included in a firmware update. **The key mappings do not meet the needs of a specific core or game, is there a solution?** The firmware can be almost completely adjusted to meet needs. Ideally, cores should follow a uniform standard regarding key use. The most common keys are selected by default, although it can be reviewed and adjusted if justified. **I disagree with the layout of SHIFT mode sequences, are there alternatives?** It's normal to have different preferences regarding the official firmware sequences. Users can debate and decide on the ideal combinations to develop an alternative firmware. Also, if you have programming skills, you can modify the firmware to your liking as the source codes are available to everyone. **When I connect an external keyboard, key presses repeat when using the gamepad.** This can happen because the external keyboard has active command listening, which can interfere with communication by sharing the CLK/DATA pins of the PS/2 connector. One solution is to place a diode on the DATA line with the cathode towards the external keyboard. For more information, visit this link: http://www.zxuno.com/forum/viewtopic.php?f=63&t=1804 Although Joy2PS2 was designed to operate without the need for an external keyboard, especially in setups like bartop arcade machines, using a keyboard can enhance the user experience.