{"id":6566,"date":"2022-10-28T16:41:01","date_gmt":"2022-10-28T16:41:01","guid":{"rendered":"https:\/\/41j.com\/blog\/?p=6566"},"modified":"2022-10-28T16:41:01","modified_gmt":"2022-10-28T16:41:01","slug":"ubuntu-20-04-fujitsu-fareht1-mouse-touch-screen-fixes%ef%bf%bc","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2022\/10\/ubuntu-20-04-fujitsu-fareht1-mouse-touch-screen-fixes%ef%bf%bc\/","title":{"rendered":"Ubuntu 20.04 Fujitsu FAREHT1 Mouse\/Touch Screen Fixes\ufffc"},"content":{"rendered":"\n<p>As previously noted, the touchscreen and pen input on my FAREHT1 under Ubuntu was inverted. By default this version of Ubuntu seems to be using Wayland and libinput. Wayland is pretty short on input configuration options and I tried to switch to Xorg, but also had various issues here.<\/p>\n\n\n\n<p>Googling around it seems that you&#8217;re supposed to be able to configure libinput via UDEV rules (e.g. ENV{LIBINPUT_CALIBRATION_MATRIX}=&#8221;1 0 0 0 1 0&#8243;). For whatever reason this wasn&#8217;t working for me, libinput didn&#8217;t seem to be picking up the calibration matrix at all.<\/p>\n\n\n\n<p>libinput itself support device\/model quirks, but doesn&#8217;t have a quirk config that simply lets you enter a calibration matrix. So I decided to hack away at libinput. I grabbed the package source as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>vi \/etc\/apt\/sources.list #Uncomment source packages in sources.list\napt-get update\napt-get install dpkg-dev\napt-get source libinput\ncd libinput-1.20.0\napt-get install build-essential\napt-get install cmake\napt-get install pkg-config\napt-get install libudev-dev\napt-get install libmtdev-dev\napt-get install libevdev-dev\napt-get install libwacom-dev\napt-get install libwacom\napt-get install libgtk-3-dev<\/code><\/pre>\n\n\n\n<p>Next I needed to hack the libinput sources. To the function quirk_get_name(enum quirk q) in quirks.c I added a new quirk type in addition to the existing quirks (ModelInvertMouse below):<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>        case QUIRK_MODEL_INVERT_HORIZONTAL_SCROLLING:   return \"ModelInvertHorizontalScrolling\";\n        case QUIRK_MODEL_INVERT_MOUSE:                  return \"ModelInvertMouse\";\n        case QUIRK_MODEL_LENOVO_SCROLLPOINT:            return \"ModelLenovoScrollPoint\";<\/code><\/pre>\n\n\n\n<p>And the definition to quirk.h:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>        QUIRK_MODEL_HP_ZBOOK_STUDIO_G3,\n        QUIRK_MODEL_INVERT_MOUSE,\n        QUIRK_MODEL_INVERT_HORIZONTAL_SCROLLING,<\/code><\/pre>\n\n\n\n<p>Then in evdev.c I added the following:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\n        if (libevdev_has_event_code(evdev, EV_ABS, ABS_X)) {\n                evdev_extract_abs_axes(device, udev_tags);\n\n                if (evdev_is_fake_mt_device(device))\n                        udev_tags &amp;= ~EVDEV_UDEV_TAG_TOUCHSCREEN;\n        }\n\n\/\/CODE ADDED HERE\n        if (evdev_device_has_model_quirk(device, QUIRK_MODEL_INVERT_MOUSE)) {\n                \/\/Invert pointer calibration matrix\n                float mat&#91;6];\n                \n                mat&#91;0]=-1; mat&#91;1]=0;  mat&#91;2]=1;\n                mat&#91;3]=0;  mat&#91;4]=-1; mat&#91;5]=1;\n                \n                evdev_device_set_default_calibration(device,mat);\n        }\n\/\/ADDED CODE ENDS HERE\n\n        if (evdev_device_has_model_quirk(device,\n                                         QUIRK_MODEL_DELL_CANVAS_TOTEM)) {\n                dispatch = evdev_totem_create(device);\n                device->seat_caps |= EVDEV_DEVICE_TABLET;\n                evdev_log_info(device, \"device is a totem\\n\");\n                return dispatch;\n        }\n<\/code><\/pre>\n\n\n\n<p>In the quirks directory I created a new file 50-system-fujitsu.quirks with the following contents:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;FAREHT1]\nMatchName=WCOM0101:00 2D1F:009C\nModelInvertMouse=1\n\n&#91;FAREHT2]\nMatchName=FTSC1000:00 2808:2922\nModelInvertMouse=1\n<\/code><\/pre>\n\n\n\n<p>I also had to go in and disable the libinput calibration interface. I think this is likely the fundamental problem. Something in gdm\/wayland is going in a over-riding whatever calibration matrix is set via udev, in libinput.c I commented out the following:<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>LIBINPUT_EXPORT enum libinput_config_status\nlibinput_device_config_calibration_set_matrix(struct libinput_device *device,\n                                              const float matrix&#91;6])\n{\n\/\/ Disable Wayland screwups\n\/\/      if (!libinput_device_config_calibration_has_matrix(device))\n                return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;\n\n\/\/      return device->config.calibration->set_matrix(device, matrix);\n\n}\n<\/code><\/pre>\n\n\n\n<p>I <em>also<\/em> had to go in and disable calibration via dev. Even after removing any relevant udev rules, libinput seems to attempt to read udev and set the identity matrix if it doesn&#8217;t find anything there. This means commenting out the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>evdev_read_calibration_prop(device);<\/code><\/pre>\n\n\n\n<p>In path-seat.c and udev-seat.c.<\/p>\n\n\n\n<p>With all these changes in place, libinput can then be build and installed as follows, restarting gdm for changes to take effect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir builddir\nmeson --prefix=\/usr builddir\/\nninja -C builddir\/ \nninja -C builddir\/ install\n\/etc\/init.d\/gdm3 restart<\/code><\/pre>\n\n\n\n<p>Touch sensitivity still seems a bit off. But I&#8217;m happy enough with it for the moment.<\/p>\n\n\n\n<p>A tarball containing all my changes is <a href=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2022\/10\/libinput-1.20.0.tar.gz\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As previously noted, the touchscreen and pen input on my FAREHT1 under Ubuntu was inverted. By default this version of Ubuntu seems to be using Wayland and libinput. Wayland is pretty short on input configuration options and I tried to switch to Xorg, but also had various issues here. Googling around it seems that you&#8217;re [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-6566","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-1HU","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/6566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=6566"}],"version-history":[{"count":2,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/6566\/revisions"}],"predecessor-version":[{"id":6569,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/6566\/revisions\/6569"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=6566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=6566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=6566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}