Skip to content

Instantly share code, notes, and snippets.

@chenhn123
Created February 5, 2024 10:30
Show Gist options
  • Save chenhn123/8c0c2992d35eaf1c9b8c04e00a4031c0 to your computer and use it in GitHub Desktop.
Save chenhn123/8c0c2992d35eaf1c9b8c04e00a4031c0 to your computer and use it in GitHub Desktop.
How to rebind weida hid i2c device
#!/bin/sh
#
# Copyright (c) 2024 Randy Lai
# Copyright (c) Weida
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# version:1.0
path=`ls /sys/bus/hid/devices/ | grep 0018:2575`
echo $path
hid_phys=$(grep HID_PHYS /sys/bus/hid/devices/$path/uevent | cut -d '=' -f2)
echo $hid_phys
driver=$(grep DRIVER /sys/bus/i2c/devices/$hid_phys/uevent | cut -d '=' -f2)
echo $driver
cd /sys/bus/i2c/drivers/$driver
sudo echo $hid_phys | sudo tee -a unbind
sleep 3
sudo echo $hid_phys | sudo tee -a bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment