aboutsummaryrefslogtreecommitdiff
path: root/scripts/set_rotation.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/set_rotation.sh')
-rwxr-xr-xscripts/set_rotation.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/set_rotation.sh b/scripts/set_rotation.sh
new file mode 100755
index 0000000..f3eb011
--- /dev/null
+++ b/scripts/set_rotation.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+rotation="${1}"
+
+if [ "$#" -ne 1 ]; then
+ printf "Usage: $0 [angle]\n"
+ exit 1
+fi
+
+rise=$(awk -v ang=$1 'BEGIN { print int( sin(ang*2*atan2(1,0)/180.0) * 2^31-1 + 0.5) }')
+run=$(awk -v ang=$1 'BEGIN { print int( cos(ang*2*atan2(1,0)/180.0) * 2^31-1 + 0.5) }')
+
+sudo su -c "echo ${rise} > /sys/module/hid/parameters/rise"
+sudo su -c "echo ${run} > /sys/module/hid/parameters/run"