-
Notifications
You must be signed in to change notification settings - Fork 35
No disconnect detection #9
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
Comments
The streamed output of xboxdrv is expected to change whenever a controller loses connectivity. Normally, the output of xboxdrv is a full set of control states for the Xbox 360 controller. When a disconnect occurs, xboxdrv normally detects the change and sends an event string that is unique (it switches to an original Xbox controller layout, rather than the 360 layout). You should be able to see this for yourself by running xboxdrv interactively
While the controller is connected, you'll see state changes streamed to the console, showing a consistent format that includes all of the controls of a 360 controller. If you pop-out the battery from the controller, to force a disconnect, you should see a final event streamed that has a unique format to it. Here is how it appears for me (note how the 'black' and 'white' states appear, which are unique to the original Xbox controller):
If you confirm that xboxdrv is working in this manner on your system, then xbox.py should be able to detect the loss of connection. Running sample.py is a good way to confirm that all is well. If xboxdrv isn't sending a unique event string on disconnect, then xbox.py will not be able to detect the disconnect. I'd be curious to learn what you are seeing. For reference, I was using xboxdrv version 0.8.8 on Ubuntu, for the sample above. I'm also using an original Microsoft USB Xbox receiver. |
Thank you very much for taking the time to reply.
(a wireless version)
|
That is definitely different than I've seen with Microsoft receivers. If xboxdrv doesn't provide some unique output, then xbox.py won't be able to identify a disconnect. There might be a simple workaround for you, I see that your output is showing the Y1 and Y2 axis values registering as -256, while X1 and X2 come through as zeros, which is fairly unique. If the values are always X1: 0 Y1: -256 X2: 0 Y2: -256 whenever the controller is disconnected, you could test for this condition specifically within the 'refresh' method of xbox.py. Currently the block of code for determining connected status looks like this:
Try changing the 'if' statement to:
I can't really test it with my hardware, but you can give it a try. |
Thank you, that is a good solution. I will try it
Στις Δευ, 22 Απρ 2019 στις 11:02 μ.μ., ο/η Steven Jacobs <
[email protected]> έγραψε:
… That is definitely different than I've seen with Microsoft receivers. If
xboxdrv doesn't provide some unique output, then xbox.py won't be able to
identify a disconnect. There might be a simple workaround for you,
I see that your output is showing the Y1 and Y2 axis values registering as
-256, while X1 and X2 come through as zeros, which is fairly unique. If the
values are always X1: 0 Y1: -256 X2: 0 Y2: -256 whenever the controller is
disconnected, you could test for this condition specifically within the
*'refresh'* method of xbox.py. Currently the block of code for
determining connected status looks like this:
# Valid controller response will be 140 chars. if len(response) == 140:
self.connectStatus = True self.reading = response else: #Any other response
means we have lost wireless or controller battery self.connectStatus = False
Try changing the 'if' statement to:
if len(response) == 140 and not response.startswith("X1: 0 Y1: -256 X2: 0
Y2: -256 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0
Y:0 LB:0 RB:0 LT: 0 RT: 0"):
I can't really test it with my hardware, but you can give it a try.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AI3LP7FSFG6KNC2PZIK4MXTPRYKU5ANCNFSM4HEAO3SQ>
.
--
F Sofras
Change of email address: [email protected]
------------------------------
*Frank E. Sofras* MD, PhD, FRCS FEBU
Professor of Urology
*Address*
137 Vas. Sofias Ave.
Athens - 11521
GREECE
Mobile: +30 6944 472 417
Web Page: http://www.urology.edu.gr
|
I am using a wireless controller to control a rover. Despite the fact that the handheld is switched off, the joy.connected attribute is True. Any idea why?
The text was updated successfully, but these errors were encountered: