sylware / nyanlinux (public) (License: AFFERO GPLv3) (since 2019-09-09) (hash sha1)
scripts for a lean, from scratch, amd hardware, linux distro

/files/rival110 (62a7ad36b7d8377733fb9fe21b89cb33333e4c2a) (3483 bytes) (mode 100755) (type blob)

#!/bin/sh

dpi_to_hex()
{
	case $2 in
	40) eval $1=00;;
	80) eval $1=01;;
	120) eval $1=02;;
	160) eval $1=03;;
	200) eval $1=04;;
	240) eval $1=05;;
	280) eval $1=06;;
	320) eval $1=07;;
	360) eval $1=08;;
	400) eval $1=09;;
	440) eval $1=0a;;
	480) eval $1=0b;;
	520) eval $1=0c;;
	560) eval $1=0d;;
	600) eval $1=0e;;
	640) eval $1=0f;;
	680) eval $1=10;;
	720) eval $1=11;;
	760) eval $1=12;;
	800) eval $1=13;;
	840) eval $1=14;;
	880) eval $1=15;;
	920) eval $1=16;;
	960) eval $1=17;;
	1000) eval $1=18;;
	1040) eval $1=19;;
	1080) eval $1=1a;;
	1160) eval $1=1b;;
	1200) eval $1=1c;;
	1240) eval $1=1d;;
	1280) eval $1=1e;;
	1320) eval $1=1f;;
	1360) eval $1=20;;
	1400) eval $1=21;;
	1440) eval $1=22;;
	1480) eval $1=23;;
	1520) eval $1=24;;
	1560) eval $1=25;;
	1600) eval $1=26;;
#... can do way more
	*)
		printf "\nERROR:invalid dpi (40-1600/40 increment)\n"
		exit 1
		;;
	esac
}

effect_to_hex()
{
	case $effect in
	steady) effect=01;;
	slow) effect=02;;
	breath) effect=03;;
	pulsing) effect=04;;
	*)
		printf "\nERROR:invalid effect (steady|slow|breath|pulsing)\n"
		exit 1
		;;
	esac
}

# not implemented, because factory default value is ok
# set polling rate in Hz:
# command=04 00
# suffix=00 00 00 00 00 00
# values=
#	125 Hz=04
#	250 Hz=03
#	500 Hz=02
#	1000 Hz=02 (factory default)
#
# not implemented, because no use for it
# button 6 (wheel button) action:
# command=0b
# suffix=00 00 00 00 00 00 00
# values=
#       default=00
# 	os=01

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"
if test $# -eq 0; then
	echo $USAGE
	exit 0
fi

# vendor_id=0x1038
# product_id=0x1729
for l in /sys/class/hidraw/*; do
	if readlink -f $l | egrep '1038:1729' >/dev/null 2>&1; then
		rival110=/dev/$(basename $l)
		break
	fi
done

if test "${rival110-unset}" = unset; then
	echo ERROR:unable to locate a rival110
	exit 1
else
	echo $rival110
fi

while test $# -ne 0; do
	case $1 in
		-c)
			if test "$2" = ""; then
				echo missing rgb_hex
				exit 1
			fi
			rgb_hex=$2
			shift 2
			;;
		-s1)
			if test "$2" = ""; then
				echo missing sensitivity 1
				exit 1
			fi
			sensitivity_1=$2
			shift 2
			;;
		-s2)
			if test "$2" = ""; then
				echo missing sensitivity 2
				exit 1
			fi
			sensitivity_2=$2
			shift 2
			;;
		-e)
			if test "$2" = ""; then
				echo missing effect
				exit 1
			fi
			effect=$2
			shift 2
			;;
		-s)
			save=yes
			shift
			;;
		*)
			echo ignoring $1
			shift
			;;
	esac
done

# each command is padded to 9 bytes
if test "${rgb_hex-unset}" != unset; then
	echo "rgb_hex=$rgb_hex";
	cmd_hex=0500${rgb_hex}00000000
fi
if test "${sensitivity_1-unset}" != unset; then
	printf "sensitivity_1=$sensitivity_1 dpi"
	dpi_to_hex sensitivity_1 $sensitivity_1
	echo "/hexcode=$sensitivity_1"
	cmd_hex=${cmd_hex}0301${sensitivity_1}000000000000
fi
if test "${sensitivity_2-unset}" != unset; then
	printf "sensitivity_2=$sensitivity_2 dpi"
	dpi_to_hex sensitivity_2 $sensitivity_2
	echo "/hexcode=$sensitivity_2"
	cmd_hex=${cmd_hex}0302${sensitivity_2}000000000000
fi
if test "${effect-unset}" != unset; then
	printf "effect=$effect"
	effect_to_hex
	echo "/hexcode=$effect"
	cmd_hex=${cmd_hex}0700${effect}000000000000
fi
# must be last for an obvious reason
if test "${save-unset}" != unset; then
	echo "****will save settings in mouse persistent memory****"
	cmd_hex=${cmd_hex}090000000000000000
fi
printf $cmd_hex | xxd -r -p >$rival110


Mode Type Size Ref File
100644 blob 5 8eba6c8dd4dcaf6166bd22285ed34625f38a84ff .gitignore
100755 blob 1587 57fa4264b9ee0ae0a6f678f2527a05d3b22dda78 00-bootstrap-build.sh
100755 blob 848 a30f443bf405d56682efe3b4c5d3a19d5f7eb45d 01-re-bootstrap-build.sh
100644 blob 2142 f19c2d6b293244bb11a3f74ee77c10675cadc7d6 INSTALL
100644 blob 30 c9b735fa1332286f4b3f5f81fa10527fd7506b6e LICENSE
040000 tree - 169c9f0dee844f98b3123398bc664738b05292a1 builders
100644 blob 1773 ef1551089a803bde37e36edc8d61bb819d06f793 conf.bootstrap.sh
100644 blob 479 8cc15efe46965ac7750fe304460f5a2b0aa4201c conf.sh
040000 tree - 120fb2d034cb100ec077f85a9160bb38c059b440 files
100755 blob 356 8fb8be28ac72f7214b59934b9f74a682665f2d32 pkg-build
100644 blob 22800641 e9e6291054c857401f6835c728f31541dae4311e steam.tar.bz2
100644 blob 173 2047af328b22f9d146585cd9e759edbc18122250 utils.sh
040000 tree - 8e23f551092a35f82b37129dd08c35c4d313c17b x64
040000 tree - b7a22de7f5cbd97650dd45412ef7d4246e395eb8 x86
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/nyanlinux

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/nyanlinux

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/nyanlinux

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main