summaryrefslogtreecommitdiff
path: root/sys/src/cmd/nusb/kb/kb.c
AgeCommit message (Collapse)Author
2023-01-29nusb/kb: GAOMON S620 tablet supportcinap_lenrek
The GAOMON S620 tablet is recognized as a HID device, but is restricted in the X-axis to the width of a mobile phone. I sniffed usb traffic for generic windows 10 hid driver and there didnt seem anything out of the ordinary. It turns out that this is some kind of phone feature and i suspect they have some heuristic for how windows reads the device and config descriptors to decide if this is windows or android. Checking the DIGImend project git repository, they suggest this is some kind of UCLOGIC compatible tablet, which once a series of string properties have been read will switch itself to some different mode. The report descriptor is supposed to be generated from the string properties, but the report format didnt really match theirs. So i ignore the string properties and just looked at the report data. The format after reading the magic string properties seems to be: 08 - report id bb - buttons: 0x80 = inrange, 0x04 = eraser, 0x02, barrel, 0x01 = touch xx xx - x-axis: [0x0000-0x80000) yy yy - y-axis: [0x0000-0x50000) pp pp - pressure: [0x0000-0xffff] ?? ?? - unknown So i hand rolled a hid report descriptor for this and call it a day :)
2022-10-07nusb/kb: support 無変換, 変換, and 'ひらがな / カタカナ' keysJacob Moody
These usb codes are defined for Japanese OADG 109(A) layouts. The scancodes are already defined in /sys/lib/kbmap/jp, they map to ^l, ^\, and ^n (^v with shift). These perform actions true to form in ktrans already: clearing the line buffer, completing to kanji, and switching between hiragana and katakana. http://hp.vector.co.jp/authors/VA003720/lpproj/others/kbdjpn.htm tested with 109A layout tex shinobi
2022-10-06nusb/kb: add "rawon"/"rawoff" to switch ctl fid into raw report output modeSigrid Solveig Haflínudóttir
2022-10-06nusb/kb, aux/kbdfs: add brightness down/up media keysSigrid Solveig Haflínudóttir
2022-10-04aux/kbdfs, nusb/kb: add basic media keys support; add /dev/hidNctl to change ↵Sigrid Solveig Haflínudóttir
repeat/delay; fix a race condition
2022-09-28nusb/kb: fix scancode for right ctlSigrid Solveig Haflínudóttir
2022-02-21nusb: Fix handling of interface altsetting.cinap_lenrek
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
2021-01-22nusb/kb: correct Mod4 scancode (125 → 91, to match what kbdfs has)Sigrid
2020-12-08nusb/kb: update button state if event was actually received, fix typos ↵Sigrid
(thanks umbraticus)
2020-11-21nusb/kb, nusb/joy: dont try to set protocol on nonboot devicesmischief
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-05-08nusb/kb: add quirks for Elecom HUGE trackballkvik
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.
2019-05-07nusb/usbd: work around devices that ignore the high byte of wLength in ↵cinap_lenrek
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-03-21nusb/kb: fix continuous scrollwheel delta not being reported (thanks sam-d)cinap_lenrek
2018-11-14nusb/kb: multitouch support (touchscreens, stylus)cinap_lenrek
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-13nusb/kb: revert multitouch, breaks some mice...cinap_lenrek
2018-11-12nusb/kb: lilu dallas multitouchcinap_lenrek
2018-10-20nusb/kb: work arround broken split transaction on raspi's dwc otg usb controllercinap_lenrek
2018-05-08add usb tablet supportaiju
2016-09-28nusb/kb: set usage to 0 (undefined) for items exceeding usage listcinap_lenrek
2015-04-08nusb/kb: always try to recover on error, fix recover for multi-function devicescinap_lenrek
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-01-01nusb/kb: fix alt/altgr being swapped for some reasonftrvxmtrx
2014-10-31nusb/kb: dont set boot protocol on HidCSP interface when we failed to read ↵cinap_lenrek
report descriptor (thanks aap_) this fixes wireless keyboard/mouse on raspi.
2014-08-16nusb/kb: delete code for keyboard boot protocol handling, just use hid parsercinap_lenrek
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-06-28nusb: implement aijus stable uniqueue device namescinap_lenrek
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-05-03fix threadsetname usage in few placesftrvxmtrx
2014-04-18nusb/kb: fix trackpoint on thinkpad usb keyboardftrvxmtrx
The trackpoint has no subclass, but it's still a pointer device. Also close the device while we are here.
2013-08-10nusb/kb: *really* only send to mousein when mouse state actually changes ↵cinap_lenrek
(zero detlas, same buttons)
2013-08-10revert previous commit... stupid ideacinap_lenrek
2013-08-10nusb/kb: only send to mousein when mouse state actually changescinap_lenrek
2013-06-02nusb/kb: map button 4 to middle button 2 (for logitech 5 button mouse)cinap_lenrek
2013-05-18nusb/kb: simplify repeat logic as scancode now contains the info about esc1 ↵cinap_lenrek
extension
2013-05-18nusb/kb: oops, fixupftrvxmtrx
2013-05-18nusb/kb: use a flag to indicate extended code; fix the most unix-friendly ↵ftrvxmtrx
key on se/fi kbd layout
2013-03-01nusb/kb: fix "Home" key producing "7" with some usb keyboards (import from ↵cinap_lenrek
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-01-30nusb/kb: increase maximum report descriptor size, non-continuous endpoints ↵cinap_lenrek
(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.
2012-12-26nusb/kb: remove mouse acceleration -a flagcinap_lenrek
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-19nusb/kb: use report protocol for mousecinap_lenrek
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-11-30nusb/kb: fix 5ms sleep polling in repeatproc, notegroup, cleanupcinap_lenrek
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-30nusb/kb: add support for evoluent vertical mousecinap_lenrek
2012-11-25nusb/kb: skip 0x01 lead byte hack, you dont wanna knowcinap_lenrek
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-24nusb/kb: zero reads, error handling, priority, cleanupcinap_lenrek
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-08-13nusb/kb: increase mouse packet buffer from 32 to 64 bytes for Microsoft ↵cinap_lenrek
Sidewinder X5 Mouse (thanks Rexford Gibbs for reporting and testing)
2011-11-30kb.c: add curly braces to enable usb mouse nub scrollingstanley lieber
2011-08-01nusb: fix usage inconsitency, shr namescinap_lenrek
2011-08-01nusb: put setleds in kbworkcinap_lenrek
2011-07-31kb: don't do setleds on miceaiju
2011-07-27nusb: improvedaiju