mapping two controllers?

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

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

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

mapping two controllers?

Postby Newsdee » Mon Nov 06, 2017 3:28 am

I think I'm being stupid and I missed something, but can we map two players controllers in the OSD? Or if not is there a way to clone a mapping to tell it to use it for P2 instead of P1?

I read the firmware code and as far as I can tell it is still passing two joystick inputs to cores, and the mapping seems to support multiple devices. I just don't see an obvious way to tell it to map device 2 instead of device 1... Did I miss something?

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Mon Nov 06, 2017 7:02 am

I haven't seen anything about a second input either. Out of curiosity, what happens if you plug in a second joystick and do the input setup using the second joystick ? Does it work at all ? And if so, does it over ride joystick 1's input ?

Edit: I'd test it out, but I haven't finished rebuilding my joystick - I need to get a few more spade plugs for the actual joystick mechanism. The buttons are all wired up nicely. Once that's done, I should have a nice arcade stick to use.

Sorgelig
Atari God
Atari God
Posts: 1189
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: mapping two controllers?

Postby Sorgelig » Mon Nov 06, 2017 9:38 am

Newsdee wrote:I think I'm being stupid and I missed something, but can we map two players controllers in the OSD? Or if not is there a way to clone a mapping to tell it to use it for P2 instead of P1?

I read the firmware code and as far as I can tell it is still passing two joystick inputs to cores, and the mapping seems to support multiple devices. I just don't see an obvious way to tell it to map device 2 instead of device 1... Did I miss something?


2 joysticks are supported currently.
The joystick where first button has been pressed becomes the first joystick. It's per core. So, after starting any core, press the button on the joystick to make it first.
Button mapping is per device ID. If both joysticks are identical, then mapping will be the same (you see joystick ID while defining the buttons). If joysticks are different, then you need to define the buttons on each joystick.

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

Re: mapping two controllers?

Postby Newsdee » Mon Nov 06, 2017 2:24 pm

Thanks, I've updated the wiki a bit.0

If somebody wants to test a USB joystick on the Linux side you can connect to the MiSTer via terminal console then type:

Code: Select all

jstest --event /dev/input/js0


You can see a list of connected devices by entering:

Code: Select all

ls /dev/input/js*


I've been trying a few controllers and many they work a bit weird:
  • Bufallo SNES pad - works fine
  • Atari-dapter for 2600 pad - issues with directions and VID/PID
  • Retrode - seems recognized for SNES and Genesis pads, but has issues with directions
  • Retro Freak adapter - recognized but also has issues with directions
  • My GhettoStick (https://www.instagram.com/p/BU8FUueBs3r)- left and right works but not up and down

I suspect there's a problem with the handling of directions... still looking.

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

Re: mapping two controllers?

Postby Newsdee » Mon Nov 06, 2017 2:50 pm

This is strange. I worked out that, for one of my controllers, the MiSTer firmware is receiving four axis for the directions. In jstest I only see two recognized (axis 0 and 3), but in the MiSTer firmware we are receiving a bunch of events on axis 2. It's as if there's a contact being set and constantly sending a value. Somehow the Linux side manages to ignore it, so there must be a way to tell the MiSTer firmware to ignore these events as well. For now I can only think of hard-coding vid/pid values in the firmware (and tell the firmware to disregard some events for those IDs) but I'd rather avoid doing that.
Last edited by Newsdee on Mon Nov 06, 2017 2:55 pm, edited 1 time in total.

Sorgelig
Atari God
Atari God
Posts: 1189
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: mapping two controllers?

Postby Sorgelig » Mon Nov 06, 2017 2:55 pm

i'm using 2 controllers with MiSTer:
- Thrustmaster Ferrari Wireless 430 Scuderia
- Noname PS3-like wired pad

Both them works fine. I suggest to use noname PS3-like controller because it's cheap and provides many buttons.

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

Re: mapping two controllers?

Postby Newsdee » Mon Nov 06, 2017 3:43 pm

It's exciting to get it working because I noticed there's a much wider range of recognized gamepads and adapters compared to the MiST :)
But I don't have a compiling environment for the firmware yet... it will take me some time to get there.

For now I've identified three different issues on different controllers, looking at input.c and terminal output:
  • Axis not expected by the firmware; this seems like an easy fix (at least a workaround by mapping EV_ABS ev.code 3 to Y)
  • Axis negative values not recognized; I noticed it happens when min(x) or min(y) do not match the opposite value of max(x) and max(y).
  • Device seems to disconnect; I have no clue what causes this but it's only on the AtariDapter.

What's the logic behind this code? I don't fully understand it yet:

Code: Select all

uint16_t offset = 0;
f (ev.code < 16) offset += 4;
if (ev.code < 2) offset += 4;

On the MiST we were using an offset to read button location but I think that is abstracted away in the Linux handler. So I suppose this is something else? Perhaps that needs to change to ev.code<3 to accept the axis in the first problem?

I suppose worst case we can do like the MiST and hard-code PID/VID for specific tweaks on the internal USB mapping.

Sorgelig
Atari God
Atari God
Posts: 1189
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: mapping two controllers?

Postby Sorgelig » Mon Nov 06, 2017 3:55 pm

Standard axis number for X is 0. For Y - 1. If your joystick doesn't provide axis 0/1 then check if your joystick can be switched to other mode. My noname PS3 pad switches between 2 modes by "mode" button.
Usually left analog stick has axis 0/1, right analog stick has 2/5 (if i remember correct). This is standard mapping for analog sticks.

Newsdee wrote:What's the logic behind this code? I don't fully understand it yet:

simply different emulated key codes. 4 codes per 2 pairs of axis: 0/1, 2/5, 16/17

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Sat Nov 11, 2017 4:25 am

Did anything come of the issues raised here ?

I've just finished rebuilding my arcade joystick, which works perfectly well in Windows, but MiSTer only recognises left and right, but not up and down. It makes game play very difficult :)

I'm using one of these generic USB encoders, if that helps at all.

https://www.aliexpress.com/store/produc ... 77442.html

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

Re: mapping two controllers?

Postby Newsdee » Sat Nov 11, 2017 7:47 am

Not yet, but my GhettoStick uses the exact same encoder so I should be able to sort it out.

Edit: try the attached firmware, it fixes it on my device.
MiSTer.zip
You do not have the required permissions to view the files attached to this post.

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Sun Nov 12, 2017 12:47 am

I tried your firmware, and whilst I can now define the joystick properly, the controls don't work.

I tried Timepilot - the ship just doesn't move / rotate. I can fire, easily enough.

Then I tested Xevious which moved the ship towards the top left of the screen (all the way left, and 2/3rds of the way up), and it got stuck there. Again, I could shoot, and drop bombs, just not move around.

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

Re: mapping two controllers?

Postby Newsdee » Sun Nov 12, 2017 12:53 am

I'll try the cores and see how it looks on my end. It is possible that your encoder is slightly different than mine (they look the same but who knows). No big deal, I'm sure we can refine the handling.

The behavior looks like the directions are stuck. Are you able to send me the device VID/PID? Also are you able to run the console via USB UART to collect some debug info? (if you run the menu core and move joystick it will print joystick axis info to console).

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

Re: mapping two controllers?

Postby Newsdee » Sun Nov 12, 2017 10:04 am

Try the attached. I'll test a few more controllers before updating the Github source.
MiSTer_joy_fixes2.zip
You do not have the required permissions to view the files attached to this post.

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Mon Nov 13, 2017 7:13 am

Newsdee wrote:Try the attached. I'll test a few more controllers before updating the Github source.
MiSTer_joy_fixes2.zip


That worked, thanks ! :cheers:

I did have a slight hiccup - it was working for about 2 minutes, then the joystick stopped. I think between the keyboard, wireless mouse adaptor and the joystick the USB hub just didn't want to keep it all going.

So I pulled the mouse adaptor, restarted the Terasic board and the joystick has been good ever since.

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

Re: mapping two controllers?

Postby Newsdee » Mon Nov 13, 2017 11:29 am

Slade wrote:So I pulled the mouse adaptor, restarted the Terasic board and the joystick has been good ever since.

Can you try using a powered hub? It looks like a power problem.

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Mon Nov 13, 2017 8:51 pm

Newsdee wrote:
Slade wrote:So I pulled the mouse adaptor, restarted the Terasic board and the joystick has been good ever since.

Can you try using a powered hub? It looks like a power problem.


I don't have a powered hub, but it was my guess too, which was why I pulled the mouse adaptor. I figured 2 items plugged in would be OK, and it is. I'll have to hunt around for a powered hub, that also does OTG. In the mean time, I just keep 2 of the 3 things I want plugged in at the same time.

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

Re: mapping two controllers?

Postby Newsdee » Mon Nov 13, 2017 10:13 pm

Slade wrote:I'll have to hunt around for a powered hub, that also does OTG. In the mean time, I just keep 2 of the 3 things I want plugged in at the same time.


Can't you use a regular (non OTG) hub with the included OTG cable from the DE10?

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Tue Nov 14, 2017 5:15 am

Newsdee wrote:
Slade wrote:I'll have to hunt around for a powered hub, that also does OTG. In the mean time, I just keep 2 of the 3 things I want plugged in at the same time.


Can't you use a regular (non OTG) hub with the included OTG cable from the DE10?


May be I was unlucky, but I didn't get an OTG cable in the box. I have a USB to micro and USB to mini cable in my box. That's all there is, aside from power and the DE10 itself.

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

Re: mapping two controllers?

Postby Newsdee » Tue Nov 14, 2017 5:55 am

Slade wrote:May be I was unlucky, but I didn't get an OTG cable in the box. I have a USB to micro and USB to mini cable in my box. That's all there is, aside from power and the DE10 itself.

The USB to mini cable is an OTG cable :)
https://software.intel.com/en-us/node/712680

Slade
Atari nerd
Atari nerd
Posts: 46
Joined: Tue Dec 27, 2016 11:02 pm

Re: mapping two controllers?

Postby Slade » Tue Nov 14, 2017 7:48 am

Newsdee wrote:
Slade wrote:May be I was unlucky, but I didn't get an OTG cable in the box. I have a USB to micro and USB to mini cable in my box. That's all there is, aside from power and the DE10 itself.

The USB to mini cable is an OTG cable :)
https://software.intel.com/en-us/node/712680


The power supply on my powered USB hub perished on the weekend (it was connected to my 3D printer and running the Raspberry Pi, LED's and printer from it). So now I have an unpowered USB hub, which doesn't do anything. I wouldn't be surprised if it killed the hub as well.

Not that it would matter. It seems odd to supply a USB OTG cable that is micro to USB A plugs on both ends, rather than a socket on one end. The hub I have is 10 in and 1 out, which is USB B for the computer connection side.

I've just looked at replacement hubs (I really have never needed one, and the one I killed hadn't been used for a while until recently), and they all have hardwired USB A plugs on the end. How is that going to connect to the supplied cable ?

Sorgelig
Atari God
Atari God
Posts: 1189
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: mapping two controllers?

Postby Sorgelig » Tue Nov 14, 2017 7:56 am

Supplied USB to micro-USB cable is not for HUB usage. Besides acting as a HOST, DE10-nano can work as a device (hence the name OTG). So, supplied cable is for usage of DE10-nano as a USB device.
I never tried to use DE10-nano as a device, so i have no idea what it can do as a USB device. Actually i don't even want to know it :)

You need either OTG-USB hub which has micro-USB connector to the DE1-nano, or use an OTG micro-USB adapter to connect full-sized USB connector.

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

Re: mapping two controllers?

Postby Newsdee » Tue Nov 14, 2017 12:22 pm

Sorgelig wrote:You need either OTG-USB hub which has micro-USB connector to the DE1-nano, or use an OTG micro-USB adapter to connect full-sized USB connector.

That's odd .... because I just use the cable from the box with an unpowered hub and it works fine. Oh well, as long as nothing burns:)

Sorgelig
Atari God
Atari God
Posts: 1189
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: mapping two controllers?

Postby Sorgelig » Tue Nov 14, 2017 12:48 pm

Newsdee wrote:That's odd .... because I just use the cable from the box with an unpowered hub and it works fine. Oh well, as long as nothing burns:)

i don't understand you. Terasic doesn't include micro-usb host cable. They include only micro-usb device cable. Or may be we have different packages.

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

Re: mapping two controllers?

Postby Newsdee » Tue Nov 14, 2017 1:04 pm

Sorgelig wrote:i don't understand you. Terasic doesn't include micro-usb host cable. They include only micro-usb device cable. Or may be we have different packages.

I'll admit I may be wrong. The packing list seemed to confirm it but reading it again, I feel it just means the port is OTG compatible. So best to buy a new OTG cable, they're easy enough to find, and then one can use any hub with it.


Return to “MiSTer”

Who is online

Users browsing this forum: No registered users and 1 guest