libICE: update and moved to /usr/lib
[nyanlinux.git] / files / rival110
blob62a7ad36b7d8377733fb9fe21b89cb33333e4c2a
1 #!/bin/sh
3 dpi_to_hex()
5 case $2 in
6 40) eval $1=00;;
7 80) eval $1=01;;
8 120) eval $1=02;;
9 160) eval $1=03;;
10 200) eval $1=04;;
11 240) eval $1=05;;
12 280) eval $1=06;;
13 320) eval $1=07;;
14 360) eval $1=08;;
15 400) eval $1=09;;
16 440) eval $1=0a;;
17 480) eval $1=0b;;
18 520) eval $1=0c;;
19 560) eval $1=0d;;
20 600) eval $1=0e;;
21 640) eval $1=0f;;
22 680) eval $1=10;;
23 720) eval $1=11;;
24 760) eval $1=12;;
25 800) eval $1=13;;
26 840) eval $1=14;;
27 880) eval $1=15;;
28 920) eval $1=16;;
29 960) eval $1=17;;
30 1000) eval $1=18;;
31 1040) eval $1=19;;
32 1080) eval $1=1a;;
33 1160) eval $1=1b;;
34 1200) eval $1=1c;;
35 1240) eval $1=1d;;
36 1280) eval $1=1e;;
37 1320) eval $1=1f;;
38 1360) eval $1=20;;
39 1400) eval $1=21;;
40 1440) eval $1=22;;
41 1480) eval $1=23;;
42 1520) eval $1=24;;
43 1560) eval $1=25;;
44 1600) eval $1=26;;
45 #... can do way more
47 printf "\nERROR:invalid dpi (40-1600/40 increment)\n"
48 exit 1
50 esac
53 effect_to_hex()
55 case $effect in
56 steady) effect=01;;
57 slow) effect=02;;
58 breath) effect=03;;
59 pulsing) effect=04;;
61 printf "\nERROR:invalid effect (steady|slow|breath|pulsing)\n"
62 exit 1
64 esac
67 # not implemented, because factory default value is ok
68 # set polling rate in Hz:
69 # command=04 00
70 # suffix=00 00 00 00 00 00
71 # values=
72 # 125 Hz=04
73 # 250 Hz=03
74 # 500 Hz=02
75 # 1000 Hz=02 (factory default)
77 # not implemented, because no use for it
78 # button 6 (wheel button) action:
79 # command=0b
80 # suffix=00 00 00 00 00 00 00
81 # values=
82 # default=00
83 # os=01
85 USAGE="Usage: $0 -c color(hex 3 bytes rrggbb) -s1 dpi1(200-7200/100 increment) -s2 dpi2(100-7200/100 increment) -e effect(steady|slow|breath|pulsing) -s"
86 if test $# -eq 0; then
87 echo $USAGE
88 exit 0
91 # vendor_id=0x1038
92 # product_id=0x1729
93 for l in /sys/class/hidraw/*; do
94 if readlink -f $l | egrep '1038:1729' >/dev/null 2>&1; then
95 rival110=/dev/$(basename $l)
96 break
98 done
100 if test "${rival110-unset}" = unset; then
101 echo ERROR:unable to locate a rival110
102 exit 1
103 else
104 echo $rival110
107 while test $# -ne 0; do
108 case $1 in
110 if test "$2" = ""; then
111 echo missing rgb_hex
112 exit 1
114 rgb_hex=$2
115 shift 2
117 -s1)
118 if test "$2" = ""; then
119 echo missing sensitivity 1
120 exit 1
122 sensitivity_1=$2
123 shift 2
125 -s2)
126 if test "$2" = ""; then
127 echo missing sensitivity 2
128 exit 1
130 sensitivity_2=$2
131 shift 2
134 if test "$2" = ""; then
135 echo missing effect
136 exit 1
138 effect=$2
139 shift 2
142 save=yes
143 shift
146 echo ignoring $1
147 shift
149 esac
150 done
152 # each command is padded to 9 bytes
153 if test "${rgb_hex-unset}" != unset; then
154 echo "rgb_hex=$rgb_hex";
155 cmd_hex=0500${rgb_hex}00000000
157 if test "${sensitivity_1-unset}" != unset; then
158 printf "sensitivity_1=$sensitivity_1 dpi"
159 dpi_to_hex sensitivity_1 $sensitivity_1
160 echo "/hexcode=$sensitivity_1"
161 cmd_hex=${cmd_hex}0301${sensitivity_1}000000000000
163 if test "${sensitivity_2-unset}" != unset; then
164 printf "sensitivity_2=$sensitivity_2 dpi"
165 dpi_to_hex sensitivity_2 $sensitivity_2
166 echo "/hexcode=$sensitivity_2"
167 cmd_hex=${cmd_hex}0302${sensitivity_2}000000000000
169 if test "${effect-unset}" != unset; then
170 printf "effect=$effect"
171 effect_to_hex
172 echo "/hexcode=$effect"
173 cmd_hex=${cmd_hex}0700${effect}000000000000
175 # must be last for an obvious reason
176 if test "${save-unset}" != unset; then
177 echo "****will save settings in mouse persistent memory****"
178 cmd_hex=${cmd_hex}090000000000000000
180 printf $cmd_hex | xxd -r -p >$rival110