Commit graph

41 commits

Author SHA1 Message Date
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
Sigrid a9e70446a0 nusb/kb: correct Mod4 scancode (125 → 91, to match what kbdfs has) 2021-01-22 17:48:41 +01:00
Sigrid 07805ac892 nusb/kb: update button state if event was actually received, fix typos (thanks umbraticus) 2020-12-08 11:47:15 +01:00
mischief f8738fd757 nusb/kb, nusb/joy: dont try to set protocol on nonboot devices
the hid 1.11 specification says that for hid devices which arent in
the boot subclass (subclass 1), it is only optional to support the set
protocol command.  for my devices, trying to set protocol results in a
stall error and unusable devices.

fixes my Tex Shinobi keyboard and Playstation 4 controller.
2020-11-21 12:31:54 -08:00
kvik 758edf2b14 nusb/kb: add quirks for Elecom HUGE trackball
As said in the code comment:

	Elecom trackball report descriptor lies by
	omission, failing to mention all its buttons.
	We patch the descriptor with a correct count
	which lets us parse full reports. Tested with:
		Elecom HUGE (M-HT1DRBK, M-HT1URBK)

The descriptor fixup is adapted from Linux kernel:
	drivers/hid/hid-elecom.c
in which a more detailed account of why and how this
works may be found.

A followup change to nusb/kb will be needed to expose
these additional events for potential remapping.
2020-05-08 20:49:11 +02:00
cinap_lenrek 3a4a3faf29 nusb/usbd: work around devices that ignore the high byte of wLength in control transfer reads
there appear to be devices out there such as Realtek RTL2838UHIDIR
SDR that do not process control transfers correctly, ignoring the
high byte of the wLength field. to work around this, we specify an
odd number of bytes for read sizes >= 256 which keeps the low byte
0xFF.
2019-05-07 09:19:53 +02:00
cinap_lenrek 58668339bc nusb/kb: fix continuous scrollwheel delta not being reported (thanks sam-d) 2019-03-21 01:27:28 +01:00
cinap_lenrek 06783edd7a nusb/kb: multitouch support (touchscreens, stylus)
touchscreens signal multiple contact points (X/Y) in
the hid descriptor separated by being nested in separate
collections. the contact point is identified by a
optional contact id. if omited, we use the collection
index and report id.

so we collect all the items (X/Y, buttons, wheel) from
separate collections in Hidslot structures and in the
end combine all the slots together.

buttons are or'ed together while absolute X/Y is applied
when it changed. relative X/Y deltas get added together.

thanks to kivik and Glats for testing.
2018-11-14 09:12:34 +01:00
cinap_lenrek 8a7f897b30 nusb/kb: revert multitouch, breaks some mice... 2018-11-13 03:34:19 +01:00
cinap_lenrek 9de1403358 nusb/kb: lilu dallas multitouch 2018-11-12 08:52:01 +01:00
cinap_lenrek 5bb7240ee9 nusb/kb: work arround broken split transaction on raspi's dwc otg usb controller 2018-10-20 19:57:37 +02:00
aiju 0e5888a0cf add usb tablet support 2018-05-08 08:28:48 +00:00
cinap_lenrek 062a46607e nusb/kb: set usage to 0 (undefined) for items exceeding usage list 2016-09-28 19:25:23 +02:00
cinap_lenrek adfb8dff26 nusb/kb: always try to recover on error, fix recover for multi-function devices
when we get an i/o error, always call hdrecover() which
will reset the port and reinitialize the interface of
the calling processes endpoint.

handle the case when we have multi-function device with
multiple reader procs in hdrecover(). the sequence is
as follows:

1) any of the reader procs encounters i/o error and calls hdrecover(),
acquires qlock and initiates port reset.
2) any other readerprocs will now encounter i/o error (due to reset) and also call
hdrecover() but will be waiting on the qlock for reset to complete.
3) first process completes reset and reinitializes its interface with setproto()
and then releases the qlock for the other readers todo the same.
2015-04-08 18:07:16 +02:00
ftrvxmtrx c5da8810ee nusb/kb: fix alt/altgr being swapped for some reason 2015-01-01 22:53:17 +01:00
cinap_lenrek bb33ba6b9a nusb/kb: dont set boot protocol on HidCSP interface when we failed to read report descriptor (thanks aap_)
this fixes wireless keyboard/mouse on raspi.
2014-10-31 20:40:13 +01:00
cinap_lenrek a5bce84600 nusb/kb: delete code for keyboard boot protocol handling, just use hid parser
unify the keyboard and mouse readers into one using the hid
report parser for both. remove the keyboard protocol handling,
as it is now handled by hid parser and all we get is a sequence
of keycodes in Hiddev.k[] which we diff for up/down and translate
to pc scancodes.
2014-08-16 23:34:28 +02:00
cinap_lenrek 4275c49e72 nusb: implement aijus stable uniqueue device names
instead of naming devices by ther dynamically assigned device address,
we hash device uniqueue fields from the device descriptor and produce
a 5 digit hex string that will identify the device across machines.

when there is a collision (less than 1% chance with 100 devices),
usbd will append the device address to the name to make it uniqueue
for this machine.

the hname is passed to drivers in the devid argument, which now has
the form addr:hname, where the colon and hname can be omited (for backwards
compatibility).

when the new behaviour isnt desired, nousbhname= environment variable
can be defined giving the old behaviour.
2014-06-28 18:09:43 +02:00
ftrvxmtrx d2c3185bfa fix threadsetname usage in few places 2014-05-03 13:07:52 +02:00
ftrvxmtrx 9204ed8910 nusb/kb: fix trackpoint on thinkpad usb keyboard
The trackpoint has no subclass, but it's still a pointer device.
Also close the device while we are here.
2014-04-18 16:43:43 +02:00
cinap_lenrek bfe852b3a2 nusb/kb: *really* only send to mousein when mouse state actually changes (zero detlas, same buttons) 2013-08-10 08:47:43 +02:00
cinap_lenrek 2012ba4d03 revert previous commit... stupid idea 2013-08-10 08:37:13 +02:00
cinap_lenrek f887f71320 nusb/kb: only send to mousein when mouse state actually changes 2013-08-10 07:59:54 +02:00
cinap_lenrek 97c4381dc4 nusb/kb: map button 4 to middle button 2 (for logitech 5 button mouse) 2013-06-02 23:45:38 +02:00
cinap_lenrek 4c6c7be688 nusb/kb: simplify repeat logic as scancode now contains the info about esc1 extension 2013-05-18 01:46:25 +02:00
ftrvxmtrx 506cae05df nusb/kb: oops, fixup 2013-05-18 01:03:13 +02:00
ftrvxmtrx 811c3e8d78 nusb/kb: use a flag to indicate extended code; fix the most unix-friendly key on se/fi kbd layout 2013-05-18 01:01:34 +02:00
cinap_lenrek 6bd2c26a85 nusb/kb: fix "Home" key producing "7" with some usb keyboards (import from sources patch/usb-khome)
Fixes the problem with certain keyboards generating "7" on "Home" key press.

http://9fans.net/archive/2013/03/8
http://9fans.net/archive/2013/03/10
2013-03-01 19:53:11 +01:00
cinap_lenrek a2b83a5aea nusb/kb: increase maximum report descriptor size, non-continuous endpoints (from richard millars usbmouse-endpoint patch)
Another band-aid fix to the usb mouse driver, to cope with a mouse which has
an interrupt endpoint number 3 but no number 1 or 2, and a report descriptor
more than 128 bytes long.
2013-01-30 20:33:28 +01:00
cinap_lenrek 8f3595e058 nusb/kb: remove mouse acceleration -a flag
mouse acceleration can be done by software in the kernels
devmouse device like:

echo hwaccel off >/dev/mousectl
echo accelerated 5 >/dev/mousectl

it is hard to pass nusb/kb parameters anyway as it is started
from nusbrc in bootfs.paq, so i remove the option.
2012-12-26 22:48:12 +01:00
cinap_lenrek 7b34e8e759 nusb/kb: use report protocol for mouse
instead of forcing mouse to boot protocol, which often
doesnt work, we set it to report protocol and parse
the hid report descriptor. if thers no such descriptor
we revert to boot protocol.

all mouse packet parsing is done by report parser,
even for boot protocol. also all the work arrounds
for the leadbyte hack (report id?) are removed.

keyboards should not be affected by this change.
2012-12-19 12:09:35 +01:00
cinap_lenrek 86eaffdcaa nusb/kb: fix 5ms sleep polling in repeatproc, notegroup, cleanup
fix repeatproc timeout handling, add constants for Kbdelay
and Kbrepeat.

set procname so one knows which is keyboard and which is mouse
and on what endpoints they work.

9front's /dev/mousein and /dev/kbdin allow multiple opens,
so theres no need for the refcounted Kin structures.

spawn the worker procs in ther own note group, so they wont
get killed on interrupt in the original notegroup.
2012-11-30 19:01:59 +01:00
cinap_lenrek 3f25f69718 nusb/kb: add support for evoluent vertical mouse 2012-11-30 04:02:03 +01:00
cinap_lenrek 4260392749 nusb/kb: skip 0x01 lead byte hack, you dont wanna know
apparently, some mouse send constant 0x01 byte
before normal 4 byte mouse packet. this is known in
openbsd/freebsd as UQ_MS_LEADING_BYTE quirk.
2012-11-25 22:37:53 +01:00
cinap_lenrek aadc581040 nusb/kb: zero reads, error handling, priority, cleanup
handle short reads as errors and retry. this can happen
on ohci and some ps2 to usb converter. it might'v deen caused
by a recent change on sources handling td overrun differently.

fix error handling. have to check f->ep == nil after recovery
and check packet size. also, use f->ep->dfd instead of ptrfd
and kbdfd as it might be different after recovery. make a
setleds() error non fatal.

boost process priority for keyboard and mouse worker processes.

cleanup: use single write() in putmod(), improve error reporting.
2012-11-24 16:37:39 +01:00
cinap_lenrek 142a77c9dc nusb/kb: increase mouse packet buffer from 32 to 64 bytes for Microsoft Sidewinder X5 Mouse (thanks Rexford Gibbs for reporting and testing) 2012-08-13 10:41:02 +02:00
stanley lieber b8136286b6 kb.c: add curly braces to enable usb mouse nub scrolling 2011-11-30 22:12:04 -06:00
cinap_lenrek b43de8eb1f nusb: fix usage inconsitency, shr names 2011-08-01 02:36:02 +02:00
cinap_lenrek e5bab1dd9f nusb: put setleds in kbwork 2011-08-01 02:01:04 +02:00
aiju 5bf221bab7 kb: don't do setleds on mice 2011-07-31 15:02:01 +02:00
aiju 05d09f086f nusb: improved 2011-07-27 20:07:30 +02:00