nightmode / logitech-g29

Logitech G29 Racing Wheel for Node
Creative Commons Zero v1.0 Universal
104 stars 35 forks source link

Add support for G920 Driving Force Racing Wheel for Xbox One #22

Closed trentrand closed 1 year ago

trentrand commented 1 year ago

This library works well for the G920 Wheel! Adding support only required adding this device's details to the connection process.

Not sure how you want to brand this repo, but it could be worth adding note of G920 support to places like the README.md.

nightmode commented 1 year ago

Wow, unexpected.

So just by adding a bit of logic to search for productId === 49762 or product === 'G920 Driving Force Racing Wheel for Xbox One' you were able to connect your G920 wheel?

Were you also able to use every feature of you G920? Like all the buttons, pedals, and shifters? Oh and what about the Xbox button? Does that show up as an event when you press it?

I do not currently have a G920 so my questions are based on the images of the wheel on the Logitech site. https://support.logi.com/hc/en-us/articles/360025417153--Product-Gallery-G920-Driving-Force-Racing-Wheel

trentrand commented 1 year ago

Yes, exactly! Everything works and dispatches a unique event, but the event payloads seem a little odd.

Here's a diagram of the G920 controls: Logitech G920 wheel inputs diagram

Below I've mapped out the event payload, each corresponding with the label from the diagram above:

Input 1 (LB) -
  Pressed: `{ shifter: { gear: 2 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 2 (Dpad Up) -
  Pressed: `{ wheel: { shift_left: 0, shift_right: 0, button_l2: 0, button_r2: 0 } }`
  Idle: `{ wheel: { shift_left: 1, shift_right: 1, button_l2: 1, button_r2: 1 } }`

Input 3 (Back) -
  Pressed: `{ shifter: { gear: 4 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 4 (LSB) -
  Pressed: `{ shifter: { gear: 6 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 5 (RB) -
  Pressed: `{ shifter: { gear: 1 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 6 (A) -
  Pressed: `{ wheel: { button_share: 1 } }`
  Idle: `{ wheel: { button_share: 0 } }`

Input 6 (B) -
  Pressed: `{ wheel: { button_option: 1 } }`
  Idle: `{ wheel: { button_option: 0 } }`

Input 6 (X) -
  Pressed: `{ wheel: { button_r3: 1 } }`
  Idle: `{ wheel: { button_r3: 0 } }`

Input 6 (Y) -
  Pressed: `{ wheel: { button_l3: 1 } }`
  Idle: `{ wheel: { button_l3: 0 } }`

Input 7 (Start) -
  Pressed: `{ shifter: { gear: 3 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 8 (RSB) -
  Pressed: `{ shifter: { gear: 5 } }`
  Idle: `{ shifter: { gear: 0 } }`

Input 9 (Xbox) -
  Pressed: `{ shifter: { gear: -1 } }`
  Idle: `{ shifter: { gear: 0 } }`

And here's a diagram for the pedals:

Logitech G920 pedal inputs diagram

And the corresponding event payloads for each pedal:

Input 1 (Clutch) -
  Maximum: `{ pedals: { clutch: 1 } }`
  Minimum / Idle: `{ pedals: { clutch: 0.00 } }`
  Increment: `0.01`

Input 2 (Brake) -
  Maximum: `{ pedals: { brake: 1 } }`
  Minimum / Idle: `{ pedals: { brake: 0.00 } }`
  Increment: `0.01`

Input 3 (Throttle) -
  Maximum: `{ pedals: { gas: 1 } }`
  Minimum / Idle: `{ pedals: { gas: 0.00 } }`
  Increment: `0.01`
nightmode commented 1 year ago

Ah the mis-matched events make sense since this library is currently specialized for the G29 and the G920 is probably sending data in a slightly different format than expected.

You could probably figure out which button, pedal, wheel turn, etc... does what by inspecting the raw data coming from the wheel. In some cases, at least for the G29, some data was not easily viewed by looking at integers, but instead required checking even lower level, at the bits level, to see which bits where on or off. It is a lot of tracing work. :o

You may find some of the scripts inside the test folder useful for troubleshooting and tracing events, especially if you have already figured out how to connect to the wheel. I am also assuming your wheel is happy with the default init commands but I am just guessing.

Ok, long story short, I think you are on a good path and if want to and do end up figuring out how to get Node and the G920 to work together, consider sharing it as a library for others.

I have occasionally thought of making a more general use library that would support more than one wheel system, simultaneous wheels, and perhaps a way to easily extend the library to support things I don't physically have, but... that is only an occasional thought. Not sure when or even IF I will end up building something like that.

trentrand commented 1 year ago

Thanks for the additional context! I'm going to dig in more and assess the required effort to fix those input mappings and initiation command.

Just to be explicit about the request - if I do get this working, you're suggestion is to fork this repo into a new repo named logitech-g920 and publish it as a new npm package?

nightmode commented 1 year ago

Oh yes please, feel free to fork this repo and name it logitech-g920 (or whatever name you like and/or is available on NPM). I would normally want to help out more but since I don't have G920 hardware, I will just hope things go well with your investigations and/or coding. ^_^