custom USB controller adapters

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, Greenious, spiny, Sorgelig, Moderator Team

Slade
Atari freak
Atari freak
Posts: 60
Joined: Tue Dec 27, 2016 11:02 pm

Re: custom USB controller adapters

Postby Slade » Sun Dec 31, 2017 3:39 am

I realise this is for a different device, but if you have an Arduino UNO or clone around you could try this: https://github.com/AlanChatham/UnoJoy

Bit more of a headache to set up, but it's an option and the 328p clone hardware is dirt cheap. If only I could find the 3-4 of them I have floating around.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Sun Dec 31, 2017 7:18 am

Slade wrote:I realise this is for a different device, but if you have an Arduino UNO or clone around you could try this: https://github.com/AlanChatham/UnoJoy

Bit more of a headache to set up, but it's an option and the 328p clone hardware is dirt cheap. If only I could find the 3-4 of them I have floating around.

this is completely unnecessary and redundant. Arduino micro is much smaller and emulates HID device without such hassle.

Slade
Atari freak
Atari freak
Posts: 60
Joined: Tue Dec 27, 2016 11:02 pm

Re: custom USB controller adapters

Postby Slade » Sun Dec 31, 2017 12:52 pm

Sorgelig wrote:
Slade wrote:I realise this is for a different device, but if you have an Arduino UNO or clone around you could try this: https://github.com/AlanChatham/UnoJoy

Bit more of a headache to set up, but it's an option and the 328p clone hardware is dirt cheap. If only I could find the 3-4 of them I have floating around.

this is completely unnecessary and redundant. Arduino micro is much smaller and emulates HID device without such hassle.


I have a bunch of nano's based on the Atmega 328P. They're 18x44mm, so small enough to do what you need. It's an alternative, for people who have them on hand, rather than buying new hardware (even if it is dirt cheap).

I realise the Uno is huge and it's not an ideal solution to put into a joystick. The nano on the other hand should work fine.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Sun Dec 31, 2017 1:39 pm

Nano doesn't have native USB port, so it won't be able to emulate HID device. You need Arduino based on ATMega32U4.

Slade
Atari freak
Atari freak
Posts: 60
Joined: Tue Dec 27, 2016 11:02 pm

Re: custom USB controller adapters

Postby Slade » Thu Jan 25, 2018 12:25 pm

Newsdee wrote:I can get directions working but not the buttons. I followed the example to the letter and tested for connectivity on relevant pins, I even tried using shorter connections but none of the button work. Maybe a problem with my board? Unfortunately I only have one right now :(


I tested some of the examples on Windows and they worked fine. I ordered a board from Aliexpress, which arrived today. I've only done a quick test, but so far the simple joystick test works ok (4 directions + fire button). As does the buttons example.

I need to solder the pin headers in place to test it properly, and I should order some more joystick parts to make a smaller 2 button joystick.

User avatar
Newsdee
Atari God
Atari God
Posts: 1482
Joined: Fri Sep 19, 2014 8:40 am

Re: custom USB controller adapters

Postby Newsdee » Thu Jan 25, 2018 11:40 pm

Which board did you get exactly?

Slade
Atari freak
Atari freak
Posts: 60
Joined: Tue Dec 27, 2016 11:02 pm

Re: custom USB controller adapters

Postby Slade » Fri Jan 26, 2018 7:42 am

This is the one I ordered: https://www.aliexpress.com/item/5sets-l ... 47161.html

Yes, that's the correct URL, it just points to a different item than you think it will.

THaase
Captain Atari
Captain Atari
Posts: 186
Joined: Mon Oct 16, 2017 8:39 am
Location: Germany

Re: custom USB controller adapters

Postby THaase » Tue Jan 30, 2018 1:54 pm

cvenditti wrote:
Sorgelig wrote:You don't need any other components for you converter. Just wire any retro joystick directly to its GPIO and write the firmware :)

nes.png
No need to write the firmware, this guy already did it (partially):
https://github.com/mcgurk/Arduino-USB-H ... ickAdapter



I've checked this ... the code itself isn't working (anymore) due to an update of the Joystick Lib ..... and I personally don't like the flying leads to the Joystick connectors and ... and ... and ....

So I've played a little bit (having some Pro Micro clones laying around) ....

I've started for now with DB9 for Atari Joysticks (Competition Pro Retro) (that have also the possibility to have 3 Buttons (Atari ST / Amiga) .... I've a modified one with 3 button support
Nice overview:http://wiki.icomp.de/wiki/DB9-Joystick

Output from my side:
A small PCB (KiCAD) for 2xDB9 and one Arduino Pro Micro wired for 3 Button support on both DB9
Pro Micro FW adopted to this PCB.

As I'm not allowed to attach any files - I've uploaded the stuff to dropbox https://www.dropbox.com/s/ekqlb35r581zg5q/USB2DB9.zip?dl=0.
At the moment I can't gurantee that everything is working as expected as I've not received any PCBs till now (and this will take at least 2 weeks (epacket to Germany)

cu
Thomas

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Tue Jan 30, 2018 2:02 pm

THaase wrote:As I'm not allowed to attach any files - I've uploaded the stuff to dropbox https://www.dropbox.com/s/ekqlb35r581zg ... 9.zip?dl=0.

If you want, i can add you into MiSTer github group, so you will be able to add your repository(ies) where you will be able to update your work.

THaase
Captain Atari
Captain Atari
Posts: 186
Joined: Mon Oct 16, 2017 8:39 am
Location: Germany

Re: custom USB controller adapters

Postby THaase » Tue Jan 30, 2018 2:07 pm

This is nice - but I think at the moment too much .....
I first need to buy my FPGA Board, solder my SDRam Board and so on - before I can't really test it makes no sense to me!
Nevertheless - THANKS!

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Tue Jan 30, 2018 2:11 pm

no problem - just let me know.

ulao
Atarian
Atarian
Posts: 4
Joined: Tue Feb 26, 2019 4:58 pm

Re: custom USB controller adapters

Postby ulao » Tue Feb 26, 2019 5:04 pm

Newsdee, while I agree the Bliss-Box is an over kill price wise. Take note the Gamer-Pro a single player version plus the latest dev work by @rysha. There is no longer any need to play with USB. The LLAPI will get all the data from the controller in a time window less then that of any adapter. Bliss-Box designed a protocol to communicate with its upcoming Bridge adapter. the challenge was how to send data from the BB to the Bridge in a fraction of a ms. The protocol uses the USB cable but talks on its own langue. What Rysha did, was used that protocol to get the data from the Bliss-Box for the mister. You are sill limited to the controller's own latency and you do need to wait for the mister to vblank but it's as close as you will get to zero lag.

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Tue Feb 26, 2019 8:23 pm

And according to @rysha, there is no feel in lag difference against USB connection.

jdubs
Retro freak
Retro freak
Posts: 12
Joined: Thu Nov 01, 2018 3:11 pm

Re: custom USB controller adapters

Postby jdubs » Tue Feb 26, 2019 9:46 pm

ulao wrote:Newsdee, while I agree the Bliss-Box is an over kill price wise. Take note the Gamer-Pro a single player version plus the latest dev work by @rysha. There is no longer any need to play with USB. The LLAPI will get all the data from the controller in a time window less then that of any adapter. Bliss-Box designed a protocol to communicate with its upcoming Bridge adapter. the challenge was how to send data from the BB to the Bridge in a fraction of a ms. The protocol uses the USB cable but talks on its own langue. What Rysha did, was used that protocol to get the data from the Bliss-Box for the mister. You are sill limited to the controller's own latency and you do need to wait for the mister to vblank but it's as close as you will get to zero lag.


Yes!!! This is going to be awesome. Can't wait for this functionality (just got my bliss-box specifically for this).

-Jim

theimporter
Atariator
Atariator
Posts: 20
Joined: Sun Feb 17, 2019 6:58 pm

Re: custom USB controller adapters

Postby theimporter » Wed Feb 27, 2019 5:30 am

Hey guys, here's a playlist of mine with 3 video recordings with 3 PS2 to USB converters on my MiSTer box. Using YouTube slow motion, which one do you feel has input lag: https://www.youtube.com/playlist?list=P ... fgU2NJZkr8

User avatar
Newsdee
Atari God
Atari God
Posts: 1482
Joined: Fri Sep 19, 2014 8:40 am

Re: custom USB controller adapters

Postby Newsdee » Wed Feb 27, 2019 7:49 am

Wait.. so the Blissbox was tested especially to have as little lag as possible with a MiSTer? That is really good news (if I understood correctly).

User avatar
Newsdee
Atari God
Atari God
Posts: 1482
Joined: Fri Sep 19, 2014 8:40 am

Re: custom USB controller adapters

Postby Newsdee » Wed Feb 27, 2019 8:00 am

@theimporter The 2nd one seems the best of the three to me. I can see lag on the 1st, the 3rd is in between.

ulao
Atarian
Atarian
Posts: 4
Joined: Tue Feb 26, 2019 4:58 pm

Re: custom USB controller adapters

Postby ulao » Wed Feb 27, 2019 11:58 am

The Bliss-Box out of the box (no pun intended) has around 16ms usb timing (not to be confused with lag) . This is just the nature of USB and yes you can sense that I'm told ( I hardly can) when the timing goes over a video frame. Rysha is not using USB but rather the GPIO pins with the USB cable. It is in the works and thus far showing success. Though the logic is changing I here.. She was able to drive pins HIGH to fake the lack of external pull ups. Once this change happens they just may be required. Not a huge deal for much of the community but it is an extra step. As exciting as this is and yes a few cores are showing signs of success, give it time to solidify and became stable. The Bliss-Box 3.0 firmware is required and only beta at this time. If you want to be part of development I suggest jumping on the Bliss-Box discord.
Last edited by ulao on Wed Feb 27, 2019 1:39 pm, edited 1 time in total.

ulao
Atarian
Atarian
Posts: 4
Joined: Tue Feb 26, 2019 4:58 pm

Re: custom USB controller adapters

Postby ulao » Wed Feb 27, 2019 12:11 pm

And according to @rysha, there is no feel in lag difference against USB connection.

Well she does say it feels ok and where I agree she did says this.
-Rysha-
With all the power that passing the IO through the linux side of MiSTer brings to the platform, it does have one drawback: It introduces an average about 9 to 18ms of latency, according to my oscilloscope. The majority of controllers fell in the 8ms range, with a cheap Chinese one having over a frame of lag. Most people won’t notice or be bothered by this, but MiSTer users aren’t most people, are they?


I have been gaming for years and 16 ms is nothing to me but I sure is hell feel it on punchout. In my experience, 8ms is your reaction window and over 16 is your visual window. Though for things like spinners and time samplers you need near 2ms. Once you go over 16.6 ms you will always hit 1 frame or more lag (60fps). Being under 8ms reduces this a great deal but tying poll rates to vblack is the key here. When a frame is drawn you have time to do things like reading controllers. And that is what Rysha is doing with the LLAPI. Lag is many call it, is where the video frame elapses but the input is not received. Obviously you will never see lag is steps < the video frame length (its not even drawn). So on a 60fps set up you get 16.6ms between screen anyways. If the adapter does it's job before that, you get only video lag no input lag. Problem is emulators have no access to the video black where device likes the MiSter do. What goes in in a frame, stays in a frame :) Hope that made sense...

Locutus73
Captain Atari
Captain Atari
Posts: 493
Joined: Wed Feb 07, 2018 6:13 pm

Re: custom USB controller adapters

Postby Locutus73 » Wed Feb 27, 2019 2:43 pm

Speaking of controllers with Rysha/Kitrinx she expressed her idea about implementing mouse support for emulating lightguns and… one thing lead to another and I remembered I have a Mayflash Wireless Sensor DolphinBar (Wiimote to PC USB ) http://www.mayflash.com/Products/NINTENDOWiiU/W010.html
It’s a cool device with various working modes: mode 2 (Keyboard and Mouse Game Mode) IMHO is particularly interesting for MiSTer. It basically emulates various keyboard keystrokes with Wiimote buttons and mouse movement when aiming the Wiimote to the “sensor bar” leds.
So I tried it with MiSTer, I successfully navigated through the main menu as if I was using a keyboard, and I fired Minimig. As soon as I loaded the Workbench I started to wiggle the Wiimote but mouse didn’t move; I got a Joypad configuration wizard instead.
So I further investigated the issue, I connected to the serial console and this is what I got with lsusb

Code: Select all

Bus 001 Device 004: ID 0079:1802 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0079
  idProduct          0x1802
  bcdDevice            1.00
  iManufacturer           1 HJZ
  iProduct                2 Mayflash Wiimote PC Adapter
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3
      bInterfaceSubClass      1
      bInterfaceProtocol      1
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID              10.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      63
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3
      bInterfaceSubClass      0
      bInterfaceProtocol      2
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID              10.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     113
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               1
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

and this is what I got while wiggling the Wiimote

Code: Select all

Input event: type=EV_ABS, Axis=0, Offset:=485, jnum=2, ID:0079:1802. ABS_INFO: min = 0 max = 512
Input event: type=EV_ABS, Axis=1, Offset:=400, jnum=2, ID:0079:1802. ABS_INFO: min = 0 max = 400
Input event: type=EV_ABS, Axis=0, Offset:=484, jnum=2, ID:0079:1802. ABS_INFO: min = 0 max = 512
Input event: type=EV_ABS, Axis=0, Offset:=483, jnum=2, ID:0079:1802. ABS_INFO: min = 0 max = 512

and this is what I get from a Logitech K400+ touchpad

Code: Select all

Input event: type=EV_REL, Axis=0, Offset:=1, jnum=0, ID:046d:404d
Input event: type=EV_REL, Axis=1, Offset:=-1, jnum=0, ID:046d:404d
Input event: type=EV_REL, Axis=0, Offset:=3, jnum=0, ID:046d:404d
Input event: type=EV_REL, Axis=1, Offset:=-2, jnum=0, ID:046d:404d

So basically Mayflash Dolphinbar emulates an “absolute” mouse, not a relative one, just like a sort of touchscreen and, if we think about how Wiimotes work, it’s logic. Problem is MiSTer assumes that each “relative” event comes from a mouse, while each “absolute” event comes from a joypad and, since it isn’t mapped, it fires the wizard.
So first of all the wizard (I think it's launched here https://github.com/MiSTer-devel/Main_Mi ... 1541-L1571, never reached with relative events) should be skipped if the absolute event comes from a mouse (or with a less elegant approach, if VID:PID=0079:1802).
Then I don’t know, probably trying to convert the absolute mouse into a relative one for using void user_io_mouse(unsigned char b, int16_t x, int16_t y); is not worth the effort for using Wiimote with Amiga and other retrocomputers… maybe it would be enough to implement an additional absolute mode for lightgun and paddle games where the absolute position is mapped 1:1 to a screen coordinate and that would work both with analog sticks (top left = top left of the screen) and Mayflash Dolphinbar.

Regards.

Locutus73

Milongero
Atariator
Atariator
Posts: 28
Joined: Sun Nov 25, 2018 2:24 pm
Location: Germany

Re: custom USB controller adapters

Postby Milongero » Wed Feb 27, 2019 2:59 pm

Hello,

what is the benefit of FPGA Simulation against Software Emulation?

The benefit on FPGA Simulation is that many things can happend at the same time (in parallel) like our old computers and consoles can do.

An Emulation is an sequentiel prozess where everything is going on after another like CPUs work.


What is the difference between USB and the old Atari DB9-Port?

Yes - USB is serial- and the DB9 is a parallel-Port

 
If i play a jump 'n run game and i must jump over a hole i have to pull the stick up and left and hit the button at the same time (3 elektronic actions)

The DB9 has for each action his own PIN!!! ->Wikipedia


With DB9 my Input lag is my reaction time

 
with USB i have the reaction time + THREE times the pullingrate of USB

 

How can we solve this Problem? We have no parallel-Port at the DE10 Nano.

 

I think Sorgelig is right – there is no benefit to use an old original Controler over USB-adapter

 

Kind regards

Sorgelig
Ultimate Atarian
Ultimate Atarian
Posts: 5220
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: custom USB controller adapters

Postby Sorgelig » Wed Feb 27, 2019 3:43 pm

Locutus73 wrote:So basically Mayflash Dolphinbar emulates an “absolute” mouse, not a relative one,

EV_ABS is what analog joystick uses.
Axis=0/1 are standard axes of analog joystick. So, basically you can use it as simple joystick in games.

Locutus73
Captain Atari
Captain Atari
Posts: 493
Joined: Wed Feb 07, 2018 6:13 pm

Re: custom USB controller adapters

Postby Locutus73 » Wed Feb 27, 2019 4:20 pm

Sorgelig wrote:
Locutus73 wrote:So basically Mayflash Dolphinbar emulates an “absolute” mouse, not a relative one,

EV_ABS is what analog joystick uses.
Axis=0/1 are standard axes of analog joystick. So, basically you can use it as simple joystick in games.


Yes and not... I know analog joysticks send EV_ABS, but it's the same for "absolute/pointing" mice (bInterfaceProtocol 2)...
I see two problems here:
1) Since MiSTer thinks it's an analog stick event form an unmapped joypad, main MiSTer automatically brings up the joypad configuration wizard, but there's nothing to configure here: apart from those EV_ABS events, the Dolphinbar adapter sends normal keyboard events or mouse clicks, so there's nothing to configure for device 0079:1802. But if you cancel the wizard, as soon as you move again the Wiimote the wizard is shown again... an endless loop.
2) I agree that in the end, if we manage to skip the wizard somehow, we can use these events as a special analog joypad or whatever... we get absolute events we use absolute values but, usually cores use these values as we would use an analog stick, so they consider those absolute value as a sort of speed vector for a pointer or a character or something. In this special case we should need to use the absolute value as an absolute position on the screen of this pointer/character, i.e. using the absolute X value for placing Arkanoid ship in the same absolute position on the screen (playing a sort of "air" Arkanoid) or using absolute X/Y as absolute screen position for a lightgun. Using EV_ABS from Wiimote as a traditional analog joypad would lead to aiming slightly on the left (relative to the center of the screen) translating to the pointer/character/ship moving slowly to the left, while aiming to the far left side of the screen translating to moving the pointer quickly; not 1:1 mapping which is the natural feeling we expect from a pointing device. But I think this is something related to single cores if we can escape the wizard loop.

Thank you in advance.

Locutus73

theimporter
Atariator
Atariator
Posts: 20
Joined: Sun Feb 17, 2019 6:58 pm

Re: custom USB controller adapters

Postby theimporter » Thu Feb 28, 2019 3:57 am

Newsdee wrote:@theimporter The 2nd one seems the best of the three to me. I can see lag on the 1st, the 3rd is in between.


While playing, I can't feel any input lag with the 1st and 2 converter, but I can feel some with the 3rd one.

User avatar
Newsdee
Atari God
Atari God
Posts: 1482
Joined: Fri Sep 19, 2014 8:40 am

Re: custom USB controller adapters

Postby Newsdee » Thu Feb 28, 2019 8:01 am

Fair enough, i's a bit hard to see on the video when you press the button exactly.

What some people have done is wire a LED to the button so it lights up when pressed... that gives a very clear indication of lag by slow motion.

In fact in a crazy world of infinite developer time, it would theoretically be possible to have a core that emits serial commands that push buttons (wired to an original controller) then measures internally the time it takes for the button push to come back from the USB bus... which such a rig we could test all kinds of adapters to weed out bad ones. But I don't expect this to appear, is just a wild thought. :)


Return to “MiSTer”

Who is online

Users browsing this forum: nagus, Tateha and 9 guests