From b158ece4249c961d26298a372664b7832f69ce4d Mon Sep 17 00:00:00 2001 From: probonopd Date: Fri, 8 Jan 2021 01:32:40 +0100 Subject: [PATCH] Try to fix #52 --- overlays/uzip/hello/files/etc/rc.d/load_acpi | 71 +++++++++++++++++++ .../uzip/hello/files/etc/rc.d/load_iichid | 41 +++++++++++ .../hello/files/usr/local/bin/enable_tapping | 39 ++++++++++ .../hello/files/usr/local/bin/start-hello | 6 ++ .../uzip/hello/files/usr/local/bin/tpquirk | 51 +++++++++++++ settings/rc.conf.hello | 2 + 6 files changed, 210 insertions(+) create mode 100755 overlays/uzip/hello/files/etc/rc.d/load_acpi create mode 100755 overlays/uzip/hello/files/etc/rc.d/load_iichid create mode 100755 overlays/uzip/hello/files/usr/local/bin/enable_tapping create mode 100755 overlays/uzip/hello/files/usr/local/bin/tpquirk diff --git a/overlays/uzip/hello/files/etc/rc.d/load_acpi b/overlays/uzip/hello/files/etc/rc.d/load_acpi new file mode 100755 index 000000000000..6fc33766c885 --- /dev/null +++ b/overlays/uzip/hello/files/etc/rc.d/load_acpi @@ -0,0 +1,71 @@ +#!/bin/sh + +# PROVIDE: load_acpi +# REQUIRE: FILESYSTEMS +# KEYWORD: nojail +# +# Add these lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# load_acpi_enable (bool): Set to YES by default. +# Set to NO to disable. +# + +. /etc/rc.subr + +name=load_acpi +rcvar=load_acpi_enable +start_cmd="load_acpi_start" +stop_cmd=":" + +load_rc_config $name + +: ${load_acpi_enable:="YES"} + +vendors="asus fujitsu hp ibm panasonic sony toshiba wmi" + +asus_hids="ATK0100 ASUS010" +toshiba_hids="TOS6200 TOS6207 TOS6208" +ibm_hids="IBM0068 LEN0068" +sony_hids="SNY5001" +wmi_hids="PNP0C14" +fujitsu_hids="FUJ02B1" +panasonic_hids="MAT0019" + +asus_kmod="acpi_asus" +toshiba_kmod="acpi_toshiba" +ibm_kmod="acpi_ibm" +sony_kmod="acpi_sony" +wmi_kmod="acpi_wmi" +fujitsu_kmod="acpi_fujitsu" +panasonic_kmod="acpi_panasonic" + +load_acpi_start() +{ + config=$(devinfo -rv) + found=0 + for i in ${vendors}; do + [ ${found} -gt 0 ] && break + eval hids=\$${i}_hids + for j in ${hids}; do + if echo "${config}" | grep -q -i _HID=${j}; then + eval kmod=\$${i}_kmod + kldload ${kmod} + found=1; break + fi + done + done + sysfam=$(kenv smbios.system.family) + load_acpi_video=1 + case ${sysfam} in + *ThinkPad*T450*) + # The Fn keys of the ThinkPad T450 for controlling the + # brightness will not work if the acpi_video(4) module + # is loaded. + load_acpi_video=0 + ;; + esac + [ ${load_acpi_video} -eq 1 ] && kldload acpi_video +} + +run_rc_command "$1" diff --git a/overlays/uzip/hello/files/etc/rc.d/load_iichid b/overlays/uzip/hello/files/etc/rc.d/load_iichid new file mode 100755 index 000000000000..ec48c8312046 --- /dev/null +++ b/overlays/uzip/hello/files/etc/rc.d/load_iichid @@ -0,0 +1,41 @@ +#!/bin/sh + +# PROVIDE: load_iichid +# REQUIRE: dsbdriverd kld +# BEFORE: LOGIN + +. /etc/rc.subr + +load_iichid_enable=${load_iichid_enable-"NO"} + +name="load_iichid" +rcvar="load_iichid_enable" +start_cmd="${name}_start" + +check_has_i2chid() { + devinfo -rv | egrep -q '(PNP0C50|ACPI0C50)' +} + +check_iichid_loaded() { + kldstat | grep -q -w 'iichid\.ko' +} + +load_iichid_start() { + check_has_i2chid || exit 0 + check_iichid_loaded && exit 0 + + local msg="There is one or more I2C HID devices (e.g. touchpad)" + local msg="${msg} installed.\n\nShall I load the experimental iichid" + local msg="${msg} driver?\n" + TERM=xterm dialog \ + --title "LOAD I2C HID DRIVER" \ + --yes-button "Load driver" --no-button "Cancel" \ + --yesno "${msg}" 8 60 + [ $? -ne 0 ] && exit 0 + kldload iicbus + kldload iichid +} + +load_rc_config $name +run_rc_command "$1" + diff --git a/overlays/uzip/hello/files/usr/local/bin/enable_tapping b/overlays/uzip/hello/files/usr/local/bin/enable_tapping new file mode 100755 index 000000000000..61c651049536 --- /dev/null +++ b/overlays/uzip/hello/files/usr/local/bin/enable_tapping @@ -0,0 +1,39 @@ +#!/bin/sh +# +# BSD 2-Clause License +# +# Copyright (c) 2020, The NomadBSD Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Enable "tapping" on touchpad + +ids=$(xinput | grep -v XTEST | egrep '.*slave[ \t]*pointer.*' | \ + sed -E 's/.*id=([0-9]+).*/\1/g') +for id in $ids; do + if (xinput list-props $id | grep -q Tapping); then + xinput set-prop $id "libinput Tapping Enabled" 1 2>/dev/null + fi +done + diff --git a/overlays/uzip/hello/files/usr/local/bin/start-hello b/overlays/uzip/hello/files/usr/local/bin/start-hello index 27bc3d1f0931..c8657853a911 100755 --- a/overlays/uzip/hello/files/usr/local/bin/start-hello +++ b/overlays/uzip/hello/files/usr/local/bin/start-hello @@ -39,6 +39,12 @@ if [ -z "${LANG}" ] || [ "C.UTF-8" = "${LANG}" ] ; then fi fi +# Use sysmouse if there is a problem with the touchpad; Credits: NomadBSD +tpquirk + +# Enable tapping on touchpad; Credits: NomadBSD +enable_tapping + # Swap keys: # On both PC and Apple keyboards, the key left from the space bar # shall be used to invoke menu shortcuts (which applications tend to diff --git a/overlays/uzip/hello/files/usr/local/bin/tpquirk b/overlays/uzip/hello/files/usr/local/bin/tpquirk new file mode 100755 index 000000000000..8a3f03855c04 --- /dev/null +++ b/overlays/uzip/hello/files/usr/local/bin/tpquirk @@ -0,0 +1,51 @@ +#!/bin/sh +# +# BSD 2-Clause License +# +# Copyright (c) 2020, The NomadBSD Project +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Check for touchpad bug +grep -q 'TouchPad.*:.*kernel bug' /var/log/Xorg.0.log || exit 0 + +# Determine the bits of the current mask. +mask=$(sysctl -n kern.evdev.rcpt_mask) +while [ $mask -gt 0 ]; do + for b in 3 2 1 0; do + n=$(echo "2^$b" | bc) + if [ $mask -ge $n ]; then + mask=$(($mask - $n)) + eval bit$b=1 + else + eval bit$b=0 + fi + done +done +# Preserve the keyboard bits (1, 0), unset bit 2 (mouse hardware), +# and set the sysmouse bit (0). +mask=$(echo "2^0 + $bit1 * 2^1 + $bit3 * 2^3" | bc) + +sudo /sbin/sysctl kern.evdev.rcpt_mask=$mask + diff --git a/settings/rc.conf.hello b/settings/rc.conf.hello index 2b16a198f7ae..7519d152cc4d 100644 --- a/settings/rc.conf.hello +++ b/settings/rc.conf.hello @@ -1,2 +1,4 @@ slim_enable="YES" autofs_enable="YES" +load_iichid_enable="YES" +load_acpi_enable="YES"