File files/rival3 added (mode: 100755) (index 0000000..ada70b9) |
|
1 |
|
#!/bin/sh |
|
2 |
|
effects='rainbow-shift|breath-fast|breath|breath-slow|steady|rainbow-breath|disco' |
|
3 |
|
effect_to_hex() |
|
4 |
|
{ |
|
5 |
|
case $effect in |
|
6 |
|
rainbow-shift) effect=00;; |
|
7 |
|
breath-fast) effect=01;; |
|
8 |
|
breath) effect=02;; |
|
9 |
|
breath-slow) effect=03;; |
|
10 |
|
steady) effect=04;; |
|
11 |
|
rainbow-breath) effect=05;; |
|
12 |
|
disco) effect=06;; |
|
13 |
|
*) |
|
14 |
|
printf "\nERROR:invalid effect ($effects)\n" |
|
15 |
|
exit 1 |
|
16 |
|
;; |
|
17 |
|
esac |
|
18 |
|
} |
|
19 |
|
|
|
20 |
|
# not implemented, because factory default value is ok |
|
21 |
|
# set polling rate in Hz: |
|
22 |
|
# command=04 00 |
|
23 |
|
# suffix=00 00 00 00 00 00 |
|
24 |
|
# values= |
|
25 |
|
# 125 Hz=04 |
|
26 |
|
# 250 Hz=03 |
|
27 |
|
# 500 Hz=02 |
|
28 |
|
# 1000 Hz=01 (factory default) |
|
29 |
|
USAGE="Usage: $0 -z1 color(hex 3 bytes rrggbb) -z2 color(hex 3 bytes rrggbb) -z3 color(hex 3 bytes rrggbb) -logo color(hex 3 bytes rrggbb) -s dpi1,dpi2,dpi3,dpi4,dpi5(40-8500/40 increment) -e effect($effects) -save" |
|
30 |
|
if test $# -eq 0; then |
|
31 |
|
echo $USAGE |
|
32 |
|
exit 0 |
|
33 |
|
fi |
|
34 |
|
|
|
35 |
|
# vendor_id=0x1038 |
|
36 |
|
# product_id=0x1824 |
|
37 |
|
# product_id=0x182c, firmware v0.37.0.0 |
|
38 |
|
# endpoint index 3 (there are 4 endpoints) |
|
39 |
|
endpoint=0 |
|
40 |
|
for l in /sys/class/hidraw/*; do |
|
41 |
|
if readlink -f $l | egrep '1038:1824' >/dev/null 2>&1; then |
|
42 |
|
if test $endpoint -eq 3; then |
|
43 |
|
rival3=/dev/$(basename $l) |
|
44 |
|
break |
|
45 |
|
fi |
|
46 |
|
endpoint=$(($endpoint + 1)) |
|
47 |
|
elif readlink -f $l | egrep -i '1038:182c' >/dev/null 2>&1; then |
|
48 |
|
if test $endpoint -eq 3; then |
|
49 |
|
rival3=/dev/$(basename $l) |
|
50 |
|
break |
|
51 |
|
fi |
|
52 |
|
endpoint=$(($endpoint + 1)) |
|
53 |
|
fi |
|
54 |
|
done |
|
55 |
|
|
|
56 |
|
if test "${rival3-unset}" = unset; then |
|
57 |
|
echo ERROR:unable to locate a rival3 |
|
58 |
|
exit 1 |
|
59 |
|
else |
|
60 |
|
echo $rival3 |
|
61 |
|
fi |
|
62 |
|
|
|
63 |
|
while test $# -ne 0; do |
|
64 |
|
case $1 in |
|
65 |
|
-z1) |
|
66 |
|
if test "$2" = ""; then |
|
67 |
|
echo missing rgb_hex |
|
68 |
|
exit 1 |
|
69 |
|
fi |
|
70 |
|
rgb_hex_z1=$2 |
|
71 |
|
shift 2 |
|
72 |
|
;; |
|
73 |
|
-z2) |
|
74 |
|
if test "$2" = ""; then |
|
75 |
|
echo missing rgb_hex |
|
76 |
|
exit 1 |
|
77 |
|
fi |
|
78 |
|
rgb_hex_z2=$2 |
|
79 |
|
shift 2 |
|
80 |
|
;; |
|
81 |
|
-z3) |
|
82 |
|
if test "$2" = ""; then |
|
83 |
|
echo missing rgb_hex |
|
84 |
|
exit 1 |
|
85 |
|
fi |
|
86 |
|
rgb_hex_z3=$2 |
|
87 |
|
shift 2 |
|
88 |
|
;; |
|
89 |
|
-logo) |
|
90 |
|
if test "$2" = ""; then |
|
91 |
|
echo missing rgb_hex |
|
92 |
|
exit 1 |
|
93 |
|
fi |
|
94 |
|
rgb_hex_logo=$2 |
|
95 |
|
shift 2 |
|
96 |
|
;; |
|
97 |
|
-s) |
|
98 |
|
if test "$2" = ""; then |
|
99 |
|
echo missing sensitivities |
|
100 |
|
exit 1 |
|
101 |
|
fi |
|
102 |
|
sensitivities=$2 |
|
103 |
|
shift 2 |
|
104 |
|
;; |
|
105 |
|
-e) |
|
106 |
|
if test "$2" = ""; then |
|
107 |
|
echo missing effect |
|
108 |
|
exit 1 |
|
109 |
|
fi |
|
110 |
|
effect=$2 |
|
111 |
|
shift 2 |
|
112 |
|
;; |
|
113 |
|
-save) |
|
114 |
|
save=yes |
|
115 |
|
shift |
|
116 |
|
;; |
|
117 |
|
*) |
|
118 |
|
echo ignoring $1 |
|
119 |
|
shift |
|
120 |
|
;; |
|
121 |
|
esac |
|
122 |
|
done |
|
123 |
|
|
|
124 |
|
# each command is padded to 9 bytes |
|
125 |
|
if test "${rgb_hex_z1-unset}" != unset; then |
|
126 |
|
echo "rgb_hex_z1=$rgb_hex_z1"; |
|
127 |
|
cmd_hex=050001${rgb_hex_z1}64 |
|
128 |
|
fi |
|
129 |
|
if test "${rgb_hex_z2-unset}" != unset; then |
|
130 |
|
echo "rgb_hex_z2=$rgb_hex_z2"; |
|
131 |
|
cmd_hex=050002${rgb_hex_z2}64 |
|
132 |
|
fi |
|
133 |
|
if test "${rgb_hex_z3-unset}" != unset; then |
|
134 |
|
echo "rgb_hex_z3=$rgb_hex_z3"; |
|
135 |
|
cmd_hex=050003${rgb_hex_z3}64 |
|
136 |
|
fi |
|
137 |
|
if test "${rgb_hex_logo-unset}" != unset; then |
|
138 |
|
echo "rgb_hex_logo=$rgb_hex_logo"; |
|
139 |
|
cmd_hex=0500004${rgb_hex_logo}64 |
|
140 |
|
fi |
|
141 |
|
if test "${sensitivities-unset}" != unset; then |
|
142 |
|
printf "sensitivities = $sensitivities" |
|
143 |
|
IFS_SAVED="$IFS" |
|
144 |
|
IFS=',' |
|
145 |
|
dpi_n=0 |
|
146 |
|
sensitivities_rounded="/rounded_to =" |
|
147 |
|
for dpi in $sensitivities |
|
148 |
|
do |
|
149 |
|
dpi_step=$(printf "$dpi/40" | bc) |
|
150 |
|
dpi_rounded=$(printf "$dpi_step * 40" | bc) |
|
151 |
|
sensitivities_rounded="${sensitivities_rounded} ${dpi_rounded}" |
|
152 |
|
if test $dpi_rounded -lt 40; then |
|
153 |
|
printf "\n$dpi_rounded from $dpi is below 40\n" |
|
154 |
|
exit |
|
155 |
|
fi |
|
156 |
|
if test $dpi_rounded -gt 8500; then |
|
157 |
|
printf "\n$dpi_rounded from $dpi is above 8500\n" |
|
158 |
|
exit |
|
159 |
|
fi |
|
160 |
|
output=$(($dpi_step - 1)) |
|
161 |
|
output_hex=$(printf "%02x" $output) |
|
162 |
|
sensitivities_hex="${sensitivities_hex}$output_hex" |
|
163 |
|
dpi_n=$(printf "%02x" $(($dpi_n + 1))) |
|
164 |
|
done |
|
165 |
|
IFS="$IFS_SAVED" |
|
166 |
|
printf "$sensitivities_rounded" |
|
167 |
|
if test $dpi_n -gt 5; then |
|
168 |
|
printf "\ndpi preset count is above 5\n" |
|
169 |
|
exit |
|
170 |
|
fi |
|
171 |
|
echo "/hexcode = ${dpi_n}${sensitivities_hex}" |
|
172 |
|
cmd_hex=${cmd_hex}0b00${dpi_n}01${sensitivities_hex} |
|
173 |
|
fi |
|
174 |
|
if test "${effect-unset}" != unset; then |
|
175 |
|
printf "effect=$effect" |
|
176 |
|
effect_to_hex |
|
177 |
|
echo "/hexcode=$effect" |
|
178 |
|
cmd_hex=${cmd_hex}0600${effect} |
|
179 |
|
fi |
|
180 |
|
# must be last for an obvious reason |
|
181 |
|
if test "${save-unset}" != unset; then |
|
182 |
|
echo "****will save settings in mouse persistent memory****" |
|
183 |
|
cmd_hex=${cmd_hex}0900 |
|
184 |
|
fi |
|
185 |
|
printf "00:$cmd_hex\n" | xxd -r >$rival3 |