-
Notifications
You must be signed in to change notification settings - Fork 0
/
logitech-master
95 lines (89 loc) · 1.9 KB
/
logitech-master
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
source $1
function pressCommand(){
device=$1; button=$2; key_state=$3
#echo "Press key [" $device "/" $button "/" $key_state "]"
if [ ${key_state} = "pressed," ]; then
if [ ${button} = "BTN_EXTRA" ]; then
echo "BTN_EXTRA"
#####
$EVENT_SIDE1
#####
elif [ ${button} = "BTN_SIDE" ]; then
echo "BTN_SIDE"
#####
$EVENT_SIDE2
#####
fi
fi
}
function scrollCommand(){
device=$1; vert=$2; horiz=$3
if [ ${horiz} != "0.00/0" ]; then
#echo "Scroll horiz [" $device "/" $horiz "]"
if [[ ${horiz} = "-15.00"* ]]; then
echo "SCROLL_HORIZ_UP"
######
$EVENT_SCROLL_UP
######
elif [[ ${horiz} = "15.00"* ]]; then
echo "SCROLL_HORIZ_DOWN"
#####
$EVENT_SCROLL_DOWN
#####
fi
#else
#echo "Scroll vert [" $device "/" $vert "]"
fi
}
count=0
function thumbCommand(){
device=$1;
if [ ${count} = 6 ]; then
echo "BTN_THUMB"
######
$EVENT_THUMB
######
count=0
fi
}
function parseEventLine(){
if [ $# = 0 ]; then
return
fi
device=$1
action=$2
if [ ${action} = "POINTER_BUTTON" ]; then
button=$4
key_state=$6
pressCommand ${device} ${button} ${key_state}
elif [ ${action} = "POINTER_SCROLL_WHEEL" ]; then
vert=$5
horiz=$7
scrollCommand ${device} ${vert} ${horiz}
elif [ ${action} = "KEYBOARD_KEY" ]; then
thumbCommand ${device}
#elif [ ${action} = "POINTER_MOTION" ]; then
# echo "POINTER_MOTION"
#else
# echo "Unknown action"
fi
}
function mapDevice(){
device=$1
if [ -e $1 ]; then
echo "mapDevice() ["$device"]"
while read line; do
parseEventLine ${line}
done < <(stdbuf -oL libinput debug-events --device ${device} & )
else
echo "Stream $1 does not exist"
#return;
fi
}
echo "Scan device"
readarray -t devices <<<$(libinput list-devices | grep pointer -B4 | grep "Logitech MX Master 3" -A1 | grep -o '/dev/input/event[0-9]*')
for device in ${devices[@]}; do
( mapDevice ${device} ) &
done
wait