#!/bin/rc # run as "nusb/joy epX.Y | ps3joy N", where N=[1,2] awk -safe -v 'joy='$1 ' BEGIN { k[0] = "" } /^axis 0/ { if($3 < 25) k[0] = "left " if($3 > 100 && $3 < 160) k[0] = "" if($3 > 225) k[0] = "right " } /^axis 1/ { if($3 < 25) k[1] = "up " if($3 > 100 && $3 < 160) k[1] = "" if($3 > 225) k[1] = "down " } /^down 5$/ { k[1] = "up " } /^up 5$/ { k[1] = "" } /^down 7$/ { k[1] = "down " } /^up 7$/ { k[1] = "" } /^down 8$/ { k[0] = "left " } /^up 8$/ { k[0] = "" } /^down 6$/ { k[0] = "right " } /^up 6$/ { k[0] = "" } /^down 13$/ { k[2] = "x " } /^down 14$/ { k[3] = "a " } /^down 15$/ { k[4] = "b " } /^down 16$/ { k[5] = "y " } /^down 4$/ { k[6] = "start " } /^down 1$/ { k[7] = "control " } /^down 9$/ { k[8] = "l1 " } /^down 10$/ { k[9] = "r1 " } /^up 13$/ { k[2] = "" } /^up 14$/ { k[3] = "" } /^up 15$/ { k[4] = "" } /^up 16$/ { k[5] = "" } /^up 4$/ { k[6] = "" } /^up 1$/ { k[7] = "" } /^up 9$/ { k[8] = "" } /^up 10$/ { k[9] = "" } { if(joy != "") printf "joy%s ", joy for(i = 0; i <= 9; i++) printf k[i] printf "\n" fflush } '