ZRtmWrJqXcjbqBLIMBYMCeUw / Logitech-G923-Linux-Kernel-Driver

This project is intended to add support for the Logitech G923 steering wheel to the Linux kernel.
GNU General Public License v3.0
32 stars 0 forks source link

G923 Xbox version current state #5

Open s3rg3 opened 2 years ago

s3rg3 commented 2 years ago

To switch to the Xbox mode i added these two files, because the xpad patch will not make it to the kernel, and they used USB_ModeSwitch for the G920

/etc/usb_modeswitch.d/046d:c26d :

#Logitech G923 Racing Wheel (Xbox Mode)
DefaultVendor=046d
DefaultProduct=c26d
MessageEndpoint=01
ResponseEndpoint=01
TargetClass=0x03
MessageContent="0f00010142"

/etc/udev/rules.d/40-usb_modeswitch.rules :

#Logitech G923 Racing Wheel (Xbox Mode)
ATTR{idVendor}=="046d", ATTR{idProduct}=="c26d", RUN+="usb_modeswitch '%b/%k'"

i posted a request at USB_ModeSwitch forum to add those files in the program.

Then i patched the kernel with these 3 files:

--- a/drivers/hid/hid-ids.h 2021-12-28 22:33:06.000000000 +0100
+++ b/drivers/hid/hid-ids.h 2022-01-04 18:28:24.652408404 +0100
@@ -797,6 +797,7 @@
 #define USB_DEVICE_ID_LOGITECH_G510_USB_AUDIO  0xc22e
 #define USB_DEVICE_ID_LOGITECH_G29_WHEEL   0xc24f
 #define USB_DEVICE_ID_LOGITECH_G920_WHEEL  0xc262
+#define USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL 0xc26e
 #define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
 #define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286
 #define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940  0xc287
--- a/drivers/hid/hid-logitech-hidpp.c  2021-12-28 22:33:06.000000000 +0100
+++ b/drivers/hid/hid-logitech-hidpp.c  2022-01-04 18:32:45.669070137 +0100
@@ -4323,6 +4323,9 @@
    { /* Logitech G920 Wheel over USB */
      HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL),
        .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS},
+   { /* Logitech G923 Wheel (Xbox version) over USB */
+     HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL),
+       .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS },
    { /* Logitech G Pro Gaming Mouse over USB */
      HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC088) },
--- a/drivers/hid/hid-quirks.c  2022-01-15 17:00:20.645923000 +0100
+++ b/drivers/hid/hid-quirks.c  2022-01-15 17:12:37.822606103 +0100
@@ -479,6 +479,7 @@
 #endif
 #if IS_ENABLED(CONFIG_HID_LOGITECH_HIDPP)
    { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL) },
+   { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL) },
 #endif
 #if IS_ENABLED(CONFIG_HID_MAGICMOUSE)
    { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },

Here is the result of dmesg once the kernel is patched:

[  966.220496] usb 2-1.8: new full-speed USB device number 5 using ehci-pci
[  966.319843] usb 2-1.8: New USB device found, idVendor=046d, idProduct=c26d, bcdDevice=39.01
[  966.319854] usb 2-1.8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  966.319857] usb 2-1.8: Product: G923 Racing Wheel for Xbox One and PC
[  966.319860] usb 2-1.8: Manufacturer: Logitech
[  966.319862] usb 2-1.8: SerialNumber: xxxxxxxxxxxxxxxx
[  966.381285] audit: type=1130 audit(1642337004.482:67): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=usb_modeswitch@2-1.8 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
[  966.396840] audit: type=1130 audit(1642337004.495:68): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=usb_modeswitch@2-1.8 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
[  967.040241] usb 2-1.8: USB disconnect, device number 5
[  968.273827] usb 2-1.8: new full-speed USB device number 6 using ehci-pci
[  968.373740] usb 2-1.8: New USB device found, idVendor=046d, idProduct=c26e, bcdDevice=39.01
[  968.373749] usb 2-1.8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  968.373752] usb 2-1.8: Product: G923 Racing Wheel for Xbox One and PC
[  968.373755] usb 2-1.8: Manufacturer: Logitech
[  968.373757] usb 2-1.8: SerialNumber: xxxxxxxxxxxxxxxx
[  968.432276] logitech-hidpp-device 0003:046D:C26E.0007: HID++ 4.2 device connected.
[  968.466558] input: Logitech G923 Racing Wheel for Xbox One and PC as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.8/2-1.8:1.0/0003:046D:C26E.0007/input/input34
[  968.466998] logitech-hidpp-device 0003:046D:C26E.0007: input,hiddev97,hidraw3: USB HID v1.11 Joystick [Logitech G923 Racing Wheel for Xbox One and PC] on usb-0000:00:1d.0-1.8/input0
[  968.467205] logitech-hidpp-device 0003:046D:C26E.0007: Force feedback support loaded (firmware release 1).
[  968.467967] logitech-hidpp-device 0003:046D:C26E.0008: hiddev98,hidraw4: USB HID v1.11 Device [Logitech G923 Racing Wheel for Xbox One and PC] on usb-0000:00:1d.0-1.8/input1
[  969.486385] audit: type=1130 audit(1642337007.585:69): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=usb_modeswitch@2-1.8 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[  969.486398] audit: type=1131 audit(1642337007.585:70): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=usb_modeswitch@2-1.8 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

The wheel is recognized with the master branch of oversteer, the force feedback is working, but the pedals are inversed, probably others buttons too.

Here is the result i get when launching steam:

Local Device Found
  type: 046d c26e
  path: sdl://0
  serial_number:  - 0
  Manufacturer: 
  Product:      Logitech G923 Racing Wheel for Xbox One and PC
  Release:      111
  Interface:    -1

!! Steam controller device opened for index 0.
Steam Controller reserving XInput slot 0
BYieldingQueryAccountsRegisteredToController
Controller 0 mapping uses xinput : false
Opted-in Controller Mask for AppId 0: 8

Controller has an Invalid or missing unit serial number, setting to '46d-c26e-57f55e0'

From what i read from the internet the last line about the serial number is fine.

Euro Truck Simulator 2 was playable with some force feedback, during the short test i made.

Ferals Interactive native games (Dirt Rally, F1 2017, Dirt 4)do not recognize the wheel, i tweaked the files to add ids and more.

With Dirt 4 the most recent title i also symlinked the sdl libs to the systems one because Feral is using a custom one for some fixes, and newer sdl version have the G923 Xbox version id included, the wheel is not accepted as input, but auto center and 400 degrees angle are set by the game.

Proton Games (Dirt 5, Grid 2019, Dirt Rally 2) do not reconized the wheel, even with a custom Proton version with patched WINE

All those test where done with Steam input desactivated.

mvwestendorp commented 2 years ago

@s3rg3 Thanks for the instructions! I get the same output as you have described (on Manjaro adapting the instructions given here). Indeed the wheel is recognised in oversteer but pedals are mixed up. Trying it with some Proton games (Dirt Rally 2, Project Cars 2) also not recognising the wheel. Furthermore it cycles through the vertical menus implying that the buttons are mixed up as said.

I would prefer not having to use Windows just for having this wheel supported, so I am happy to do some testing if that is helpful.

s3rg3 commented 2 years ago

I did some test this week with more games and proton 7.0-1, almost all the games (including Dirt Rally 2 and Project Cars 2) now have working input but the force feedback is still not detected.

You should try with a newer proton version, if not already the lastest one, i also modified the patches to disable the second input as it have been done for the g29, but it doesn't seems to have any effect.

--- a/drivers/hid/hid-logitech-hidpp.c  2022-01-15 17:00:20.642589000 +0100
+++ b/drivers/hid/hid-logitech-hidpp.c  2022-02-01 18:39:31.189165714 +0100
@@ -63,6 +63,7 @@
 #define HIDPP_QUIRK_CLASS_M560         BIT(1)
 #define HIDPP_QUIRK_CLASS_K400         BIT(2)
 #define HIDPP_QUIRK_CLASS_G920         BIT(3)
+#define HIDPP_QUIRK_CLASS_G923         BIT(3)
 #define HIDPP_QUIRK_CLASS_K750         BIT(4)

 /* bits 2..20 are reserved for classes */
@@ -3487,8 +3488,8 @@
    if (!hidpp)
        return 0;

-   /* Ensure that Logitech G920 is not given a default fuzz/flat value */
-   if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
+   /* Ensure that Logitech G920 and G923 are not given a default fuzz/flat value */
+   if ((hidpp->quirks & HIDPP_QUIRK_CLASS_G920) || (hidpp->quirks & HIDPP_QUIRK_CLASS_G923)) {
        if (usage->type == EV_ABS && (usage->code == ABS_X ||
                usage->code == ABS_Y || usage->code == ABS_Z ||
                usage->code == ABS_RZ)) {
@@ -4058,6 +4059,19 @@
    hidpp->hid_dev = hdev;
    hidpp->name = hdev->name;
    hidpp->quirks = id->driver_data;
+
+   /* G293_xbox only work with the 1st interface */
+   if (hidpp->quirks & HIDPP_QUIRK_CLASS_G923) {
+       struct usb_interface *iface;
+       __u8 iface_num;
+       iface = to_usb_interface(hdev->dev.parent);
+       iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
+       if (iface_num != 0) {
+           dbg_hid("%s: ignoring ifnum %d\n", __func__, iface_num);
+           return -ENODEV;
+       }
+   }
+
    hid_set_drvdata(hdev, hidpp);

    ret = hid_parse(hdev);
@@ -4161,7 +4175,7 @@
        ret = wtp_get_config(hidpp);
        if (ret)
            goto hid_hw_init_fail;
-   } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) {
+   } else if (connected && ((hidpp->quirks & HIDPP_QUIRK_CLASS_G920) || (hidpp->quirks & HIDPP_QUIRK_CLASS_G923))) {
        ret = g920_get_config(hidpp, &data);
        if (ret)
            goto hid_hw_init_fail;
@@ -4184,7 +4198,7 @@
        goto hid_hw_start_fail;
    }

-   if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
+   if ((hidpp->quirks & HIDPP_QUIRK_CLASS_G920) || (hidpp->quirks & HIDPP_QUIRK_CLASS_G923)) {
        ret = hidpp_ff_init(hidpp, &data);
        if (ret)
            hid_warn(hidpp->hid_dev,
@@ -4323,6 +4337,9 @@
    { /* Logitech G920 Wheel over USB */
      HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL),
        .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS},
+   { /* Logitech G923 Wheel (Xbox version) over USB */
+     HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL),
+       .driver_data = HIDPP_QUIRK_CLASS_G923 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS },
    { /* Logitech G Pro Gaming Mouse over USB */
      HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC088) },
diff --unified --recursive --text a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
--- a/drivers/hid/hid-quirks.c  2022-01-15 17:00:20.645923000 +0100
+++ b/drivers/hid/hid-quirks.c  2022-01-15 17:12:37.822606103 +0100
@@ -479,6 +479,7 @@
 #endif
 #if IS_ENABLED(CONFIG_HID_LOGITECH_HIDPP)
    { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL) },
+   { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL) },
 #endif
 #if IS_ENABLED(CONFIG_HID_MAGICMOUSE)
    { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },

i also recently started to implement the RPM indicator leds in case this is the thing blocking a proper wheel detection, but it will take a long time if i ever succeed to do it as i am not a skilled developer.

mvwestendorp commented 2 years ago

I am using the newest proton (7.0-1). Some looking around in Steam shows the wheel being detected as a generic controller. This leads the steers rotation and accelerator axis being seen as the left joystick of the controller and the clutch as the right joystick. This explains my experience of cycling through the menus since not touching the accelerator equals keeping the left joystick on a controller down.

Is the wheel also detected as a generic controller for you? I'll try that patch this weekend to see if it has an effect for me.

s3rg3 commented 2 years ago

You have to right click on the game, then on properties, and go to controller, and deactivate steam input.

Steam input is remapping the wheel as an xbox controller and you don't want that.

Without steam input, you can actually play most of the racing games on proton.

You can also set the wheel angle and autocenter with oversteer, but it's not that fun without all the force feedback effects.

mvwestendorp commented 2 years ago

For me it shows up as a generic controller. Disabling steam input has no effect for me for some reason.

s3rg3 commented 2 years ago

You could try to delete the SDL_GamepadBind entry in ~/.steam/steam/config/config.vdf

I did it at some point, It will be recreated.

mvwestendorp commented 2 years ago

I have tried that and also deleting the whole config.vdf file. It is recreated but doesn't seem have changed anything for me unfortunately.

s3rg3 commented 2 years ago

Sorry to hear that, i don't recall doing something else special.

I tested different settings with steam inputs while having the same issue you are describing and ended with deleting the SDL_GamepadBind entry to reset all of that.

It didn't make it work, and i only have it working later with the latest proton version.

Maybe once steam input is activated with a proton profile, it set some things in it, you could try erasing it.

codesnippy commented 2 years ago

Hi I have a G923 Xbox version. I am trying to get it working on Debian bullseye with KDE desktop. I have gotten the usb_modeswitch part working. This makes it so KDE input device settings for Game controllers sees the wheel now. and all the buttons peddles and gear switches. Although the wheel has a 45 degree dead zone on the steering wheel in both directions in the KDE input device settings menu. This makes the game Euro Truck simulator 2 unplayable for me. Strange thing is that in the game City Car Driving there is no dead zone at all. It only does not detect the shifter.

Also the program oversteer sees the wheel as a G923 Xbox version however when I press one of the buttons on my wheel the program locks up and does not respond any longer.

I guess I need to do the kernel patch for this. But I have never done a patch to the kernel. Could someone take me thought how I would go about doing this. (newbie in this) Or direct me to useful info on this topic.

I am still able to exchange my driving wheel for a different model. I don't know what you would recommend in this area. Perhaps exchange it for a G923 PS edition? As I gather that this version is already in a working state. Or even to exchange for a G92 as this one is already supported by the new-lg4ff driver.

Any help would be appreciated. I am willing to do all kinds of testing for the G923 Xbox version. If someone would be willing to talk me through what I would need to be doing.

With kind regard.

s3rg3 commented 2 years ago

Hello,

Yes you need to patch your kernel for initializing the force feedback, otherwise too much forces are applied on it, and this is not usable.

You should exchange it while you can, unless you really want to experiment with it.

Also patching a kernel with debian is probably not an easy task.

codesnippy commented 2 years ago

What do you recommend the G923 PS edition vs G29. Which one is best supported. and in working condition?

s3rg3 commented 2 years ago

I don’t own any of those wheels, but i guess they are both fully working except for the G923 trueforce.

If you want to play natives games G29 should already be configured for them, and with the G923 you have to tweak the files.

And if you want to play with proton, both should be already configured.

Also with the G29 you can use the compatibility mode to emulate other ancient Logitech wheels.

codesnippy commented 2 years ago

Thanks you for the quick reply and the info I think I am going to try to get it exchanged with a G29