MiSTer-devel / Main_MiSTer

Main MiSTer binary and Wiki
GNU General Public License v3.0
3.06k stars 331 forks source link

Logitech Driving Wheels not working #575

Closed thorr2 closed 1 year ago

thorr2 commented 2 years ago

The PSX core, ao486 and possibly others have a ton of great driving games. Many of us have Logitech driving wheels such as the G25 and G27 and want to use them with the MiSTer. Currently, they show up with lsusb but do not respond when trying to map them in the MiSTer. Please add support for these driving wheels.

There was this project to get it to work with Linux: https://github.com/TripleSpeeder/LTWheelConf

but as mentioned on the page: "we managed to get most / all wheels supported directly by the kernel, so there is no need for this separate tool anymore"...

That said, I tried plugging in mine and I couldn't map any inputs, so I guess it may not be in the kernel used by MiSTer

/root# lsusb Bus 001 Device 006: ID 046d:c294 Logitech, Inc. Driving Force

Thanks!

GThrone commented 2 years ago

You're right, mate. This is a major issue. It's a standardised controller (same as the G25), used en-masse by the community. It's bizarre that it's not recognised. What an odd omission from an otherwise fairly intelligent project. I should be able to use my G27 to play everything from Super Monaco GP to Gran Turismo.

birdybro commented 2 years ago

It's bizarre that it's not recognised. What an odd omission from an otherwise fairly intelligent project.

Hasn't added support for something yet != unintelligent omission. Be more respectful with your comments please.

You can request device support at the Linux_MiSTer issues page --> https://github.com/MiSTer-devel/Linux-Kernel_MiSTer/issues

https://mister-devel.github.io/MkDocs_MiSTer/advanced/console/#u-boot-command-prompt - use a console connection and provide the debug output when you use the inputs on your steering wheel, so you can help the devs add support for it.

The reason why there isn't as wide a device support as there are in regular desktop linux distros is because the project isn't using laggy SDL, or anything like that, for input support. Most of the input handling is custom code, to ensure that there is very low latency.

coolbho3k commented 2 years ago

I'm currently trying to add support for racing wheels generically. However, I have a Fanatec wheel, and no Logitech wheel, so I may need that debug information from folks who do have other brand wheels. If I do manage to make this contribution, support for Fanatec wheels will come first, because that's just what I have and can test. Can you do what @birdybro mentioned on your device?

Please use the MiSTer debug output to figure out which axis the steering, brake, throttle, and clutch are on, and what the max/min values are roughly.

CONFIG_HID_LOGITECH=y is set in the kernel, I don't understand why the MiSTer won't respond at all to the Logitech wheel. Maybe https://github.com/berarma/new-lg4ff will work, but I have no Logitech wheel to test.

There's more complexities than many other controllers, like the fact that usually brake/throttle are on separate axes on a wheel, the necessity of setting a constant centering spring force so FFB wheels return to center, and perhaps adding rumble -> FFB translation.

thorr2 commented 2 years ago

I hooked up the console port and hit escape and got the => prompt. I am not sure what to do next. Also, when the wheel is hooked up and the MiSTer fully/normally boots, the wheel calibrates itself like it normally does. When using the console port and hitting escape to stop it before booting, the wheel does not calibrate itself at this point. Pushing the buttons does nothing on the screen either.

Please let me know what to type at the => prompt to get the debug output and I will provide the output.

Also, I have not compiled anything on the MiSTer before, but I am familiar with compiling in Linux. It does not appear that gcc or any of the other compiling applications are there. I wouldn't mind trying the berarma/new-lg4ff driver, but I am not sure how to proceed on the MiSTer. I just need a list of commands to type to get everything installed, and I am happy to test.

Thanks a lot for your help coolbho3k, and birdybro also!

coolbho3k commented 2 years ago

@thorr2 I actually have not debugged with console, however here is an alternative method that I've used:

  1. ssh into MiSTer - ssh root@<your_misters_ip> (default password is 1 unless you changed it)
  2. Run top and find the current PID of the /media/fat/MiSTer process - it is usually somewhere in the 500-600 range for me
  3. Kill the MiSTer process - kill <pid>
  4. Run /media/fat/MiSTer on your terminal and MiSTer process should restart you should see all the console output

Now plug in your Logitech wheel and turn the wheel, press the pedals, and you should see a lot of debug logging in your terminal related to the axis and values of the wheel/pedals. Each event should look like this:

0eb7:0004:00 P0 Input event: type=EV_ABS, Axis=0 [0...65535], Offset=51148
0eb7:0004:00 P0 Input event: type=EV_ABS, Axis=0 [0...65535], Offset=51050

The important values are the Axis for each input, the range (0...65535) and which direction it's going as you turn left/right and press the pedal down. These values would be great:

For wheel Axis: Range: Center offset: Full left offset: Full right offset:

For each of throttle/brake/clutch Axis: Range: Default offset: Fully pressed offset:

sorgelig commented 2 years ago

i have Driving Force Pro, Driving Force GT and G29 wheels. i will see what can i do. ao486 has input only for 2 analog axis and 4 buttons, so i don't think current implementation of joystick on ao486 will work with wheels. The only core which may take advantage from wheel is PSX and couple games. Yeah, so bizarre omission!

coolbho3k commented 2 years ago

Great that you have hardware! Some findings from my tweaking.

My solution has been to map the steering axis to left analog stick left/right (already default on my wheel so no work needed).

Throttle axis maps to right analog stick up.

Brake axis maps to right analog stick down.

And this works with PSX core with NeGcon controller. But doesn’t work that well on the current UI and some hard coded values. Here is my branch with ideas. Note: not ready for review yet and needs lots of cleanup but basically working so far

https://github.com/coolbho3k/Main_MiSTer/tree/wheel

You need to send an FF_SPRING force feedback signal to the wheel to enable the centering force spring or else it won’t be very playable. I got this to work. Once this is in place, plus some in-game calibration to remove in-game deadzones, Gran Turismo feels great.

Most wheels don’t use FF_RUMBLE, but FF_PERIODIC so the default rumble implementation doesn’t work. I haven’t gotten this to work yet with my wheel as I can’t figure out how to use FF_PERIODIC properly yet without the wheel reacting violently and turning all the way to the left…

sorgelig commented 2 years ago

I don't think we need to even touch FF for wheel as there is basically no support in games. initialization with FF_SPRING to enable springy feeling is the only thing possible to do for wheels.

sorgelig commented 2 years ago

probably break/accel can be mapped to horz/vert axis of right stick so they can wok independently. Then it will be up to core how to treat it. Problem is that not many games where wheel can be used. It's possible to use wheel as a dummy analog left/right steering which is doubtful pleasure where you have to unpack a bulky controller to simulate analog stick of gamepad.

DFGT wheel is mapped wheel to analog horizontal axis. So basically it's working out ouf the box (after enabling logitech wheel in kernel).

sorgelig commented 2 years ago

Working with my Logitech wheels - they use their own interface to control spring and range. It's good they are supported by kernel, so it's not a problem to add it. The only problem is the whole hassle is kind of pointless.

thorr2 commented 2 years ago

Thank you everyone. It is definitely worth the effort in my opinion and probably many others, even if the game only supports it in a basic way. The alternative is using a thumbstick or a joystick which is totally terrible for driving games by comparison. I used to play PC games with a Thrustmaster steering wheel and it was left/right analog, and the two pedals were up/down analog, and it had a springy mechanical return to center. This was pure joy back then compared to a joystick. The PSX seems to support more options by changing the controller type in the core. This should support separate axis controls for the pedals.

Tonight (PST) I can provide the testing output if it will help. Thanks everyone!

On Tue, Apr 19, 2022, 6:59 AM Alexey Melnikov @.***> wrote:

Working with my Logitech wheels - they use their own interface to control spring and range. It's good they are supported by kernel, so it's not a problem to add it. The only problem is the whole hassle is kind of pointless.

— Reply to this email directly, view it on GitHub https://github.com/MiSTer-devel/Main_MiSTer/issues/575#issuecomment-1102691733, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMVRPLQLIAXZEBCAK5PULP3VF232VANCNFSM5RINQA5A . You are receiving this because you were mentioned.Message ID: @.***>

coolbho3k commented 2 years ago

For pedals, I had a few ideas.

  1. One alternative is to combine brake and throttle input by averaging them. It's in my branch above. Since the NeGcon on PSX core maps the analog buttons to right stick up and down, it works out of the box. It's not as realistic, as of course in a real car you can press both at the same time, but I'm not sure that's really relevant for any games that MiSTer will ever support.

  2. Mapping the other pedal to the horizontal axis is even better, as it would allow independent control and double resolution on the pedals, but it would require some minor change to the PSX core to work - probably a config option.

  3. Yet another idea, which I actually prefer, is to add a mappable analog L2 and R2 input to the MiSTer virtual controller, then make that mappable to the analog NeGcon buttons in PSX core. This also allows you to map a regular controller with analog L2 and R2 and use these as throttle/brake like how modern racing games work. Today, I think you have to use right stick.

I'm not sure which other cores would be relevant for wheels though and whether analog input is even possible for them - for example can you even get multiple analog axes into ao486?

sorgelig commented 2 years ago

currently i plan to use such mapping: steering - Left Stick X acceleration - Left Stick Y break - Right Stick Y (optional) clutch - Right Stick X

Pedals will be translated to positive-only values (0-127) giving half range but for pedals it's more than enough resolution. It also will be compatible with dual-stick gamepads where sticks are centered. I also will think about giving option for L/R analog triggers, but need to keep in mind that many gamepads have only digital triggers, so sticks are still preferred for wheel emulation.

Since accel/break will be sent as separate analogs, it will be up to core to average it or not. I would suggest for cores to pick higher value between break and accel which will give more intuitive behavior.

sorgelig commented 2 years ago

Logitech Wheels have nice feature - multimode. So newer wheel can be switched into one of older model (on HW level it seems) with VID:PID of that wheel and mappings. So using G29 i can test MiSTer with DF-EX, DFP, DFGT, G25, G27 wheels.

DF-EX uses same axis for both accel and break pedals. It does subtraction inside wheel when both pedals are pressed. So both pressed pedals give 0 on that axis.

thorr2 commented 2 years ago

steering - Left Stick X acceleration - Left Stick Y break - Right Stick Y (optional) clutch - Right Stick X

This sounds like a good overall approach. Each pedal should have its own axis. PSX has the most driving games currently so this should work well as long as the core is updated to support the layout. Choosing "Driving Wheel" or something similar as a plugged in controller.

The above would be a compromise in ao486 because you would have to use one foot driving for acceleration and braking. The midpoint of the pedal would be where it would change from acceleration to braking. I am already used to this in my Tesla with regenerative braking, so it would be funny playing driving games the same way I drive my Tesla, lol. It would be cool if there was a way in the MiSTer.ini under the [ao486] header (or others) to change the behavior of how to map the acceleration and brake pedals (single or dual axis).

As I was typing this, sorgelig, your new comment came in. I am not sure if my MiSTer.ini idea is needed or not or if there is another way to get it to work both ways for different cores. Thanks!

sorgelig commented 2 years ago

I think making less amount axes is always easy. Core may simply subtract 2 axes to make a single one like it's done in DF-EX wheel. Actually ao486 supports dual-analog joystick, so at least 1 wheel with 4 axes and 4 buttons should be possible. I need some game names of that age supporting wheels over standard joystick connection, then i will see how to implement it.

thorr2 commented 2 years ago

Pretty much any DOS game works like a single analog joystick. "Stunts" for DOS is an example. This is in the flynnsbit Top 300 pack. Also Need for Speed. I know Stunts works, and haven't tested Need for Speed yet. https://www.youtube.com/watch?v=-hKK4_gvOS0

sorgelig commented 2 years ago

Being fan of racing games i have several wheel (as mentioned above) to play mostly GranTourismo series and some Forza Horizon games. Main purpose of wheels for me is feedback. Here we are talking about wheels without feedback, so it's pretty much a dummy big gamepad.. It doesn't resemble me a wheel experience, that's why i'm skeptical about usefulness of the whole this hassle even having compatible wheels...

thorr2 commented 2 years ago

It's retro gaming, and games at that time didn't support it. We can play modern games with our wheels too, but I miss the old games and want to use my wheel like I did back in the day with my Thrustmaster. :-)

thorr2 commented 2 years ago

The PSX is of most interest to me personally, so if only that gets fully supported, I would still be happy. ao486 would still work with one foot driving and might be good enough if it is too much work to implement as a special case.

thorr2 commented 2 years ago

Why we need wheel support: https://www.youtube.com/watch?v=UIFcVhRWWX4 It would be a shame to be limited to a thumbstick. ;-)

thorr2 commented 2 years ago

coolbho3k I tried your suggestion to get the debug output. It worked to see things, but nothing I do with the steering wheel or its buttons shows up in the output. Typing on the keyboard shows all kinds of stuff, so I know it is otherwise working. Let me know if you want me to try anything else. Thanks! lsusb shows: Bus 001 Device 007: ID 046d:c294 Logitech, Inc. Driving Force

coolbho3k commented 2 years ago

I also agree it's worth it to add wheel support. This would be a great "enhanced" way to play all PSX racing games. With my test branch and the PSX , playing Gran Turismo is quite good, even with no real FFB. We'll never have proper force feedback as it's just not in any of these games originally. However, I can see simulating controller rumble with FF_PERIODIC being pretty cool. And, budget wheels without true FFB like Hori and PXN with just rumble and a physical centering spring sell a lot of units for modern racing games. And as a bonus, it would be truly funny to play old arcade and PSX games with modern high-end racing equipment.

Wheel is also the native control scheme of many old arcade racing games, and not all of them had real force feedback either. It would be the only way to play these games with "authentic" controls on MiSTer.

@sorgelig If you want to take this on, I will pause my efforts. In my code I added a hard coded map of VID and PID for wheels, and add a QURIK to remap the axes on the devices that are found in the map. Not sure if that's a preferred way of doing it.

@thorr2 To me it sounds like an issue with kernel drivers. To my knowledge, it really should be working. It may be best to see if @sorgelig can get Logitech wheels working with the kernel. I would try it if I had the wheel.

coolbho3k commented 2 years ago

Here's a video of Gran Turismo on my test branch: https://www.youtube.com/watch?v=uTh8pJ7a_Vk

It's really not bad at all.

thorr2 commented 2 years ago

Awesome! Great job! I am officially jealous at the moment. ;-) I also have an Act Labs Force RS wheel, shifter and pedals that I was planning to use with my arcade cabinet that I am building with interchangeable control panels. I haven't tried it yet. It would be cool if there was a way to add any kind of wheel by specifying it as a wheel by the vid/pid (as long as it works with the kernel). Just an idea. I am looking forward to being able to play the PSX games! I previously played the Need for Speed series games on a PC with a 3D card and the PSX is pretty close to the same on the MiSTer (except possibly missing FFB depending on the game). It's very impressive that the MiSTer has that much power in the PSX core.

On Tue, Apr 19, 2022, 10:37 PM Michael Huang @.***> wrote:

Here's a video of Gran Turismo on my test branch: https://youtube.com/shorts/uTh8pJ7a_Vk?feature=share

It's really not bad at all.

— Reply to this email directly, view it on GitHub https://github.com/MiSTer-devel/Main_MiSTer/issues/575#issuecomment-1103490534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMVRPLRZU463VSX6RPCVD23VF6JZPANCNFSM5RINQA5A . You are receiving this because you were mentioned.Message ID: @.***>

sorgelig commented 2 years ago

@coolbho3k i will add wheel support for logitech wheels i'm able to test. Then you can add your wheels too.

sorgelig commented 2 years ago

@coolbho3k i've pushed my changes for wheels. I didn't look into cores yet, but you can add your wheel to the same mapping.

I forgot that stick up direction gives negative values, so accel and break generate negative-only values to mimic sticks.

coolbho3k commented 2 years ago

@sorgelig Great, I'll take a look tonight and see if I can I can add support for the 3 Fanatec wheels I can test, then I'll test functionality the best I can, probably using some debug logging if it doesn't work with cores yet.

sorgelig commented 2 years ago

i've tried Gran Turismo on PSX. I can steer by left analog stick but gas/break are on buttons, they aren't analog. Is it how Pedals should be mapped? What is control scheme of racing games on PSX?

coolbho3k commented 2 years ago

@sorgelig I set the controller type for Player 1 to NeGcon.

By default, accelerate will be mapped to analog button I on NeGcon and brake will be be mapped to analog button II on NeGcon.

Right now, the PSX core maps right stick up to button I and right stick down to button II.

You can also remap controls in in-game settings menu. For example I mapped upshift and downshift to the paddle shifters.

birdybro commented 2 years ago

The original PS1 games didn't have that kind of axis-based acceleration support, right? It was just on-off. They added the analog axis-based accelerate and brake on PS2 and PS3 with official Gran Turismo racing controllers. PS1 race controllers just had the brake and gas mapped to the buttons, like the Mad Catz MC2 does, I'm pretty sure.

Pressure sensitive buttons (on dual shock 2) and analog stick brake/gas mapping came with PS2/PS3 racing games I thought.

thorr2 commented 2 years ago

@birdybro This is incorrect. What coolbho3k said is correct. Look up the NeGcon and JogCon controllers and what games were supported. Edit: See here: https://en.wikipedia.org/wiki/NeGcon

sorgelig commented 2 years ago

jogcon didn't have analog buttons, only jog itself.

NegCon control scheme doesn't look good as steering is digital, so either full left or full right. Analog gamepad with digital gas/brake is better. It seems there is no option for analog steering and analog pedals.

thorr2 commented 2 years ago

@sorgelig I was able to use my DualShock 3 controller's two thumbsticks and set the core to NeGcon and have both analog steering and acceleration. This is from memory. Maybe the analog shoulder buttons work also/instead. I think I tried it with R4 Ridge Racer Type 4, but it should work with everything. Steering is analog on NeGcon - you twist it.

sorgelig commented 2 years ago

yeah, steering in negcon mode is indeed analog, just very sensitive. I'm trying different options using gamepad. So negcon controls looks good.

sorgelig commented 2 years ago

i see core combines 2 analog buttons into a single axis which definitely not a good idea. Physically 2 buttons can be pressed at the same time. Anyway, there is a way to add wheel with 3 analog axes.

thorr2 commented 2 years ago

Yeah, I was wondering, worried about that. I would recommend the core be changed to use the shoulder buttons instead of the thumbstick.

coolbho3k commented 2 years ago

For Gran Turismo:

NeGcon mode: The "I" and "II" buttons on NeGcon are analog, Gran Turismo supports it by default for analog throttle and brake. The closest equivalent on modern controllers is the L2/R2 triggers. And yes, the core combines them into a single axis, so pressing them both fully will result in 0.

DualShock mode: You can actually get analog throttle/brake by mapping them to the right stick in the game settings. But the steering is not linear and it feels bad to me. The NeGcon mode feels much better.

sorgelig commented 2 years ago

Yeah, I was wondering, worried about that. I would recommend the core be changed to use the shoulder buttons instead of the thumbstick.

MiSTer currently doesn't support analog triggers. I will think about it. Anyway, it doesn't prevent wheel implementation.

sorgelig commented 2 years ago

I've pushed wheel support in PSX core. Works ok, so far. Now i want to find out pinouts for wheel connection to PC over gameport. And i cannot find it :(

coolbho3k commented 2 years ago

Ok. Will try it out after work, and I'll propose some further configuration for wheels (wh_type or similar) in a PR if axis doesn't work properly on the Fanatec wheels.

Next we should add Thrustmaster, expand Logitech and Fanatec wheel support, etc. but we need people to provide debug info.

sorgelig commented 2 years ago

I don't think we need to run in front of locomotive. The one who wants to add their wheel into supported can provide either PR (preferable) or at least some info. Probably some wheels will need special handling and physical access to device to discover all required setup procedures.

thorr2 commented 2 years ago

I've pushed wheel support in PSX core. Works ok, so far. Now i want to find out pinouts for wheel connection to PC over gameport. And i cannot find it :(

Just so I understand, does this mean if I run update_all, I can now try this with my Logitech wheel, or is it still in the staging pipeline for a later release? Edit: I am home now and checked. This was pushed to github, not for release. ;-)

For the pinouts for wheel connection to PC over gameport, it is the same as a single analog joystick with either two or four buttons. The steering wheel is Joy 1 X-axis analog, acceleration is the upper half of Joy 1 Y-axis analog, and braking is the lower half of Joy 1 Y-axis. There may be some games that support joystick 2's two buttons so there could be up to four, but generally I can't think of anything using joystick 2's analog joystick for driving games. Here is the pinout: https://obrazki.elektroda.pl/6082738200_1640131129.png

FYI - I am leaving Sunday for vacation and won't be able to test my Logitech G25 after Saturday. If there is a way for me to test by manually installing some files, and you want me to, please let me know. I will be back next Friday (one week from now) for two days, then leaving again for just a couple of days.

thorr2 commented 2 years ago

I don't think we need to run in front of locomotive. The one who wants to add their wheel into supported can provide either PR (preferable) or at least some info. Probably some wheels will need special handling and physical access to device to discover all required setup procedures.

I am in no hurry at all, but eventually I would like to test my Act Labs Force RS. It is basically the same as the G25 in terms of controls, except the stick shifter is a completely separate USB device. I can't remember for sure, but the pedals may be a separate USB device also. I have no idea if that would cause issues or not. I certainly don't want to generate a lot more work for anyone and could live without support for this wheel. I am just sharing the info in case it is helpful to think about for future support of wheels ideas.

My plan is to use this with my arcade cabinet, and right now, there are not a lot of driving games for arcade on the MiSTer, so it will be used with Mame until the games come to the MiSTer (such as Outrun, Turbo, Pole Position, Hard Drivin', etc.). In other words, I don't need it in MiSTer right now. I sort of doubt there are any other MiSTer users still using that particular wheel also.

coolbho3k commented 2 years ago

@thorr2 Hmmm, separate USB devices are going to be a bit more complicated to add support for, because now MiSTer input framework is going to see them as separate players.

To test with your G25, you have to get the latest nightly for both Main_MiSTer and the PSX core.

Everything looks perfect already with the Fanatec wheel! There's no need to tweak the axis stuff at all.

I can also hang around the issue tracker and help folks add support for other wheels when needed, if they cannot provide a PR themselves. Thanks @sorgelig!

thorr2 commented 2 years ago

Thanks @sorgelig and @coolbho3k! You guys are the best! I will attempt to test right now...

coolbho3k commented 2 years ago

@thorr2 Oh, make sure you set the PSX core to NeGcon_Wheel for player 1 input

When I mapped my buttons on the wheel, I also skipped all the mapping for any analog axis.

thorr2 commented 2 years ago

@coolbho3k Sorry for not knowing what I am doing, but I went here: https://github.com/MiSTer-unstable-nightlies/Main_MiSTer and I see that there was an update for the wheel, but I am not sure what to download. The latest thing under releases is from April 13.

coolbho3k commented 2 years ago

@coolbho3k Sorry for not knowing what I am doing, but I went here: https://github.com/MiSTer-unstable-nightlies/Main_MiSTer and I see that there was an update for the wheel, but I am not sure what to download. The latest thing under releases is from April 13.

You can get it from the #unstable-nightlies channel in the MiSTer Discord:

Main MiSTer: https://github.com/MiSTer-unstable-nightlies/Main_MiSTer/releases/download/unstable-builds/MiSTer_unstable_20220421_21e640 - download and replace /media/fat/MiSTer - you should back up your old MiSTer binary

PSX: https://github.com/MiSTer-unstable-nightlies/PSX_MiSTer/releases/download/unstable-builds/PSX_unstable_20220421_209849.rbf

thorr2 commented 2 years ago

@coolbho3k Thanks! It's not working, but I think I know why. I think I need the latest OS as well in order for it to work with my wheel. Any suggestions on how to update the OS would be greatly appreciated.