Skip to content

Commit

Permalink
Try to fix #52
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Jan 8, 2021
1 parent 1c6efe8 commit b158ece
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 0 deletions.
71 changes: 71 additions & 0 deletions overlays/uzip/hello/files/etc/rc.d/load_acpi
Original file line number Diff line number Diff line change
@@ -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"
41 changes: 41 additions & 0 deletions overlays/uzip/hello/files/etc/rc.d/load_iichid
Original file line number Diff line number Diff line change
@@ -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"

39 changes: 39 additions & 0 deletions overlays/uzip/hello/files/usr/local/bin/enable_tapping
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions overlays/uzip/hello/files/usr/local/bin/start-hello
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions overlays/uzip/hello/files/usr/local/bin/tpquirk
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions settings/rc.conf.hello
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
slim_enable="YES"
autofs_enable="YES"
load_iichid_enable="YES"
load_acpi_enable="YES"

0 comments on commit b158ece

Please sign in to comment.