Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller loses connection randomly #171

Closed
ipkpjersi opened this issue Mar 29, 2020 · 20 comments
Closed

Controller loses connection randomly #171

ipkpjersi opened this issue Mar 29, 2020 · 20 comments

Comments

@ipkpjersi
Copy link
Contributor

Describe the bug
When I use the Xbox One controller, it randomly loses connection. My Bluetooth headphones are fine and stay connected, it's just my Xbox One controller stops accepting inputs from me and then the Xbox button light starts blinking instead of staying solid and it keeps blinking until it reconnects again.

To Reproduce
Use Ubuntu 18.04 LTS with the Xfce DE with latest xpadneo on any game

Expected behavior
I expect using the Xbox One controller to stay connected like my Bluetooth headphones

If you require any additional details please let me know. I'm not sure if this is an issue with xpadneo, a Bluetooth hardware issue (I actually tried 3 different Bluetooth USB adapters), an issue with the Xbox One controller, or something else entirely.

@kakra
Copy link
Collaborator

kakra commented May 3, 2020

Please list the model names of the dongles used. lsusb is helpful as a first step.

kakra added a commit to kakra/xpadneo that referenced this issue May 3, 2020
According to hid-microsoft.c, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
kakra added a commit to kakra/xpadneo that referenced this issue May 3, 2020
The user-space driver implementation xow only sends rumble reports to
the device if the rumble motors are running or the desired magnitude is
non-zero.

To implement this here, we first allocate a private device structure
for maintaining the rumble state. This will be passed in via the
`input_ff_create_memless()` hook. Additionally, in the hook we need
to protect concurrent access to the structure with a spinlock, tho I'm
not sure if the hook may really be called in parallel. Maybe it's
better to defer this into a dedicated worker queue as `hid-microsoft.c`
does it.

This may reduce pressure on the device firmware and stabilize the
bluetooth connection.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
kakra added a commit to kakra/xpadneo that referenced this issue May 3, 2020
The user-space driver implementation xow only sends rumble reports to
the device if the rumble motors are running or the desired magnitude is
non-zero.

To implement this here, we first allocate a private device structure
for maintaining the rumble state. This will be passed in via the
`input_ff_create_memless()` hook. Additionally, in the hook we need
to protect concurrent access to the structure with a spinlock, tho I'm
not sure if the hook may really be called in parallel. Maybe it's
better to defer this into a dedicated worker queue as `hid-microsoft.c`
does it.

This may reduce pressure on the device firmware and stabilize the
bluetooth connection.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
kakra added a commit to kakra/xpadneo that referenced this issue May 3, 2020
According to hid-microsoft.c, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
kakra added a commit to kakra/xpadneo that referenced this issue May 3, 2020
The user-space driver implementation xow only sends rumble reports to
the device if the rumble motors are running or the desired magnitude is
non-zero.

To implement this here, we first allocate a private device structure
for maintaining the rumble state. This will be passed in via the
`input_ff_create_memless()` hook. Additionally, in the hook we need
to protect concurrent access to the structure with a spinlock, tho I'm
not sure if the hook may really be called in parallel. Maybe it's
better to defer this into a dedicated worker queue as `hid-microsoft.c`
does it.

This may reduce pressure on the device firmware and stabilize the
bluetooth connection.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 3, 2020

This has happened with every dongle I've used, and only happens with my Xbox One controller as my Bluetooth headphones never ever disconnect (at the moment I am using Sennheiser HD 4.50BTNC) but here is my entire output of all USB devices I am currently using, just in case any of them are conflicting:

https://pastie.io/dpdmvp.properties

I believe the device in question is Bus 003 Device 010: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Here is the link to the device: https://www.amazon.com/dp/B00FCK307I/ref=pe_3034960_236394800_TE_dp_1

@kakra
Copy link
Collaborator

kakra commented May 3, 2020

The question is if all your dongles use the same chipset...

@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 3, 2020

@kakra
Copy link
Collaborator

kakra commented May 3, 2020

Simply plug all in at once and run lsusb. ;-)

@kakra
Copy link
Collaborator

kakra commented May 3, 2020

These are the chipsets:

  • ORICO BTA Series = CSR 8510
  • Avantree DG-40S = CSR 8510
  • StarTech Mini USB Bluetooth 2.1 Adapter = CSR BC0401PC08

So it's all "Cambridge Silicon Radio" which are - at least according to the reports here - are known to have connection losses with the controller.

@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 3, 2020

Thank you for that information, that's really good to know.

Do you know of any known-working adapters? That would help me a ton and would essentially remove one of the two biggest issues I have with xpadneo.

Also, are they issues with the controller hardware, or is it an xpadneo-specific issue? In other words, would I also have this issue on Windows (not that I'm switching, just curious)?

@ugly95
Copy link

ugly95 commented May 3, 2020

My experience has been totally different. I never lose connection with CSR Bluetooth adapters. I've tested a few that were both Broadcom and CSR dongles.

There were a lot reported here: https://atar-axis.github.io/xpadneo/#bt-dongles

With Broadcom chip USB dongles, I've found that the initial connection is good, but the range is poor, there can be a lot of lag, and I got frequent disconnects, usually with the controller stuck rumbling. I also found that I had poor range and audio lag with Bluetooth headphones.

With CSR chip USB dongles, I've found that getting the controller to connect is difficult. I usually have to run echo -e 'connect 5C:BA:37:D4:46:6A' | bluetoothctl at least once to get it to connect. But after a connection is established, it works flawlessly. I don't remember ever having a disconnect with a CSR chip USB dongle. I also have problems establishing a connection with my Bluetooth headphones.

kakra added a commit to kakra/xpadneo that referenced this issue May 4, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 4, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 4, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 4, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 5, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

It also renames the motor usage from left and right to weak and strong
because no one knows if the strong motor is left or right, it also
prevents confusion with the trigger motors which are clearly left or
right.

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
@kakra
Copy link
Collaborator

kakra commented May 7, 2020

My experience has been totally different. I never lose connection with CSR Bluetooth adapters. I've tested a few that were both Broadcom and CSR dongles.

There were a lot reported here: https://atar-axis.github.io/xpadneo/#bt-dongles

With Broadcom chip USB dongles, I've found that the initial connection is good, but the range is poor, there can be a lot of lag, and I got frequent disconnects, usually with the controller stuck rumbling. I also found that I had poor range and audio lag with Bluetooth headphones.

With CSR chip USB dongles, I've found that getting the controller to connect is difficult. I usually have to run echo -e 'connect 5C:BA:37:D4:46:6A' | bluetoothctl at least once to get it to connect. But after a connection is established, it works flawlessly. I don't remember ever having a disconnect with a CSR chip USB dongle. I also have problems establishing a connection with my Bluetooth headphones.

I can confirm that this seems not to be an issue of the chipset itself. I've now ordered a new BT dongle, this time made by TP-LINK instead of some no-name product. The specs said it should have a Qualcomm chipset but in the kernel it still identifies as CSR chip with the same USB ID as my previous no-name dongle. But the behavior of this dongle is a bit different: During init from the kernel it says [28690.646596] Bluetooth: hci0: unexpected event for opcode 0x0000 but nevertheless it works just fine. And what should I say? Not just fine but perfectly it seems: With the rumble test program I could reliably kill the connection previously, now it runs just fine for minutes and even multiple times repeated on the same connection (without power-cycling the controller). Maybe my previous dongle was some China fake chipset.

If anyone wants to try, here's the link: https://www.amazon.de/gp/product/B07NQ5YGDW/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

OTOH, I now have similar initial connection problems as @ugly95.

kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

It also renames the motor usage from left and right to weak and strong
because no one knows if the strong motor is left or right, it also
prevents confusion with the trigger motors which are clearly left or
right.

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: atar-axis#154
Affects: atar-axis#149
Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

It also renames the motor usage from left and right to weak and strong
because no one knows if the strong motor is left or right, it also
prevents confusion with the trigger motors which are clearly left or
right.

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: atar-axis#171
Maybe-related: atar-axis#122
Maybe-affects: atar-axis#180
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 7, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit to kakra/xpadneo that referenced this issue May 8, 2020
We are running the rumble motors as long as possible, there's no need
for sending the same packets over and over again: ff-memless has a
time resolution of 50ms and thus would make us send a packet 20 times
per second even when nothing changed.

Maybe-related: atar-axis#180
Maybe-fixes: atar-axis#171
Maybe-fixes: atar-axis#122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit that referenced this issue May 8, 2020
According to `hid-microsoft.c`, the device supports magnitudes in the
range of 0..100.

This commit scales the magnitudes correctly from 0..65535 to 0..100 and
also uses a finer scale for the pre-calculated cosine table to have
more than 4 steps on each trigger.

Additionally, it considerably reduces the strength of the connection
notification rumble. The controller no longer tends to hop down the
table.

I don't have any specs of this but sending too high values may affect
the stability of the firmware thus this may reduce connection losses
observed in some issue reports.

This also removes the over-use of blank lines: It confuses git during
rebase as it allows splitting logical self-contained hunks into
seemingly unrelated blocks on too many opportunities.

Closes: #154
Affects: #149
Maybe-related: #171
Maybe-related: #122
Signed-off-by: Kai Krakow <[email protected]>
kakra added a commit that referenced this issue May 8, 2020
This makes the rumble playback asynchronous from the playback callback.

This reworks much of the code-design and replaces the previous patch
for sending rumble reports only when there's a rumble command to do.
With this change, we now get the following kernel message immediately
on disconnects:

    xpadneo 0005:045E:02FD.0054: failed to send FF report

It also renames the motor usage from left and right to weak and strong
because no one knows if the strong motor is left or right, it also
prevents confusion with the trigger motors which are clearly left or
right.

The general design is a valuable effort on improving code quality, as
it simplifies some complex functions.

Maybe-related: #171
Maybe-related: #122
Maybe-affects: #180
Signed-off-by: Kai Krakow <[email protected]>
@kakra kakra closed this as completed in a86f70a May 8, 2020
@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 8, 2020

I just realized, I have rumble (force feedback) disabled, so this issue may still actually be valid, I'm not sure.

I will test xpadneo tonight and see if #171 and #57 are both "okay" or if I am still experiencing those issues.

@kakra
Copy link
Collaborator

kakra commented May 8, 2020

Feel free to re-open any of those if issues still persist and post the output of dmesg (just the recent lines not the whole log). But to me it clearly looks like a hardware issue with the dongle: I've tested two dongles (same chipset according to lsusb but one is probably a China fake or buggy version): One dongle has absolutely no intermittent connection issues but only an issue auto-connecting after turning the controller on. The other connects just fine but looses the connection especially on rumble commands.

My commit 8392d59 may mitigate the problem but chances are very low that it helps. My best tip is: Buy another dongle. My example shows that it doesn't need to be a different chipset, just a different maker/distributor.

@ipkpjersi
Copy link
Contributor Author

The disconnect did happen again, and this time my headphones disconnected too (that doesn't normally happen, maybe 1 out of every 10 disconnects). I think it might be a hardware issue, but it's not like the Bluetooth adapter I'm using right now is cheap or anything, it's class 1 supposed to be good up to 50m:
https://www.amazon.com/dp/B00FCK307I/ref=pe_3034960_236394800_TE_dp_1

Here is my dmesg although I think only the last 10 lines are relevant:
https://gist.github.com/ipkpjersi/a3e21d8d1e5edc7711dd18661681f75e

@kakra
Copy link
Collaborator

kakra commented May 9, 2020

Actually, I'm pretty sure by now that all that fuzz about "50m", "EDR" etc are just marketing bla bla. In the end, most have the CSR chipset inside and are nano adapters. So it's probably a chipset spec, and I'm not sure if that really works with a nano design. My first adapter I bought was announced to have 100m range outside and 10m inside of buildings. But that's just not true. It's maybe more like 3m if a wall blocks the signal. And even then, it's no longer a reliable connection, mostly just enough to not disassociate.

Your dmesg output indicates that you booted the device with an older version of xpadneo first, and later reconnected with a newer version.

The line [ 689.683053] xpadneo 0005:045E:02FD.0009: pretending XB1S Windows wireless mode (changed PID from 0x02FD to 0x02E0) is from the new driver version. It indicates your controller is connected in Linux mode (ID 0x02FD) and the driver pretends it to be 0x02E0 now (applications will see that ID when looking at the input layer). This is needed to get the guide button working again in all applications. You wrote you'd have another controller?

There's no sign of the output report for rumbling failing - otherwise you'd see a message failed to send FF report. But the kernel doesn't even notice the connection breaking down. You could run wireshark in parallel and open the BT monitor from there. It will show some layer 2 messages of the bluetooth protocol which the driver cannot see.

When the controller seemingly disconnects: Does rumble still play or does it stop immediately? Do input events still work at least for a few more seconds when rumble stops working correctly?

The difference between the old and the new driver version is that output and input reports for the controller are no longer interlocked: The driver can still receive input reports should they occur while the output reports for rumble could become stuck or delayed. Previously, input would queue up and no longer processed while the driver tried to send rumble reports. But there's probably still some synchronization at the BT layer.

Maybe try a different BT dongle. The one I linked works fine for me during use besides from the initial connection problem. It's the same chipset I already had just a different brand/label:

# lsusb
[...]
Bus 002 Device 013: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
                       ^^^^:^^^^

So there seems to be more to it than just this chipset.

Another chance would be trying a different chipset. I wanted to try a Qualcomm chip but wasn't able to easily find one. That's from the guys who usually also make chips for Android devices so I was seeing a good chance there.

I think we cannot do much here... If anything, it would need adjustments in the kernel source for the BT chipset drivers. It's complicated code, should be done by the guys who made the drivers and know their business. You may look here to see if you find any recent changes to the BT driver you are using, maybe they mention fixes or changes and you'd just update the kernel. You're probably using the btusb driver (that's a generic driver made for most chipsets in the wild):

https://github.com/torvalds/linux/commits/master/drivers/bluetooth

@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 9, 2020

Thank you for such a detailed post.

I agree there's probably not much that can be done, I did order one of the Bluetooth dongle you linked so I'll try that out and see how that goes.

I don't have rumble (force feedback?) on at any point so I don't think it's related? Or maybe rumble is something different and I'm not understanding?

I figure Linux and Bluetooth and even just modern technology is so finnicky in general it's amazing any of this stuff works. lol

I'm not too upset about this, just wanted to see if there's anything that can be done about it, and there probably isn't which is okay. I'm not using a controller for anything that demands 100% performance no disconnects ever so it's fine if disconnects happen like once or twice a gaming session.

I'm more concerned about the regression with #57 but I know you already have a great fix in mind for that :)

@kakra
Copy link
Collaborator

kakra commented May 9, 2020

Rumble is a subset of the force feedback support baked into the kernel: Rumble is just spinning weights with motors (as you'd find in your gamepad) while force feedback allows for much more: You could pull with a force against the user input (like for driving wheels or the good old force feedback joysticks that would apply a force against your joystick movements). Gamepads don't have anything like that, they just have their rumbling motors, usually a strong one and a weak one. And Xbox One S and later have two more: One per each trigger to rumble that trigger. None of these motors applies any force against your inputs, they just shake your hands and fingers. ;-)

And yes, looking at the btusb driver and seeing how many different chipsets (even from vastly different brands) it supports with a single codebase is amazing and scary at the same time. ;-) In the end, the chipsets seem to be very similar in how you program them, with a few minor differences and a lot of quirks. These quirks are probably the problem here.

If you don't use rumble at all, you should be able to run the controller just fine on a rock solid connection with the correct (unquirky) dongle. I could play for 10+ hours without disconnects and rumble on after swapping my dongle for a new one, about 3m away from the dongle (or 10 feet, not sure from where you are). My new dongle just requires me to manually click "connect" in the desktop Bluetooth connection applet even though I trusted the Xbox controller for auto-connects. It's a low price to pay for having a stable connection throughout the game session.

Actually, the rumble protocol is quite light-weight: It sends one small packet (64 bits) every 50ms at most, your inputs to the controller create a vast amount more traffic. So rumble is something that hardly requires 100% performance. I've documented that in https://github.com/atar-axis/xpadneo/blob/master/docs/reports/xb1s_battery_event.md and https://github.com/atar-axis/xpadneo/blob/master/docs/descriptors/xb1s_linux.md.

@ipkpjersi
Copy link
Contributor Author

ipkpjersi commented May 20, 2020

So I tested this more with the new adapter you recommended and sadly it does still happen, I had it happen twice more (0 times yesterday, twice today).

I think it might be related to me being on an older (LTS) kernel: Linux 4.15.0-101-generic x86_64

I could possibly install a newer Linux 5-based kernel but I'm not too fussed about it. It's not that big of an issue. Just out of curiosity, what kernel are you running with that adapter?

@kakra
Copy link
Collaborator

kakra commented May 20, 2020

I'm running the 5.4 LTS series kernel with an additional patch for the Bluetooth connection:
https://github.com/kakra/linux/commits/rebase-5.4/xpadneo

The Bluetooth patch of interest is kakra/linux@c8b24d8, there's also some more patches to exclude xpadneo devices from hid-microsoft, so I don't have to unbind the device with udev rules.

@ipkpjersi
Copy link
Contributor Author

Ah, that (probably) makes more sense why you are having a better Bluetooth experience than me lol

Thanks for letting me know, I might look into that kernel some time.

@kakra
Copy link
Collaborator

kakra commented May 20, 2020

@ipkpjersi Would be interesting to see if that patch makes any difference for you. Which distribution are you using? It may be relatively easily possible to slipstream the patch into your kernel package. For Gentoo, it's as easy as putting the patch in /etc/portage/patches/sys-kernel/gentoo-sources and re-emerging the kernel. For other distributions, you usually need to add the deb-src repository and install the kernel source package (or for rpm installing the source package), then go to the source directory, put the patch there and add it to the build script, then rebuild the package and install it.

@kakra
Copy link
Collaborator

kakra commented May 22, 2020

Maybe related to #189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants