History log of /haiku/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp
Revision Date Author Comments
# 4f18dc04 31-Oct-2022 Zelenoviy <zelenoviy@gmail.com>

usb_hid: Fix MaxReportSize computation

While calculating buffer size for IN reports, only "Input" report type
should been taken in account. Complex HID devices, such as "Gaming"
keyboards and mice, often have "Feature"-reports declared (with size way
bigger than "typical" kbd IN report) for vendor-specific device
configurations.

But "Feature"-reports are sent over control channel only and can't
appear on interrupt channel.

Should fix #14919, #17937, #17699

Change-Id: I4b9eb51938ca4aba2bc34247d00ae164eb2c19fc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5771
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# d98fcb7d 03-May-2022 Augustin Cavalier <waddlesplash@gmail.com>

HID: Return ENODEV instead of B_ERROR if the device was removed.

This should help with diagnosing problems in some failure conditions.


# 2b4bf3ee 04-Apr-2020 Jérôme Duval <jerome.duval@gmail.com>

i2c_hid: driver for i2c-hid devices

This is getting more common in tablets and laptops. It replaces PS/2 for
the internal keyboard and pointing devices. This is simpler and cheaper
than using up USB ports, and also simpler than the old and quirky PS/2
protocol.

The HID spec is the same no matter what transport is used (it is also
applicable for Bluetooth). Ideally we could create a separate HID bus
manager that would handle all these devices in a generic way, but that
is a lot of work nad extra complications for uncertain gains.

For now, just move the common files to a shared directory where both
drivers can use them. As a result the files are compiled twice, which is
what we want, because currently they hardcode some device paths that
need to be different for each driver.

Change-Id: I0327f6864dd0a4372b708f7b7ecf299aa86a6ea9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2466
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 1e0d4ffa 06-Apr-2020 Jérôme Duval <jerome.duval@gmail.com>

usb_hid: fix trace build, use a macro for device path suffix

no functional change

Change-Id: If8a147727214c8d40853058c033d241c284eec84
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2462
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 0034a3c5 23-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

usb_hid: 80 character limit cleanup.


# 25f723de 22-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

usb_hid: Let protocol handlers know of their closing.

On close a flag is set in the cookie of this user of a protocol handler
and the device cancels its pending transfer. This wakes up any possible
listeners. When the closed flag is set, an error code is returned from
_ReadReport() which causes the retry loop to be left. Handlers listening
on the same device which were not closed just retry the transfer.

This ensures that closing a device will cause pending control requests
to complete with a sensible error code.


# f1a02a8e 15-Mar-2015 Ithamar R. Adema <ithamar@upgrade-android.com>

usb_hid: fix STALL handling

It is not allowed to do synchronous calls to the usb bus manager
while in a usb callback routine. This causes the usb stack to get
very confused.

This code now uses the async interface to clear the STALL, and will
try to continue normal operations after that request has been handled.

Fix sponsered by http://www.izcorp.com


# 077c84eb 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 7e5b39b6 18-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix printf format warnings that were missed earlier (CIDs 715645-715657).


# f13be492 04-Jan-2012 Michael Lotz <mmlr@mlotz.ch>

Pad the transfer buffer to prevent out of bounds access.

The HIDReportItem reads 32 bit chunks from the report buffer. To avoid
having to check the remaining buffer space on each extraction, we pad
the buffer so it is always valid to read 32 bits at a time. Also add
a comment explaining why we do it that way.

Thanks to Johannes Anderwald for pointing out the potential out of
bound access!


# 7802e2dd 07-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Get the HID descriptor from the already retrieved configuration info instead of
always calling the device and requesting it. If no HID descriptor is found in
the configuration we fall back to retrieving it manually and if that fails we
fall back to a dummy report descriptor length. In the most usual case this will
save one unnecessary USB control request.

Incidentally this also fixes the absolute pointing device under VirtualBox. VBox
stalled the retrieval of the HID descriptor. That alone wasn't so problematic as
in this case we just fell back to the dummy report descriptor length which
would've been large enough. But VBox also times out the next request after the
stall, which in this case was the retrieval of the report descriptor, hence no
HIDDevice could be created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42019 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ca60b96 06-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Move the quirky device detection out of the HIDDevice constructor and into the
usb_hid_device_added hook so that we can actually detect non-HID devices at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3260cdb 04-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Reimplement the descriptor patching mechanism for quirky devices by a function
to build a new descriptor using a HIDWriter. This way a completely new
descriptor can be built on the fly or a fixed already patched blob can be
written to the writer if desired.
* Implemented writing a new report descriptor for Sony SIXAXIS controllers. The
descriptor also includes the pressure sensitive button states (exposed as 12
axes) and the accelerometers/gyroscope (exposed as another 4 axes). While the
motion sensing data is now available (and fun to look at), the usefulness is
fairly limited, as the values are not scaled/transformed in any way. It might
be possible to generically do such transformations using unit descriptions,
but those are not implemented yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e53f9a9 03-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Make the quirky device mechanism a bit more useful by allowing an init
function that is triggered before the protocol handlers are added.
* Use the quirky device mechanism to support the Sony SIXAXIS controller (the
PS3 one). It requires a specific get_report to become operational. Note that
you still have to push the PS button to enable it after plugging in. Note also
that only the two analog sticks are reported as axis, the analog values of the
buttons as well as the motion sensors aren't described by the HID descriptor
and therefore aren't accessible. The digital button states (on/off only) work
however. A fixed descriptor could possibly be crafted to support the missing
features later on though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41902 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 305aff3f 28-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Changed the way how devices are enumerated and protocol handlers are added to
handle the different device classes. Handlers are now added based on the
application collections that the HID descriptor describes instead of by
enumerating the different report items inside the reports. This means that a
device is now logically treated as a mouse when it comes with an application
collection that designates it as a mouse, instead of when there is a report
that contains an X and a Y axis. This resolves the conflicts that gamepads
and joysticks were added as mice due to them containing such elements. This
therefore fixes #4499 and opens up the way to properly handle other device
types like joysticks (#7429), gamepads, tablets (#7354, #5989 and #7481) and
so on. I'll work on gamepads/joysticks next and see where we stand for tablets
later.
* Added a few enumeration functions to HIDCollection to support the above.
* Fix the root collection handling. A device doesn't describe a single root
collection and then adds everything as a child. Instead it just has multiple
collections on level 0. We account for that now by always creating an empty
logical collection as the root collection where all the collections of the
descriptor get added.
* Rename the {Mouse|Keyboard}Device.{cpp|h} to
{Mouse|Keyboard}ProtocolHandler.{cpp|h} as that more clearly describes their
purpose. These classes are protocol handlers, i.e. they handle the ioctl based
mouse and keyboard protocol between the driver and the input_server add-ons.
* Change a lot of stuff to use references instead of pointers where it makes
sense (not necessarily complete yet).

I've tested this successfully on a keyboard with extended keys, a combo device
with a keyboard with extended keys and a mouse, a mouse and a gamepad (that now
doesn't do anything anymore) and found no regressions. However, since there are
a lot of very varied ways how to describe such functions with HID, it's not too
unlikely that some more curiously described devices will now stop working. These
have to be handled case by case and their usages have to be added to the added
to the appropriate handlers (or new handlers have to be written). Please test
and create bug reports (preferrably including the report descriptor that is
written out to /tmp).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6339610f 17-Mar-2011 Michael Lotz <mmlr@mlotz.ch>

Add a way to override report descriptors with fixed ones based on vendor and
product id. Currently the list only has an example entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6ec842d 16-Dec-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by x-ist from ticket #6115:
* A lot of HID definitions got extracted from USB_hid.h into their
own files. Many more definitions have been added from the specs.
* The names have been moved into the proper B_* namspace.
* The USB hid driver has been adapted for the changes.

Thanks a lot and sorry for the delay!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39874 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 447b0afd 15-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Use const where appropriate.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48450caa 14-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Prepared driver for the implementation of the debugger mode: there is now a
uint32 cookie that is saved per file handle and passed to the ProtocolHandler
objects.
* Beware that the output of the driver no longer shows the handler as pointer,
but the internal device cookie.
* Added handling of KB_SET_DEBUG_READER to the KeyboardDevice class (it just
doesn't do anything with that).
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36274 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e65227c2 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

* Error out on the num events ioctl in case the device was removed, otherwise
the original BeOS input_server will fail to detect the error and never close
the device.
* Remove the empty kernel_cpp header and use the one from kernel util instead.
* Add some missing headers for completeness.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55ae6131 26-Jul-2009 Michael Lotz <mmlr@mlotz.ch>

Add disabled debug-helper to dump all reports of a device.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31793 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e1857f7 26-Jul-2009 Michael Lotz <mmlr@mlotz.ch>

* Completely rework the USB HID driver to make use of the HID framework
introduced earlier.
* Reworked the previous device classes to make them ProtocolHandlers handling
their respective input_server <-> driver protocol.
* Implement setting report item data and building/sending reports based on that.
* Remove the old HID parsing code.

This enables us to use all HID devices as we now parse and use the HID
descriptors/reports. Non-boot-porotocol devices should therefore work.

The next step will be to implement a generic input/output framework in userland
that can communicate with a generic protocol handler in usb_hid. This will then
enable applications to make use of all the non-mapped HID stuff directly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31790 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d42ec70 29-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Several problems prevented USB HIDs to be opened, closed and reopened:
* The first problem was introduced by myself, when I added deleting the
transfer semaphore in HIDDevice::Close(). Obviously, I should (re)create it
in Open() then, or it won't work another time. (Open() is now the only place
where it's created.)
* The second problem was when transfers have already been scheduled the
last time the device was open, but never triggered yet. We need to reset the
fTransferUnprocessed flag, or we won't schedule another transfer but
wait on the transfer semaphore anyways in Control(). I also added
canceling the usb transfers with the stack in Close().
* The remaining problems were specific to the KeyboardDevice, the repeat
key stuff needs to be reset in Open(). I also added unsetting the repeat
key when the key release is detected, but this should have already worked,
because the semaphore timeout was reset to B_INFINITE_TIMEOUT.

One can now "/system/servers/input_server -q" and everything will be back
in working order. There may be some remaining problems in the Wacom driver
which I have not yet looked at.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28368 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dab68c33 27-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

* When a device closes, delete the transfer semaphore, so that threads blocking
on it are unblocked and get an error.
* Make fOpen volatile to prevent unwanted caching effects when checking it from
different threads. (?)
* Check IsOpen() in the KeyboardDevice class in more acquire_sem_etc() return
cases, analogous to the MouseDevice class.

I am still getting a problem when relaunching input_server with the input_server
add-on thread that ioctl()s on a USB keyboard fd, which should have never fired
because it's a fake device from a KVM. After the first input_server instance is
gone, this thread keeps on busy looping in acquire_sem_etc()->switch_sem() from
within the ioctl() of the KeyboardDevice usb_hid driver. Still on it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28350 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b57520d4 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Don't leak the decoded instructions in case the device object cannot be
allocated.
* Remove accidentally added debug device id.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27461 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11b9aad7 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Use new(std::nothrow) everywhere (NULL checks were already there).
* Fix a warning if trace output is not enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d9e7cab 05-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Also use the interface index when generating the report descriptor dump.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 32ab216c 25-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Check for the removed case before doing any transfers.
* Cancel possibly active transfers when removed.
* Do not interpret the transfer buffer in case of an error or removal.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e48bf8e 25-May-2008 Michael Lotz <mmlr@mlotz.ch>

Rewriting the usb_hid driver. It has now gotten a driver part and a device part
structured into the HIDDevice base class and KeyboardDevice and MouseDevice
subclasses. This can be extended easily to support more device types like game
controllers, joysticks and other HID devices. The parsing code remains untouched
while the interpretation code has been integrated into the device classes.
The driver should work much the same way as before including the boot protocol
only keyboard limitation. On the other hand composite devices that combine
multiple devices should now work, as long as they expose those devices as two
seperate interfaces.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25657 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0034a3c5153f98452448894ba68a181b62b24afd 23-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

usb_hid: 80 character limit cleanup.


# 25f723de857000d2be110e4be49cde05c2d61eb6 22-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

usb_hid: Let protocol handlers know of their closing.

On close a flag is set in the cookie of this user of a protocol handler
and the device cancels its pending transfer. This wakes up any possible
listeners. When the closed flag is set, an error code is returned from
_ReadReport() which causes the retry loop to be left. Handlers listening
on the same device which were not closed just retry the transfer.

This ensures that closing a device will cause pending control requests
to complete with a sensible error code.


# f1a02a8e1e570ec209443c5ce1dff417d7c7d80b 15-Mar-2015 Ithamar R. Adema <ithamar@upgrade-android.com>

usb_hid: fix STALL handling

It is not allowed to do synchronous calls to the usb bus manager
while in a usb callback routine. This causes the usb stack to get
very confused.

This code now uses the async interface to clear the STALL, and will
try to continue normal operations after that request has been handled.

Fix sponsered by http://www.izcorp.com


# 077c84eb27b25430428d356f3d13afabc0cc0d13 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# 7e5b39b67273ea3a49be51d0af33369f7f1284e4 18-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fix printf format warnings that were missed earlier (CIDs 715645-715657).


# f13be4928b1e32127ce71325fbf50f0e943c0566 04-Jan-2012 Michael Lotz <mmlr@mlotz.ch>

Pad the transfer buffer to prevent out of bounds access.

The HIDReportItem reads 32 bit chunks from the report buffer. To avoid
having to check the remaining buffer space on each extraction, we pad
the buffer so it is always valid to read 32 bits at a time. Also add
a comment explaining why we do it that way.

Thanks to Johannes Anderwald for pointing out the potential out of
bound access!


# 7802e2dd2c98f20abdf6eede5541e48876446c09 07-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Get the HID descriptor from the already retrieved configuration info instead of
always calling the device and requesting it. If no HID descriptor is found in
the configuration we fall back to retrieving it manually and if that fails we
fall back to a dummy report descriptor length. In the most usual case this will
save one unnecessary USB control request.

Incidentally this also fixes the absolute pointing device under VirtualBox. VBox
stalled the retrieval of the HID descriptor. That alone wasn't so problematic as
in this case we just fell back to the dummy report descriptor length which
would've been large enough. But VBox also times out the next request after the
stall, which in this case was the retrieval of the report descriptor, hence no
HIDDevice could be created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42019 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ca60b965f3b0d3aa28092cc2e6529d9d49f8b2d 06-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Move the quirky device detection out of the HIDDevice constructor and into the
usb_hid_device_added hook so that we can actually detect non-HID devices at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42002 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3260cdb5f9ae580205ab3093f93301484b17ce9 04-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Reimplement the descriptor patching mechanism for quirky devices by a function
to build a new descriptor using a HIDWriter. This way a completely new
descriptor can be built on the fly or a fixed already patched blob can be
written to the writer if desired.
* Implemented writing a new report descriptor for Sony SIXAXIS controllers. The
descriptor also includes the pressure sensitive button states (exposed as 12
axes) and the accelerometers/gyroscope (exposed as another 4 axes). While the
motion sensing data is now available (and fun to look at), the usefulness is
fairly limited, as the values are not scaled/transformed in any way. It might
be possible to generically do such transformations using unit descriptions,
but those are not implemented yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e53f9a99099590f263fab95a742ab6160b1b1a8 03-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Make the quirky device mechanism a bit more useful by allowing an init
function that is triggered before the protocol handlers are added.
* Use the quirky device mechanism to support the Sony SIXAXIS controller (the
PS3 one). It requires a specific get_report to become operational. Note that
you still have to push the PS button to enable it after plugging in. Note also
that only the two analog sticks are reported as axis, the analog values of the
buttons as well as the motion sensors aren't described by the HID descriptor
and therefore aren't accessible. The digital button states (on/off only) work
however. A fixed descriptor could possibly be crafted to support the missing
features later on though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41902 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 305aff3f787ca5d2e0e5ef44fe3487ca3fb7adae 28-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Changed the way how devices are enumerated and protocol handlers are added to
handle the different device classes. Handlers are now added based on the
application collections that the HID descriptor describes instead of by
enumerating the different report items inside the reports. This means that a
device is now logically treated as a mouse when it comes with an application
collection that designates it as a mouse, instead of when there is a report
that contains an X and a Y axis. This resolves the conflicts that gamepads
and joysticks were added as mice due to them containing such elements. This
therefore fixes #4499 and opens up the way to properly handle other device
types like joysticks (#7429), gamepads, tablets (#7354, #5989 and #7481) and
so on. I'll work on gamepads/joysticks next and see where we stand for tablets
later.
* Added a few enumeration functions to HIDCollection to support the above.
* Fix the root collection handling. A device doesn't describe a single root
collection and then adds everything as a child. Instead it just has multiple
collections on level 0. We account for that now by always creating an empty
logical collection as the root collection where all the collections of the
descriptor get added.
* Rename the {Mouse|Keyboard}Device.{cpp|h} to
{Mouse|Keyboard}ProtocolHandler.{cpp|h} as that more clearly describes their
purpose. These classes are protocol handlers, i.e. they handle the ioctl based
mouse and keyboard protocol between the driver and the input_server add-ons.
* Change a lot of stuff to use references instead of pointers where it makes
sense (not necessarily complete yet).

I've tested this successfully on a keyboard with extended keys, a combo device
with a keyboard with extended keys and a mouse, a mouse and a gamepad (that now
doesn't do anything anymore) and found no regressions. However, since there are
a lot of very varied ways how to describe such functions with HID, it's not too
unlikely that some more curiously described devices will now stop working. These
have to be handled case by case and their usages have to be added to the added
to the appropriate handlers (or new handlers have to be written). Please test
and create bug reports (preferrably including the report descriptor that is
written out to /tmp).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6339610f44c98bf70526ab1f27a82fd141381518 17-Mar-2011 Michael Lotz <mmlr@mlotz.ch>

Add a way to override report descriptors with fixed ones based on vendor and
product id. Currently the list only has an example entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6ec842de4c268c02649990c58c1f891869ca285 16-Dec-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by x-ist from ticket #6115:
* A lot of HID definitions got extracted from USB_hid.h into their
own files. Many more definitions have been added from the specs.
* The names have been moved into the proper B_* namspace.
* The USB hid driver has been adapted for the changes.

Thanks a lot and sorry for the delay!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39874 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 447b0afd932cfb68b7e93032017b33c61ca03f88 15-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Use const where appropriate.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48450caac5e0de5ada49bb185b24fd6a7f6420bf 14-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Prepared driver for the implementation of the debugger mode: there is now a
uint32 cookie that is saved per file handle and passed to the ProtocolHandler
objects.
* Beware that the output of the driver no longer shows the handler as pointer,
but the internal device cookie.
* Added handling of KB_SET_DEBUG_READER to the KeyboardDevice class (it just
doesn't do anything with that).
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36274 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e65227c272a91f62ab385a51af0e0bc13e53e725 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

* Error out on the num events ioctl in case the device was removed, otherwise
the original BeOS input_server will fail to detect the error and never close
the device.
* Remove the empty kernel_cpp header and use the one from kernel util instead.
* Add some missing headers for completeness.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55ae61312c5282380148abd265a038d1d9b22233 26-Jul-2009 Michael Lotz <mmlr@mlotz.ch>

Add disabled debug-helper to dump all reports of a device.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31793 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e1857f79521285ff4ecf2ab2a258191dd4aa0a8 26-Jul-2009 Michael Lotz <mmlr@mlotz.ch>

* Completely rework the USB HID driver to make use of the HID framework
introduced earlier.
* Reworked the previous device classes to make them ProtocolHandlers handling
their respective input_server <-> driver protocol.
* Implement setting report item data and building/sending reports based on that.
* Remove the old HID parsing code.

This enables us to use all HID devices as we now parse and use the HID
descriptors/reports. Non-boot-porotocol devices should therefore work.

The next step will be to implement a generic input/output framework in userland
that can communicate with a generic protocol handler in usb_hid. This will then
enable applications to make use of all the non-mapped HID stuff directly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31790 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d42ec70c9c66bf40fa1e7e411e1fc7fa72e40a7 29-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Several problems prevented USB HIDs to be opened, closed and reopened:
* The first problem was introduced by myself, when I added deleting the
transfer semaphore in HIDDevice::Close(). Obviously, I should (re)create it
in Open() then, or it won't work another time. (Open() is now the only place
where it's created.)
* The second problem was when transfers have already been scheduled the
last time the device was open, but never triggered yet. We need to reset the
fTransferUnprocessed flag, or we won't schedule another transfer but
wait on the transfer semaphore anyways in Control(). I also added
canceling the usb transfers with the stack in Close().
* The remaining problems were specific to the KeyboardDevice, the repeat
key stuff needs to be reset in Open(). I also added unsetting the repeat
key when the key release is detected, but this should have already worked,
because the semaphore timeout was reset to B_INFINITE_TIMEOUT.

One can now "/system/servers/input_server -q" and everything will be back
in working order. There may be some remaining problems in the Wacom driver
which I have not yet looked at.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28368 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dab68c33ed20488e352cd018d4653ba6c600ef81 27-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

* When a device closes, delete the transfer semaphore, so that threads blocking
on it are unblocked and get an error.
* Make fOpen volatile to prevent unwanted caching effects when checking it from
different threads. (?)
* Check IsOpen() in the KeyboardDevice class in more acquire_sem_etc() return
cases, analogous to the MouseDevice class.

I am still getting a problem when relaunching input_server with the input_server
add-on thread that ioctl()s on a USB keyboard fd, which should have never fired
because it's a fake device from a KVM. After the first input_server instance is
gone, this thread keeps on busy looping in acquire_sem_etc()->switch_sem() from
within the ioctl() of the KeyboardDevice usb_hid driver. Still on it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28350 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b57520d4a9520c7b1ed4d42f7e57697c7b9cdfa3 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Don't leak the decoded instructions in case the device object cannot be
allocated.
* Remove accidentally added debug device id.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27461 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11b9aad7f7f16e9320ea9edc4a353a5ec6c7d588 12-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Use new(std::nothrow) everywhere (NULL checks were already there).
* Fix a warning if trace output is not enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d9e7cab36edb6333d7de8fb16a21281015554b5 05-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Also use the interface index when generating the report descriptor dump.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 32ab216c8559f225626c6388c9c0e1ef26392715 25-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Check for the removed case before doing any transfers.
* Cancel possibly active transfers when removed.
* Do not interpret the transfer buffer in case of an error or removal.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e48bf8e429c4939c2c80cae1b6615b9af5bdda2 25-May-2008 Michael Lotz <mmlr@mlotz.ch>

Rewriting the usb_hid driver. It has now gotten a driver part and a device part
structured into the HIDDevice base class and KeyboardDevice and MouseDevice
subclasses. This can be extended easily to support more device types like game
controllers, joysticks and other HID devices. The parsing code remains untouched
while the interpretation code has been integrated into the device classes.
The driver should work much the same way as before including the boot protocol
only keyboard limitation. On the other hand composite devices that combine
multiple devices should now work, as long as they expose those devices as two
seperate interfaces.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25657 a95241bf-73f2-0310-859d-f6bbb57e9c96