From 1d44892edf51d2b78a17901b1aa49c83bd9a69e0 Mon Sep 17 00:00:00 2001 From: thfr Date: Sat, 23 Jan 2021 05:08:33 +0000 Subject: [PATCH] introduce ujoy(4), a restricted subset of uhid(4) for gamecontrollers. This includes ujoy_hid_is_collection() to work around limitations of hid_is_collection() until this can be combined without fallout. input, testing with 8bitdo controller, and ok brynet@ PS4 controller testing, fix for hid_is_collection, and ok mglocker@ --- etc/MAKEDEV.common | 7 +- etc/etc.alpha/MAKEDEV.md | 3 +- etc/etc.amd64/MAKEDEV.md | 3 +- etc/etc.arm64/MAKEDEV.md | 3 +- etc/etc.armv7/MAKEDEV.md | 3 +- etc/etc.hppa/MAKEDEV.md | 3 +- etc/etc.i386/MAKEDEV.md | 3 +- etc/etc.landisk/MAKEDEV.md | 3 +- etc/etc.loongson/MAKEDEV.md | 3 +- etc/etc.macppc/MAKEDEV.md | 3 +- etc/etc.octeon/MAKEDEV.md | 3 +- etc/etc.powerpc64/MAKEDEV.md | 3 +- etc/etc.sgi/MAKEDEV.md | 3 +- etc/etc.sparc64/MAKEDEV.md | 3 +- share/man/man4/Makefile | 4 +- share/man/man4/uhidev.4 | 6 +- share/man/man4/ujoy.4 | 53 ++++++++++ share/man/man4/usb.4 | 6 +- sys/arch/alpha/alpha/conf.c | 4 +- sys/arch/alpha/conf/GENERIC | 3 +- sys/arch/amd64/amd64/conf.c | 4 +- sys/arch/amd64/conf/GENERIC | 3 +- sys/arch/arm/arm/conf.c | 4 +- sys/arch/arm64/arm64/conf.c | 4 +- sys/arch/arm64/conf/GENERIC | 3 +- sys/arch/armv7/conf/GENERIC | 3 +- sys/arch/hppa/conf/GENERIC | 3 +- sys/arch/hppa/hppa/conf.c | 4 +- sys/arch/i386/conf/GENERIC | 3 +- sys/arch/i386/i386/conf.c | 4 +- sys/arch/landisk/conf/GENERIC | 3 +- sys/arch/landisk/landisk/conf.c | 4 +- sys/arch/loongson/conf/GENERIC | 3 +- sys/arch/loongson/loongson/conf.c | 4 +- sys/arch/macppc/conf/GENERIC | 3 +- sys/arch/macppc/macppc/conf.c | 4 +- sys/arch/octeon/conf/GENERIC | 3 +- sys/arch/octeon/octeon/conf.c | 4 +- sys/arch/powerpc64/conf/GENERIC | 3 +- sys/arch/powerpc64/powerpc64/conf.c | 4 +- sys/arch/sgi/conf/GENERIC-IP27 | 3 +- sys/arch/sgi/conf/GENERIC-IP30 | 3 +- sys/arch/sgi/conf/GENERIC-IP32 | 3 +- sys/arch/sgi/sgi/conf.c | 4 +- sys/arch/sparc64/conf/GENERIC | 3 +- sys/arch/sparc64/sparc64/conf.c | 4 +- sys/dev/usb/files.usb | 9 +- sys/dev/usb/uhid.c | 7 +- sys/dev/usb/uhid.h | 3 +- sys/dev/usb/ujoy.c | 149 ++++++++++++++++++++++++++++ sys/sys/conf.h | 10 +- 51 files changed, 337 insertions(+), 53 deletions(-) create mode 100644 share/man/man4/ujoy.4 create mode 100644 sys/dev/usb/ujoy.c diff --git a/etc/MAKEDEV.common b/etc/MAKEDEV.common index 6399379b4c3..b5ead877837 100644 --- a/etc/MAKEDEV.common +++ b/etc/MAKEDEV.common @@ -1,4 +1,4 @@ -vers(a, {-$OpenBSD: MAKEDEV.common,v 1.111 2020/07/06 06:11:26 dlg Exp $-})dnl +vers(a, {-$OpenBSD: MAKEDEV.common,v 1.112 2021/01/23 05:08:33 thfr Exp $-})dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries dnl @@ -181,6 +181,7 @@ dnl target(usb, usb, 0, 1, 2, 3, 4, 5, 6, 7)dnl target(usb, uhid, 0, 1, 2, 3, 4, 5, 6, 7)dnl twrget(usb, fido, fido)dnl +twrget(usb, ujoy, ujoy)dnl target(usb, ulpt, 0, 1)dnl target(usb, ugen, 0, 1, 2, 3, 4, 5, 6, 7)dnl target(usb, ttyU, 0, 1, 2, 3)dnl @@ -365,6 +366,10 @@ __devitem(fido, fido, fido/* nodes, fido)dnl _mkdev(fido, fido, {-RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0 while [ $n -lt 4 ];do M fido/$n c major_fido_c $n 666;n=Add($n, 1);done MKlist[${#MKlist[*]}]=";chmod 555 fido"-})dnl +__devitem(ujoy, ujoy, ujoy/* nodes, ujoy)dnl +_mkdev(ujoy, ujoy, {-RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 + while [ $n -lt 4 ];do M ujoy/$n c major_ujoy_c $n 444;n=Add($n, 1);done + MKlist[${#MKlist[*]}]=";chmod 555 ujoy"-})dnl __devitem(ulpt, ulpt*, Printer devices)dnl _mcdev({-ulpt-}, ulpt*, {-ulpt-}, {-major_ulpt_c-}, 600)dnl __devitem(ttyU, ttyU*, USB serial ports,ucom)dnl diff --git a/etc/etc.alpha/MAKEDEV.md b/etc/etc.alpha/MAKEDEV.md index 77fe5228989..e5256189393 100644 --- a/etc/etc.alpha/MAKEDEV.md +++ b/etc/etc.alpha/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,alpha)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.76 2020/07/06 06:11:26 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.77 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -56,6 +56,7 @@ _DEV(uall) _DEV(ugen, 48) _DEV(uhid, 46) _DEV(fido, 70) +_DEV(ujoy, 72) _DEV(ulpt, 47) _DEV(usb, 45) _TITLE(spec) diff --git a/etc/etc.amd64/MAKEDEV.md b/etc/etc.amd64/MAKEDEV.md index a544fae131b..3de86d5bc2e 100644 --- a/etc/etc.amd64/MAKEDEV.md +++ b/etc/etc.amd64/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,amd64)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.76 2020/07/06 06:11:26 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.77 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -60,6 +60,7 @@ _DEV(uall) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 98) +_DEV(ujoy, 100) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.arm64/MAKEDEV.md b/etc/etc.arm64/MAKEDEV.md index 44f79ee67fe..bf71fb870c9 100644 --- a/etc/etc.arm64/MAKEDEV.md +++ b/etc/etc.arm64/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,arm64)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.10 2020/07/06 06:11:26 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.11 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -52,6 +52,7 @@ _DEV(uall) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 98) +_DEV(ujoy, 100) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.armv7/MAKEDEV.md b/etc/etc.armv7/MAKEDEV.md index 4cde2c06d56..e4584284ebd 100644 --- a/etc/etc.armv7/MAKEDEV.md +++ b/etc/etc.armv7/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,armv7)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.18 2020/07/06 06:11:26 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.19 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2004 Todd T. Fries @@ -61,6 +61,7 @@ _DEV(uall) _DEV(ugen, 70) _DEV(uhid, 65) _DEV(fido, 106) +_DEV(ujoy, 108) _DEV(ulpt, 66) _DEV(usb, 64) _TITLE(spec) diff --git a/etc/etc.hppa/MAKEDEV.md b/etc/etc.hppa/MAKEDEV.md index 6bf1acec396..f0b0a966571 100644 --- a/etc/etc.hppa/MAKEDEV.md +++ b/etc/etc.hppa/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,hppa)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.65 2020/07/06 06:11:26 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.66 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -54,6 +54,7 @@ _DEV(uall) _DEV(usb, 40) _DEV(uhid, 41) _DEV(fido, 61) +_DEV(ujoy, 63) _DEV(ugen, 42) _DEV(ulpt, 43) _DEV(ttyU, 45) diff --git a/etc/etc.i386/MAKEDEV.md b/etc/etc.i386/MAKEDEV.md index 864aa69c2d3..2189d83ad6c 100644 --- a/etc/etc.i386/MAKEDEV.md +++ b/etc/etc.i386/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,i386)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.91 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.92 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -61,6 +61,7 @@ _DEV(uall) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 98) +_DEV(ujoy, 100) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.landisk/MAKEDEV.md b/etc/etc.landisk/MAKEDEV.md index 169f795b1fe..8c6b074c90c 100644 --- a/etc/etc.landisk/MAKEDEV.md +++ b/etc/etc.landisk/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,landisk)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.48 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.49 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2004 Todd T. Fries @@ -65,6 +65,7 @@ _DEV(uall) _DEV(ugen, 70) _DEV(uhid, 65) _DEV(fido, 106) +_DEV(ujoy, 108) _DEV(ulpt, 66) _DEV(usb, 64) _TITLE(spec) diff --git a/etc/etc.loongson/MAKEDEV.md b/etc/etc.loongson/MAKEDEV.md index fb3996c28ac..7d72161326e 100644 --- a/etc/etc.loongson/MAKEDEV.md +++ b/etc/etc.loongson/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,loongson)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.32 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.33 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -60,6 +60,7 @@ _DEV(uall) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 88) +_DEV(ujoy, 90) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.macppc/MAKEDEV.md b/etc/etc.macppc/MAKEDEV.md index 91ea647a00d..7948c70f063 100644 --- a/etc/etc.macppc/MAKEDEV.md +++ b/etc/etc.macppc/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,macppc)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.75 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.76 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -70,6 +70,7 @@ _DEV(ttyU, 66) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 90) +_DEV(ujoy, 92) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.octeon/MAKEDEV.md b/etc/etc.octeon/MAKEDEV.md index a7b641ac6a0..ab0f7ffc9f6 100644 --- a/etc/etc.octeon/MAKEDEV.md +++ b/etc/etc.octeon/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,octeon)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.19 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.20 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -67,6 +67,7 @@ _DEV(uall) _DEV(usb, 61) _DEV(uhid, 62) _DEV(fido, 76) +_DEV(ujoy, 78) _TITLE(spec) _DEV(au, 44) _DEV(bio, 49) diff --git a/etc/etc.powerpc64/MAKEDEV.md b/etc/etc.powerpc64/MAKEDEV.md index 73d415efcec..12dbee30d85 100644 --- a/etc/etc.powerpc64/MAKEDEV.md +++ b/etc/etc.powerpc64/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,powerpc64)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.6 2020/10/24 21:10:41 kettenis Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.7 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -52,6 +52,7 @@ _DEV(uall) _DEV(ugen, 49) _DEV(uhid, 50) _DEV(fido, 51) +_DEV(ujoy, 94) _DEV(ulpt, 65) _DEV(usb, 48) _TITLE(spec) diff --git a/etc/etc.sgi/MAKEDEV.md b/etc/etc.sgi/MAKEDEV.md index e6ccb80126b..8ab65047b6a 100644 --- a/etc/etc.sgi/MAKEDEV.md +++ b/etc/etc.sgi/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,sgi)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.54 2020/07/06 06:11:27 dlg Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.55 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -69,6 +69,7 @@ _DEV(uall) _DEV(ugen, 63) _DEV(uhid, 62) _DEV(fido, 76) +_DEV(ujoy, 78) _DEV(ulpt, 64) _DEV(usb, 61) _TITLE(spec) diff --git a/etc/etc.sparc64/MAKEDEV.md b/etc/etc.sparc64/MAKEDEV.md index dc0d56bbd68..930f71772ab 100644 --- a/etc/etc.sparc64/MAKEDEV.md +++ b/etc/etc.sparc64/MAKEDEV.md @@ -1,6 +1,6 @@ define(MACHINE,sparc64)dnl vers(__file__, - {-$OpenBSD: MAKEDEV.md,v 1.95 2020/07/22 14:04:37 deraadt Exp $-}, + {-$OpenBSD: MAKEDEV.md,v 1.96 2021/01/23 05:08:33 thfr Exp $-}, etc.MACHINE)dnl dnl dnl Copyright (c) 2001-2006 Todd T. Fries @@ -104,6 +104,7 @@ _DEV(uall) _DEV(ugen, 92) _DEV(uhid, 91) _DEV(fido, 137) +_DEV(ujoy, 139) _DEV(ulpt, 93) _DEV(usb, 90) _TITLE(spec) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 02af7a47a44..70e62135237 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.790 2020/12/06 20:48:12 kettenis Exp $ +# $OpenBSD: Makefile,v 1.791 2021/01/23 05:08:34 thfr Exp $ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \ acpi.4 acpiac.4 acpials.4 acpiasus.4 acpibat.4 \ @@ -84,7 +84,7 @@ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \ ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \ udav.4 udcf.4 udl.4 udp.4 udsbr.4 \ uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uipaq.4 \ - uk.4 ukbd.4 \ + ujoy.4 uk.4 ukbd.4 \ ukphy.4 ulpt.4 umass.4 umb.4 umbg.4 umcs.4 umct.4 umidi.4 umodem.4 \ ums.4 umsm.4 umstc.4 umt.4 unix.4 uonerng.4 uow.4 uoaklux.4 uoakrh.4 \ uoakv.4 upd.4 upgt.4 upl.4 uplcom.4 ural.4 ure.4 url.4 urlphy.4 \ diff --git a/share/man/man4/uhidev.4 b/share/man/man4/uhidev.4 index f0a6776a27b..06911ddef29 100644 --- a/share/man/man4/uhidev.4 +++ b/share/man/man4/uhidev.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: uhidev.4,v 1.12 2020/08/21 19:02:46 mglocker Exp $ +.\" $OpenBSD: uhidev.4,v 1.13 2021/01/23 05:08:34 thfr Exp $ .\" $NetBSD: uhidev.4,v 1.2 2001/12/29 03:06:41 augustss Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 21 2020 $ +.Dd $Mdocdate: January 23 2021 $ .Dt UHIDEV 4 .Os .Sh NAME @@ -40,6 +40,7 @@ .Cd "ucycom* at uhidev?" .Cd "ugold* at uhidev?" .Cd "uhid* at uhidev?" +.Cd "ujoy* at uhidev?" .Cd "ukbd* at uhidev?" .Cd "ums* at uhidev?" .Cd "umstc* at uhidev?" @@ -73,6 +74,7 @@ only dispatches data to them based on the report id. .Xr ucycom 4 , .Xr ugold 4 , .Xr uhid 4 , +.Xr ujoy 4 , .Xr ukbd 4 , .Xr ums 4 , .Xr umstc 4 , diff --git a/share/man/man4/ujoy.4 b/share/man/man4/ujoy.4 new file mode 100644 index 00000000000..f75c7d50db8 --- /dev/null +++ b/share/man/man4/ujoy.4 @@ -0,0 +1,53 @@ +.\" $OpenBSD: ujoy.4,v 1.1 2021/01/23 05:08:34 thfr Exp $ +.\" +.\" Copyright (c) 2020 Thomas Frohwein +.\" Copyright (c) 2020 Bryan Steele +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: January 23 2021 $ +.Dt UJOY 4 +.Os +.Sh NAME +.Nm ujoy +.Nd USB joystick/gamecontroller +.Sh SYNOPSIS +.Cd "ujoy* at uhidev?" +.Sh DESCRIPTION +The +.Nm +driver provides support for USB joysticks and other gamecontrollers. +They are Human Interface Devices (HID) which can be accessed via the +.Pa /dev/ujoy/N +interface. +.Pp +The driver is compatible with the +.Xr read 2 , +and a subset of +.Xr ioctl 2 +operations of the generic +.Xr uhid 4 +device. +.Sh FILES +.Bl -tag -width /dev/ujoy/* -compact +.It Pa /dev/ujoy/* +.El +.Sh SEE ALSO +.Xr uhid 4 , +.Xr uhidev 4 , +.Xr usb 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 6.9 . diff --git a/share/man/man4/usb.4 b/share/man/man4/usb.4 index 520f46265e0..8b9e3ffdc3c 100644 --- a/share/man/man4/usb.4 +++ b/share/man/man4/usb.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: usb.4,v 1.203 2020/08/21 20:38:56 mglocker Exp $ +.\" $OpenBSD: usb.4,v 1.204 2021/01/23 05:08:34 thfr Exp $ .\" $NetBSD: usb.4,v 1.15 1999/07/29 14:20:32 augustss Exp $ .\" .\" Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 21 2020 $ +.Dd $Mdocdate: January 23 2021 $ .Dt USB 4 .Os .Sh NAME @@ -255,6 +255,8 @@ TEMPer gold HID thermometer and hygrometer Generic driver for Human Interface Devices .It Xr uhidev 4 Base driver for all Human Interface Devices +.It Xr ujoy 4 +USB joysticks/gamecontrollers .It Xr ukbd 4 USB keyboards that follow the boot protocol .It Xr ums 4 diff --git a/sys/arch/alpha/alpha/conf.c b/sys/arch/alpha/alpha/conf.c index ff6a835c8de..d3f2667e1ab 100644 --- a/sys/arch/alpha/alpha/conf.c +++ b/sys/arch/alpha/alpha/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.88 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.89 2021/01/23 05:08:34 thfr Exp $ */ /* $NetBSD: conf.c,v 1.16 1996/10/18 21:26:57 cgd Exp $ */ /*- @@ -113,6 +113,7 @@ cdev_decl(cy); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -207,6 +208,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 69: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 70: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 71: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 72: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC index 48648e98e41..05953f8e7cb 100644 --- a/sys/arch/alpha/conf/GENERIC +++ b/sys/arch/alpha/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.266 2020/05/23 06:28:29 jsg Exp $ +# $OpenBSD: GENERIC,v 1.267 2021/01/23 05:08:34 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -107,6 +107,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet #atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/amd64/amd64/conf.c b/sys/arch/amd64/amd64/conf.c index b8f9fa911eb..3005c0b8a3b 100644 --- a/sys/arch/amd64/amd64/conf.c +++ b/sys/arch/amd64/amd64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.72 2020/10/07 13:37:33 jan Exp $ */ +/* $OpenBSD: conf.c,v 1.73 2021/01/23 05:08:34 thfr Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -139,6 +139,7 @@ cdev_decl(cy); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -288,6 +289,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 97: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 98: FIDO/U2F security keys */ cdev_pppx_init(NPPPX,pppac), /* 99: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 100: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 45b3a9b6e66..ffa1b4a497c 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.495 2020/11/15 16:47:12 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.496 2021/01/23 05:08:34 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -286,6 +286,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors umstc* at uhidev? # Microsoft Surface Type Cover aue* at uhub? # ADMtek AN986 Pegasus Ethernet diff --git a/sys/arch/arm/arm/conf.c b/sys/arch/arm/arm/conf.c index 3821d526cc6..747c42aed4a 100644 --- a/sys/arch/arm/arm/conf.c +++ b/sys/arch/arm/arm/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.55 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.56 2021/01/23 05:08:34 thfr Exp $ */ /* $NetBSD: conf.c,v 1.10 2002/04/19 01:04:38 wiz Exp $ */ /* @@ -126,6 +126,7 @@ cdev_decl(pci); #include "ugen.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ulpt.h" /* @@ -383,6 +384,7 @@ struct cdevsw cdevsw[] = { cdev_switch_init(NSWITCH,switch), /* 105: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 106: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 107: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 108: USB joystick/gamecontroller */ }; int nblkdev = nitems(bdevsw); diff --git a/sys/arch/arm64/arm64/conf.c b/sys/arch/arm64/arm64/conf.c index d6bf29bbab9..2f3504b9d12 100644 --- a/sys/arch/arm64/arm64/conf.c +++ b/sys/arch/arm64/arm64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.16 2020/10/07 13:37:32 jan Exp $ */ +/* $OpenBSD: conf.c,v 1.17 2021/01/23 05:08:34 thfr Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -110,6 +110,7 @@ cdev_decl(spkr); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -248,6 +249,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 97: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 98: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 99: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 100: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index f6f45a23aa7..adefc8ffea9 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.183 2021/01/19 19:14:39 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.184 2021/01/23 05:08:34 thfr Exp $ # # GENERIC machine description file # @@ -369,6 +369,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index d440ffd902b..13124411dc1 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.132 2020/06/23 13:57:05 fcambus Exp $ +# $OpenBSD: GENERIC,v 1.133 2021/01/23 05:08:34 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -321,6 +321,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/hppa/conf/GENERIC b/sys/arch/hppa/conf/GENERIC index d1fb312f04c..d95e5a8977b 100644 --- a/sys/arch/hppa/conf/GENERIC +++ b/sys/arch/hppa/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.180 2019/12/17 13:08:55 reyk Exp $ +# $OpenBSD: GENERIC,v 1.181 2021/01/23 05:08:34 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -111,6 +111,7 @@ ukbd* at uhidev? # USB keyboard wskbd* at ukbd? mux 1 uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet url* at uhub? # Realtek RTL8150L based adapters diff --git a/sys/arch/hppa/hppa/conf.c b/sys/arch/hppa/hppa/conf.c index ddf72299e9c..4d7a12bac26 100644 --- a/sys/arch/hppa/hppa/conf.c +++ b/sys/arch/hppa/hppa/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.70 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.71 2021/01/23 05:08:35 thfr Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -114,6 +114,7 @@ cdev_decl(pci); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -191,6 +192,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 60: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 61: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 62: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 63: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 8b54e5d0f62..c167a2f8011 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.853 2020/09/12 15:01:05 mglocker Exp $ +# $OpenBSD: GENERIC,v 1.854 2021/01/23 05:08:35 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -284,6 +284,7 @@ uticom* at uhub? # TI serial ucom* at uticom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c index 6912d9cc781..788792c4fa2 100644 --- a/sys/arch/i386/i386/conf.c +++ b/sys/arch/i386/i386/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.170 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.171 2021/01/23 05:08:35 thfr Exp $ */ /* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */ /* @@ -140,6 +140,7 @@ cdev_decl(cy); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -288,6 +289,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 97: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 98: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 99: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 100: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/landisk/conf/GENERIC b/sys/arch/landisk/conf/GENERIC index 0c59680830a..120aa0a108d 100644 --- a/sys/arch/landisk/conf/GENERIC +++ b/sys/arch/landisk/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.55 2019/12/17 13:08:55 reyk Exp $ +# $OpenBSD: GENERIC,v 1.56 2021/01/23 05:08:35 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -137,6 +137,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/landisk/landisk/conf.c b/sys/arch/landisk/landisk/conf.c index b23ef6f4b6b..45cfbd31e32 100644 --- a/sys/arch/landisk/landisk/conf.c +++ b/sys/arch/landisk/landisk/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.42 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.43 2021/01/23 05:08:35 thfr Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -116,6 +116,7 @@ cdev_decl(pci); #include "ugen.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ulpt.h" /* @@ -357,6 +358,7 @@ struct cdevsw cdevsw[] = { cdev_switch_init(NSWITCH,switch), /* 105: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 106: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 107: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 108: USB joystick/gamecontroller */ }; int nblkdev = nitems(bdevsw); diff --git a/sys/arch/loongson/conf/GENERIC b/sys/arch/loongson/conf/GENERIC index d8a84c570b8..4e8d826142b 100644 --- a/sys/arch/loongson/conf/GENERIC +++ b/sys/arch/loongson/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.62 2020/09/30 22:23:41 patrick Exp $ +# $OpenBSD: GENERIC,v 1.63 2021/01/23 05:08:35 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -164,6 +164,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors atu* at uhub? # Atmel AT76c50x based 802.11b aue* at uhub? # ADMtek AN986 Pegasus Ethernet diff --git a/sys/arch/loongson/loongson/conf.c b/sys/arch/loongson/loongson/conf.c index 7ea9243382e..0520e67cac1 100644 --- a/sys/arch/loongson/loongson/conf.c +++ b/sys/arch/loongson/loongson/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.29 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.30 2021/01/23 05:08:35 thfr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -123,6 +123,7 @@ cdev_decl(pci); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -228,6 +229,7 @@ struct cdevsw cdevsw[] = cdev_drm_init(NDRM,drm), /* 87: drm */ cdev_fido_init(NFIDO,fido), /* 88: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 89: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 90: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/macppc/conf/GENERIC b/sys/arch/macppc/conf/GENERIC index 7f33c756d24..46cd7397286 100644 --- a/sys/arch/macppc/conf/GENERIC +++ b/sys/arch/macppc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.271 2020/01/24 04:44:14 krw Exp $g +# $OpenBSD: GENERIC,v 1.272 2021/01/23 05:08:35 thfr Exp $g # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -260,6 +260,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/macppc/macppc/conf.c b/sys/arch/macppc/macppc/conf.c index a7c0ef70971..6a67a394fe4 100644 --- a/sys/arch/macppc/macppc/conf.c +++ b/sys/arch/macppc/macppc/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.72 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.73 2021/01/23 05:08:35 thfr Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -98,6 +98,7 @@ cdev_decl(com); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -231,6 +232,7 @@ struct cdevsw cdevsw[] = { cdev_switch_init(NSWITCH,switch), /* 89: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 90: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 91: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 92: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/octeon/conf/GENERIC b/sys/arch/octeon/conf/GENERIC index 63142e6667c..e5f407d7e9a 100644 --- a/sys/arch/octeon/conf/GENERIC +++ b/sys/arch/octeon/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.56 2020/10/25 10:33:31 visa Exp $ +# $OpenBSD: GENERIC,v 1.57 2021/01/23 05:08:36 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -156,6 +156,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/octeon/octeon/conf.c b/sys/arch/octeon/octeon/conf.c index 51608cb7e32..b8a40b0ea08 100644 --- a/sys/arch/octeon/octeon/conf.c +++ b/sys/arch/octeon/octeon/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.25 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.26 2021/01/23 05:08:36 thfr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -136,6 +136,7 @@ cdev_decl(pci); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -235,6 +236,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 75: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 76: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 77: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 78: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/powerpc64/conf/GENERIC b/sys/arch/powerpc64/conf/GENERIC index d874b1e308a..75e26260d84 100644 --- a/sys/arch/powerpc64/conf/GENERIC +++ b/sys/arch/powerpc64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.22 2020/11/16 19:04:57 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.23 2021/01/23 05:08:36 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -126,6 +126,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors umstc* at uhidev? # Microsoft Surface Type Cover aue* at uhub? # ADMtek AN986 Pegasus Ethernet diff --git a/sys/arch/powerpc64/powerpc64/conf.c b/sys/arch/powerpc64/powerpc64/conf.c index 060e7501cd1..4f6b805b142 100644 --- a/sys/arch/powerpc64/powerpc64/conf.c +++ b/sys/arch/powerpc64/powerpc64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.10 2020/10/24 21:06:56 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.11 2021/01/23 05:08:36 thfr Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -64,6 +64,7 @@ cdev_decl(com); #include "drm.h" #include "dt.h" #include "fido.h" +#include "ujoy.h" #include "fuse.h" #include "hotplug.h" #include "ipmi.h" @@ -203,6 +204,7 @@ struct cdevsw cdevsw[] = #else cdev_notdef(), /* 93 */ #endif + cdev_ujoy_init(NUJOY,ujoy), /* 94: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/sgi/conf/GENERIC-IP27 b/sys/arch/sgi/conf/GENERIC-IP27 index af6d1b4f057..889a921dd8f 100644 --- a/sys/arch/sgi/conf/GENERIC-IP27 +++ b/sys/arch/sgi/conf/GENERIC-IP27 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC-IP27,v 1.66 2019/12/17 13:08:56 reyk Exp $ +# $OpenBSD: GENERIC-IP27,v 1.67 2021/01/23 05:08:36 thfr Exp $ # # THIS KERNEL IS FOR Origin, Onyx, Fuel, Tezro (IP27, IP35) SYSTEMS ONLY. # @@ -128,6 +128,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support atu* at uhub? # Atmel AT76c50x based 802.11b aue* at uhub? # ADMtek AN986 Pegasus Ethernet axe* at uhub? # ASIX Electronics AX88172 USB Ethernet diff --git a/sys/arch/sgi/conf/GENERIC-IP30 b/sys/arch/sgi/conf/GENERIC-IP30 index 071d7babf95..bd90d34945b 100644 --- a/sys/arch/sgi/conf/GENERIC-IP30 +++ b/sys/arch/sgi/conf/GENERIC-IP30 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC-IP30,v 1.59 2019/12/17 13:08:56 reyk Exp $ +# $OpenBSD: GENERIC-IP30,v 1.60 2021/01/23 05:08:36 thfr Exp $ # # THIS KERNEL IS FOR Octane and Octane 2 (IP30) SYSTEMS ONLY. # @@ -119,6 +119,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support atu* at uhub? # Atmel AT76c50x based 802.11b aue* at uhub? # ADMtek AN986 Pegasus Ethernet axe* at uhub? # ASIX Electronics AX88172 USB Ethernet diff --git a/sys/arch/sgi/conf/GENERIC-IP32 b/sys/arch/sgi/conf/GENERIC-IP32 index 4595a4eb60c..d4c0d64019a 100644 --- a/sys/arch/sgi/conf/GENERIC-IP32 +++ b/sys/arch/sgi/conf/GENERIC-IP32 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC-IP32,v 1.50 2019/12/17 13:08:56 reyk Exp $ +# $OpenBSD: GENERIC-IP32,v 1.51 2021/01/23 05:08:36 thfr Exp $ # # THIS KERNEL IS FOR O2 (IP32) SYSTEMS ONLY. # @@ -111,6 +111,7 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART ucom* at uslhcom? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support atu* at uhub? # Atmel AT76c50x based 802.11b aue* at uhub? # ADMtek AN986 Pegasus Ethernet axe* at uhub? # ASIX Electronics AX88172 USB Ethernet diff --git a/sys/arch/sgi/sgi/conf.c b/sys/arch/sgi/sgi/conf.c index bb9d2ef6d88..b6ee44c1688 100644 --- a/sys/arch/sgi/sgi/conf.c +++ b/sys/arch/sgi/sgi/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.43 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.44 2021/01/23 05:08:36 thfr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -122,6 +122,7 @@ cdev_decl(pci); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -215,6 +216,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 75: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 76: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 77: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 78: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/arch/sparc64/conf/GENERIC b/sys/arch/sparc64/conf/GENERIC index 92c2157cde0..e29faa8181a 100644 --- a/sys/arch/sparc64/conf/GENERIC +++ b/sys/arch/sparc64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.314 2019/12/17 13:08:56 reyk Exp $ +# $OpenBSD: GENERIC,v 1.315 2021/01/23 05:08:36 thfr Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -224,6 +224,7 @@ umsm* at uhub? # Qualcomm MSM EVDO ucom* at umsm? uhid* at uhidev? # USB generic HID support fido* at uhidev? # FIDO/U2F security key support +ujoy* at uhidev? # USB joystick/gamecontroller support upd* at uhidev? # USB Power Devices sensors aue* at uhub? # ADMtek AN986 Pegasus Ethernet atu* at uhub? # Atmel AT76c50x based 802.11b diff --git a/sys/arch/sparc64/sparc64/conf.c b/sys/arch/sparc64/sparc64/conf.c index 49c31ac84c3..6e7df9247dd 100644 --- a/sys/arch/sparc64/sparc64/conf.c +++ b/sys/arch/sparc64/sparc64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.84 2020/07/06 04:32:25 dlg Exp $ */ +/* $OpenBSD: conf.c,v 1.85 2021/01/23 05:08:36 thfr Exp $ */ /* $NetBSD: conf.c,v 1.17 2001/03/26 12:33:26 lukem Exp $ */ /* @@ -104,6 +104,7 @@ cdev_decl(pci); #include "usb.h" #include "uhid.h" #include "fido.h" +#include "ujoy.h" #include "ugen.h" #include "ulpt.h" #include "ucom.h" @@ -297,6 +298,7 @@ struct cdevsw cdevsw[] = cdev_switch_init(NSWITCH,switch), /* 136: switch(4) control interface */ cdev_fido_init(NFIDO,fido), /* 137: FIDO/U2F security key */ cdev_pppx_init(NPPPX,pppac), /* 138: PPP Access Concentrator */ + cdev_ujoy_init(NUJOY,ujoy), /* 139: USB joystick/gamecontroller */ }; int nchrdev = nitems(cdevsw); diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb index 1d673cf635d..ff94bf8765b 100644 --- a/sys/dev/usb/files.usb +++ b/sys/dev/usb/files.usb @@ -1,4 +1,4 @@ -# $OpenBSD: files.usb,v 1.143 2020/05/31 18:15:37 jcs Exp $ +# $OpenBSD: files.usb,v 1.144 2021/01/23 05:08:36 thfr Exp $ # $NetBSD: files.usb,v 1.16 2000/02/14 20:29:54 augustss Exp $ # # Config file and device description for machine-independent USB code. @@ -74,13 +74,18 @@ file dev/usb/uhidev.c uhidev # Generic HID devices device uhid: hid attach uhid at uhidbus -file dev/usb/uhid.c uhid | fido needs-flag +file dev/usb/uhid.c uhid | fido | ujoy needs-flag # FIDO/U2F security keys device fido: hid attach fido at uhidbus file dev/usb/fido.c fido needs-flag +# USB Joysticks/Gamecontrollers +device ujoy: hid +attach ujoy at uhidbus +file dev/usb/ujoy.c ujoy needs-flag + # Keyboards file dev/usb/ukbdmap.c hidkbd device ukbd: hid, hidkbd, wskbddev diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index f43eaa13a13..bf3cd166380 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.81 2020/12/25 12:59:52 visa Exp $ */ +/* $OpenBSD: uhid.c,v 1.82 2021/01/23 05:08:36 thfr Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -36,6 +36,7 @@ */ #include "fido.h" +#include "ujoy.h" #include #include @@ -96,6 +97,10 @@ uhid_lookup(dev_t dev) #if NFIDO > 0 else if (cdev->d_open == fidoopen) cd = &fido_cd; +#endif +#if NUJOY > 0 + else if (cdev->d_open == ujoyopen) + cd = &ujoy_cd; #endif else return (NULL); diff --git a/sys/dev/usb/uhid.h b/sys/dev/usb/uhid.h index 9b46dfc344f..e54454612ac 100644 --- a/sys/dev/usb/uhid.h +++ b/sys/dev/usb/uhid.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.h,v 1.1 2019/12/17 13:08:54 reyk Exp $ */ +/* $OpenBSD: uhid.h,v 1.2 2021/01/23 05:08:36 thfr Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -48,6 +48,7 @@ struct uhid_softc { extern struct cfdriver uhid_cd; extern struct cfdriver fido_cd; +extern struct cfdriver ujoy_cd; #define UHIDUNIT(dev) (minor(dev)) #define UHID_CHUNK 128 /* chunk size for read */ diff --git a/sys/dev/usb/ujoy.c b/sys/dev/usb/ujoy.c new file mode 100644 index 00000000000..18a35d737b9 --- /dev/null +++ b/sys/dev/usb/ujoy.c @@ -0,0 +1,149 @@ +/* $OpenBSD: ujoy.c,v 1.1 2021/01/23 05:08:36 thfr Exp $ */ + +/* + * Copyright (c) 2021 Thomas Frohwein + * Copyright (c) 2021 Bryan Steele + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +int ujoy_match(struct device *, void *, void *); + +struct cfdriver ujoy_cd = { + NULL, "ujoy", DV_DULL +}; + +const struct cfattach ujoy_ca = { + sizeof(struct uhid_softc), + ujoy_match, + uhid_attach, + uhid_detach, +}; + +/* + * XXX workaround: + * + * This is a copy of sys/dev/hid/hid.c:hid_is_collection(), synced up to the + * NetBSD version. Our current hid_is_collection() is not playing nice with + * all HID devices like the PS4 controller. But applying this version + * globally breaks other HID devices like ims(4) and imt(4). Until our global + * hid_is_collection() can't be fixed to play nice with all HID devices, we + * go for this dedicated ujoy(4) version. + */ +int +ujoy_hid_is_collection(const void *desc, int size, uint8_t id, int32_t usage) +{ + struct hid_data *hd; + struct hid_item hi; + uint32_t coll_usage = ~0; + + hd = hid_start_parse(desc, size, hid_input); + if (hd == NULL) + return (0); + + while (hid_get_item(hd, &hi)) { + if (hi.kind == hid_collection && + hi.collection == HCOLL_APPLICATION) + coll_usage = hi.usage; + + if (hi.kind == hid_endcollection) + coll_usage = ~0; + + if (hi.kind == hid_input && + coll_usage == usage && + hi.report_ID == id) { + hid_end_parse(hd); + return (1); + } + } + hid_end_parse(hd); + + return (0); +} + +int +ujoy_match(struct device *parent, void *match, void *aux) +{ + struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux; + int size; + void *desc; + int ret = UMATCH_NONE; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (ret); + + /* Find the general usage page and gamecontroller collections */ + uhidev_get_report_desc(uha->parent, &desc, &size); + + if (ujoy_hid_is_collection(desc, size, uha->reportid, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_JOYSTICK))) + ret = UMATCH_IFACECLASS; + + if (ujoy_hid_is_collection(desc, size, uha->reportid, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_GAME_PAD))) + ret = UMATCH_IFACECLASS; + + return (ret); +} + +int +ujoyopen(dev_t dev, int flag, int mode, struct proc *p) +{ + /* Restrict ujoy devices to read operations */ + if ((flag & FWRITE)) + return (EPERM); + return (uhid_do_open(dev, flag, mode, p)); +} + +int +ujoyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) +{ + switch (cmd) { + case FIONBIO: + case FIOASYNC: + case USB_GET_DEVICEINFO: + case USB_GET_REPORT: + case USB_GET_REPORT_DESC: + case USB_GET_REPORT_ID: + break; + default: + return (EPERM); + } + + return (uhidioctl(dev, cmd, addr, flag, p)); +} diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 7478aa7b825..5783e5244d2 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.155 2020/07/06 04:11:26 dlg Exp $ */ +/* $OpenBSD: conf.h,v 1.156 2021/01/23 05:08:36 thfr Exp $ */ /* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */ /*- @@ -383,6 +383,13 @@ extern struct cdevsw cdevsw[]; (dev_type_stop((*))) enodev, 0, dev_init(c,uhid,poll), \ (dev_type_mmap((*))) enodev, 0, 0, dev_init(c,uhid,kqfilter) } +/* open, close, read, write, ioctl, poll, kqfilter */ +#define cdev_ujoy_init(c,n) { \ + dev_init(c,n,open), dev_init(c,uhid,close), dev_init(c,uhid,read), \ + dev_init(c,uhid,write), dev_init(c,ujoy,ioctl), \ + (dev_type_stop((*))) enodev, 0, dev_init(c,uhid,poll), \ + (dev_type_mmap((*))) enodev, 0, 0, dev_init(c,uhid,kqfilter) } + /* open, close, init */ #define cdev_pci_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ @@ -624,6 +631,7 @@ cdev_decl(usb); cdev_decl(ugen); cdev_decl(uhid); cdev_decl(fido); +cdev_decl(ujoy); cdev_decl(ucom); cdev_decl(ulpt); cdev_decl(urio); -- 2.20.1