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

Frequent disconnectsAdded optional EMPTY_PACKET_DISCONNECT build-flag to disable empty-packet-disconnects #185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
BUILD := DEBUG
VERSION := $(shell git describe --tags)

EMPTY_PACKET_DISCONNECT := 1
CONFIG := $(CONFIG) -DEMPTY_PACKET_DISCONNECT=$(EMPTY_PACKET_DISCONNECT)

FLAGS := -Wall -Wpedantic -std=c++11 -MMD -MP
DEBUG_FLAGS := -Og -g -DDEBUG
RELEASE_FLAGS := -O3
DEFINES := -DVERSION=\"$(VERSION)\"
DEFINES := -DVERSION=\"$(VERSION)\" $(CONFIG)

CXXFLAGS += $(FLAGS) $($(BUILD)_FLAGS) $(DEFINES)
LDLIBS += -lpthread -lusb-1.0
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The following Xbox One controllers are currently compatible with the driver:
| 1698 | 2015 | Elite controller | **Working** |
| 1708 | 2016 | Bluetooth connectivity | **Working** |
| 1797 | 2019 | Elite controller series 2 | **Working** |
| 1914 | 2020 | Share button and USB-C | **Untested** |
| 1914 | 2020 | Share button and USB-C | **Working** |

## Releases

Expand Down Expand Up @@ -163,6 +163,15 @@ The controller only remembers the *last* device it was connected to. It will not
Some USB controllers are known to cause issues with xow. Plugging your dongle into a USB port that uses an `ASMedia` controller will lead to problems. Most `Intel` USB controllers work well with xow.
Power management issues can arise when using a USB 3 controller. These can lead to timeouts of the USB communication. The use of a USB hub can mitigate these problems.

### Controller periodically disconnects (when idle)
Some controllers might periodically disconnect due to xow receiving an empty packet (which should not happen for most controllers).
This usually happens when the controller is not receiving any input, but can still happen when being used.
As a result, you can disable the automatic disconnect when building by using the `EMPTY_PACKET_DISCONNECT` flag as shown below:

```
make BUILD=RELEASE EMPTY_PACKET_DISCONNECT=0
```

### Other problems

In case of any other problems, please open an issue with all the relevant details (dongle version, controller version, logs, captures, etc.).
Expand Down
3 changes: 3 additions & 0 deletions dongle/dongle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "dongle.h"
#include "../utils/log.h"
#include "../utils/macros.h"

Dongle::Dongle(
std::unique_ptr<UsbDevice> usbDevice
Expand Down Expand Up @@ -269,7 +270,9 @@ void Dongle::handleBulkData(const Bytes &data)

case EVT_CLIENT_LOST:
// Packet is guaranteed not to be empty
#if IS_PROP_ENABLED(EMPTY_PACKET_DISCONNECT)
handleControllerDisconnect(packet[0]);
#endif
break;
}
}
Expand Down
23 changes: 23 additions & 0 deletions utils/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2019 Medusalix
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

// Define helper macros for property expansion
#define DO_EXPAND(VAL) VAL ## 1
#define GET_VALUE(VAL) DO_EXPAND(VAL)
#define IS_PROP_ENABLED(VAL) GET_VALUE(VAL) != 1