Closed
Bug 680326
Opened 13 years ago
Closed 7 years ago
Add XPCOM observers for device connection/disconnection
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: kael, Unassigned)
References
Details
Attachments
(1 file, 2 obsolete files)
(deleted),
patch
|
jimm
:
review-
|
Details | Diff | Splinter Review |
Device connection/disconnection notifications from the operating system (WM_DEVICECHANGE on windows) should be exposed as XPCOM observer events, so that subsystems (like the Joystick API and WebUSB) can respond to them by intelligently rescanning the available devices.
Reporter | ||
Comment 1•13 years ago
|
||
This patch should add the necessary observer notifications. Not sure how to write a test. Still trying to get it working with the current Joystick API patches.
Comment 2•13 years ago
|
||
We discussed this on IRC, but for posterity:
I tested this patch, and plugging/unplugging any of my game controllers doesn't produce any notifications. With some printf debugging, I found that I only get DBT_DEVNODES_CHANGED messages, not DBT_DEVICEARRIVAL / DBT_DEVICEREMOVECOMPLETE.
Keywords: dev-doc-needed
Reporter | ||
Comment 3•13 years ago
|
||
Updated to respond to DBT_DEVNODES_CHANGED as well since there are cases (like syncing a wireless XBox 360 controller) that don't produce the normal attached/removed notifications.
Also replaced the two different observer notifications with a single 'devices-changed' notification.
Attachment #554958 -
Attachment is obsolete: true
Comment 4•13 years ago
|
||
I integrated support for this into my patches in bug 604039, and it works great. We'll have to work on getting this landed!
Comment 5•13 years ago
|
||
I emailed Kevin, and he's not working on this anymore. This patch updates his fix to work after bug 503879 removed the window messaging from nsToolkit.cpp, and moved it to nsWindow.cpp.
Assignee: kevin.gadd → jon
Attachment #563893 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #579755 -
Flags: review?(ted.mielczarek)
Comment 6•13 years ago
|
||
Comment on attachment 579755 [details] [diff] [review]
Updated after bug 503879 was landed
Sorry, I should have redirected this earlier. I'm not a Windows widget peer, so I'll redirect this to jimm.
Attachment #579755 -
Flags: review?(ted.mielczarek) → review?(jmathies)
Comment 7•13 years ago
|
||
Comment on attachment 579755 [details] [diff] [review]
Updated after bug 503879 was landed
> + const uint DBT_DEVICEARRIVAL = 0x8000;
> + const uint DBT_DEVICEREMOVECOMPLETE = 0x8004;
> + const uint DBT_DEVNODES_CHANGED = 0x7;
There's no need for this, just include <dbt.h>
> @@ -4641,16 +4641,37 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam, ..
> case WM_DEVICECHANGE:
By placing this in our main window procedure, which is used by every window we create, this observer event will fire multiple time on the same device state change. With two windows open I counted a total of seven DBT_DEVICEARRIVAL events for one usb stick being plugged in.
I'd suggest you either tie this to a unique window (the hidden message window managed by nsAppShell.cpp would probably do) or do something similar to what we do for WM_POWERBROADCAST events where we track the current state and only only fire the observer when necessary. Not sure how to handle that for multiple devices though, so going with the message window might be the simplest approach.
Attachment #579755 -
Flags: review?(jmathies) → review-
Comment 8•13 years ago
|
||
Hm. The original version of this patch (in attachment 563893 [details] [diff] [review]), was using nsToolkit::WindowProc, but apparently that got removed as part of bug 503879.
Comment 9•13 years ago
|
||
Neil: since you removed the code that this patch originally touched, could you offer a suggestion as to what we should do to update this patch?
Updated•12 years ago
|
Assignee: jon → nobody
Status: ASSIGNED → NEW
Comment 10•7 years ago
|
||
This isn't really valid for gecko's device handling anymore. Marking incomplete.
Status: NEW → RESOLVED
Closed: 7 years ago
Component: General → DOM: Device Interfaces
Resolution: --- → INCOMPLETE
Updated•7 years ago
|
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•