From: Ulf Brosziewski Subject: Re: Help with backport support of Apple MagicTracpad 2 To: "Kirill A. Korinsky" , tech@openbsd.org Date: Tue, 5 Mar 2024 16:13:47 +0100 If you manage to activate raw mode, the next problem you might encounter is that ubcmtp won't work if it configures wsmouse without the WSMOUSEHW_MT_TRACKING flag. ubcmtp uses wsmouse_mtframe() for passing inputs to wsmouse, and this function has been added to wsmouse for the (rare) case that MT hardware doesn't provide tracking data - or that the relevant details of the protocol are unknown. wsmouse_mtframe() does nothing if the MT_TRACKING flag isn't set. However, it seems that Magic Trackpads do provide tracking IDs - in the 'id' field of the 'ubcmtp_finger_compact' struct. You could map these IDs to slot values with wsmouse_id_to_slot, and apply the "normal" method of reporting MT inputs to wsmouse, that is, by calling wsmouse_mtstate as long as a touch is active, and signalling its end by calling the function with a 'pressure' value of 0. And, just in case you are puzzled by the terminology: A "tracking ID" is an arbitrary number that identifies a touch within a series of input reports. By "slots", I refer to IDs that are restricted to the range [0-n], where n is small enough for using the values as array indices. In the current implementation, the maximal number of MT slots in wsmouse is 10, which is reason why the 'id_to_slot' mapping would be necessary even for 4-bit IDs. BTW, if you send further diffs to tech@, please send them inline (and make sure that your mail client doesn't reformat them). On 3/3/24 22:57, Kirill A. Korinsky wrote: > Dear tech@, > > I need help with backporting support of Apple MagicTracpad 2. > > As a base implementation I've used code from FreeBSD [1] which seems quite > trivial. > > Anyway, a naive reimplementation doesn't work. When I attach the device I > have inside dmesg: > > uhidev0 at uhub0 port 1 configuration 1 interface 0 "Apple Inc. Magic Trackpad" rev 2.00/8.60 addr 4 > uhidev0: iclass 3/0, 224 report ids > uhid0 at uhidev0 reportid 144: input=2, output=0, feature=0 > uhid1 at uhidev0 reportid 154: input=1, output=0, feature=0 > uhid2 at uhidev0 reportid 224: input=4, output=0, feature=0 > ubcmtp0 at uhub0 port 1 configuration 1 interface 1 "Apple Inc. Magic Trackpad" rev 2.00/8.60 addr 4 > ubcmtp0: attached to 0x5ac/0x265 type 5 > wsmouse4 at ubcmtp0 > ubcmtp0: ubcmtp_raw_mode: failed to toggle raw mode > ubcmtp0: failed to enter raw mode > attach error=1 > uhidev1 at uhub0 port 1 configuration 1 interface 3 "Apple Inc. Magic Trackpad" rev 2.00/8.60 addr 4 > uhidev1: iclass 3/0, 192 report ids > uhid3 at uhidev1 reportid 192: input=107, output=0, feature=0 > uhid0 detached > uhid1 detached > uhid2 detached > uhidev0 detached > wsmouse4 detached > ubcmtp0 detached > uhid3 detached > uhidev1 detached > > that means that it can't enter into raw mode. > > So, I deffently had missed something. > > > Footnotes: > [1] https://github.com/freebsd/freebsd-src/commit/ef8397c28e981e0115d435aabcf57cee7ea5f5ee >