unix: add HIDRAW ioctls

This change adds (most) of the ioctl API for the Linux HIDRAW interface.
Reading and writing non-numbered HID reports is done using the read and
write system calls respectively.

Some of the HIDIOC* request numbers are exported directly while others
are kept unexported. This is because some of the #defines require a len
attribute that doesn't have a specific well defined value.

Wrapper types are added for most of the request numbers as is standard.
No wrapper is added for HIDIOCGRDESCSIZE as it would just be
IoctlGetUint32.

The HIDIOC[GS]FEATURE, HIDIOC[GS]INPUT and HIDIOC[GS]OUTPUT request
numbers, which are required for numbered HID reports, are entirely
ommitted as the len attribute has to be a runtime variable. These could
be added later by doing something like
 `HIDIOCGFEATURE(0) | (len << _IOC_SIZESHIFT)`,
with care taken that len doesn't overflow _IOC_XSIZEMASK.

Outdated documentation for the HIDRAW interface is available at:
https://www.kernel.org/doc/Documentation/hid/hidraw.txt.

Change-Id: I2ae5060f0f46150f6fb52959c2e55f50927c1f69
Reviewed-on: https://go-review.googlesource.com/c/sys/+/289169
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
18 files changed
tree: 8fd3f38e042b3b2b048012dc7cb40f1ba330ec74
  1. cpu/
  2. execabs/
  3. internal/
  4. plan9/
  5. unix/
  6. windows/
  7. .gitattributes
  8. .gitignore
  9. AUTHORS
  10. codereview.cfg
  11. CONTRIBUTING.md
  12. CONTRIBUTORS
  13. go.mod
  14. LICENSE
  15. PATENTS
  16. README.md
README.md

sys

Go Reference

This repository holds supplemental Go packages for low-level interactions with the operating system.

Download/Install

The easiest way to install is to run go get -u golang.org/x/sys. You can also manually git clone the repository to $GOPATH/src/golang.org/x/sys.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the sys repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/sys:” in the subject line, so it is easy to find.