ref: 175aafdb14fdd717ca6d6591211b36182fa5fd38
parent: cb397dbce3f959f42ee8a45658e4693ad0c90c03
author: qwx <qwx@sciops.net>
date: Wed Jan 7 05:49:37 EST 2026
add forked dmus and joy scripts
--- /dev/null
+++ b/rc/bin/dmus
@@ -1,0 +1,17 @@
+#!/bin/rc -b
+#sf2=sc55.v3.7.sf2
+sf2=patch93.sc-55.sf2
+# midipipe -r >/dev/usb/ep10.2/data
+if(test -f /srv/midi)
+ c=( '{' games/mid2s -m '|' tee -a /srv/midi '|' dd -if /dev/zero '}' )+if not if(test -f /lib/midi/sf2/$sf2)
+ c=(games/sf2mid /lib/midi/sf2/$sf2)
+if not if(test -f /mnt/wad/genmidi)
+ c=(games/dmid '|' games/opl3)
+if not
+ c=(games/midi -c)
+if(~ `{file -m $1} audio/mus)+ c=(games/mus '<' $1 '|' $c)
+if not
+ c=('<' $1 $c)+eval $c
--- /dev/null
+++ b/rc/bin/joy
@@ -1,0 +1,78 @@
+#!/bin/rc
+# usage: nusb/joy epX.Y | joy [N]
+~ $#* 0 && *=''
+awk -safe -v 'joy='$1 '
+ function cat(f, v){+ getline v < f
+ return v
+ }
+ BEGIN{+ map[1] = "b"
+ map[2] = "a"
+ map[3] = "y"
+ map[4] = "x"
+ map[5] = "l1"
+ map[6] = "r1"
+ map[7] = "control"
+ map[8] = "start"
+ map[12] = "up"
+ map[13] = "down"
+ map[14] = "left"
+ map[15] = "right"
+ if(joy != "")
+ joy = "joy" joy
+ }
+
+ /^devid/{+ l = cat("/lib/joy/"$2)+ if(length(l) == 0)
+ next
+ split(l, b, ",")
+ delete map
+ for(i in b){+ if(length(b[i]) != 0)
+ map[i] = b[i]
+ }
+ }
+
+ /^(up|down)/{+ if(!($2 in map))
+ next
+ if($1 == "down")
+ k[$2] = ""
+ else if($1 == "up")
+ delete k[$2]
+ }
+
+ /^axis [01]+/{+ if($2 == 1){+ if($4 <= 0.25)
+ a["X"] = "down"
+ else if($4 >= 0.75)
+ a["X"] = "up"
+ else
+ delete a["X"]
+ }else if($2 == 0){+ if($4 <= 0.25)
+ a["Y"] = "left"
+ else if($4 >= 0.75)
+ a["Y"] = "right"
+ else
+ delete a["Y"]
+ }
+ }
+
+ /^(up|down|axis [01]+)/{+ s = joy
+ for(i in k){+ printf "%s%s", s, map[i]
+ s = " "
+ }
+ for(i in a){+ printf "%s%s", s, a[i]
+ s = " "
+ }
+ printf "\n"
+ fflush
+ }
+'
--
⑨