9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] joystick support docs
@ 2021-08-31 22:54 qwx
  2021-09-01  5:58 ` unobe
  0 siblings, 1 reply; 13+ messages in thread
From: qwx @ 2021-08-31 22:54 UTC (permalink / raw)
  To: 9front

diff 6c9462710539bd35ae5c51de27e7894522683bd7 uncommitted
--- /tmp/diff100000014803
+++ b/rc/bin/joy
@@ -1,0 +1,39 @@
+#!/bin/rc
+# usage: nusb/joy epX.Y | joy [N]
+~ $#* 0 && *=''
+awk -safe -v 'joy='$1 '
+	/^axis 0 0/   { k[0] = "left " }
+	/^axis 0 255/ { k[0] = "right " }
+	/^axis 0 128/ { k[0] = "" }
+
+	/^axis 1 0/   { k[1] = "up " }
+	/^axis 1 255/ { k[1] = "down " }
+	/^axis 1 128/ { k[1] = "" }
+
+	/^down 1$/ { k[3] = "b " }
+	/^down 5$/ { k[2] = "a " }
+	/^down 6$/ { k[8] = "x " }
+	/^down 2$/ { k[9] = "y " }
+	/^down 3$/ { k[4] = "control " }
+	/^down 4$/ { k[5] = "start " }
+	/^down 7$/ { k[6] = "l1 " }
+	/^down 8$/ { k[7] = "r1 " }
+
+	/^up 1$/ { k[3] = "" }
+	/^up 5$/ { k[2] = "" }
+	/^up 6$/ { k[8] = "" }
+	/^up 2$/ { k[9] = "" }
+	/^up 3$/ { k[4] = "" }
+	/^up 4$/ { k[5] = "" }
+	/^up 7$/ { k[6] = "" }
+	/^up 8$/ { k[7] = "" }
+
+	{
+		if(joy != "")
+			printf "joy%s ", joy
+		for(i in k)
+			printf k[i]
+		printf "\n"
+		fflush
+	}
+'
--- a/sys/man/1/atari
+++ b/sys/man/1/atari
@@ -46,6 +46,9 @@
 .TP
 .B -x
 Scale the screen to a given factor regardless of the window's size.
+.PP
+A joystick may be used to play the emulator via
+.IR joy (1).
 .SH SOURCE
 .B /sys/src/games/2600
 .SH BUGS
--- /tmp/diff100000015479
+++ b//sys/man/1/joy
@@ -1,0 +1,45 @@
+.TH MUS 1
+.SH NAME
+joy \- joystick input for games
+.SH SYNOPSIS
+.B joy
+[
+.I player
+]
+.SH DESCRIPTION
+.I Joy
+interprets input from a USB joystick device
+(see
+.IR nusb (4))
+to pass it on to a console emulator
+as a string of controller keys
+which are pressed down.
+.PP
+The optional
+.B player
+argument specifies a player number
+for those emulators that support it.
+It should be an integer equal to 1 or greater.
+Currently only players 1 and 2 are supported.
+.PP
+Note that each USB controller has its own mappings
+and the program may have to be modified
+to use its own key id's.
+.SH EXAMPLES
+Use USB device 10 as a joystick
+for the player number 1's controller
+with the Nintendo Entertainment System (NES) emulator:
+.IP
+.EX
+% nusb/joy /dev/usb/ep10.0 | joy 1 | games/nes -a rom.nes
+.EE
+.SH "SEE ALSO"
+.IR atari (1),
+.IR nintendo (1),
+.IR sega (1),
+.IR nusb (4)
+.SH SOURCE
+.B /rc/bin/joy
+.SH HISTORY
+.I Joy
+first appeared in 9front (June, 2014).
--- a/sys/man/1/nintendo
+++ b/sys/man/1/nintendo
@@ -134,6 +134,11 @@
 .TP
 .B -m
 Enable mouse emulation using system mouse. Mouse button 1 (left button) engages the SNES left mouse button. Mouse button 3 (right button) engages the SNES right mouse button. Holding down mouse button 2 (middle button) disengages the SNES mouse entirely so that the Plan 9 cursor offset can be adjusted to align with the SNES cursor.
+.PP
+Each of these emulators support the use of joysticks via
+.IR joy (1).
+.I Nes
+also supports selecting the joystick for either player 1 or 2.
 .SH SOURCE
 .B /sys/src/games/gb
 .br
--- a/sys/man/1/sega
+++ b/sys/man/1/sega
@@ -44,6 +44,9 @@
 .TP
 .B -x
 Scale the screen to a given factor regardless of the window's size.
+.PP
+Each of these emulators support the use of joysticks via
+.IR joy (1).
 .SH SOURCE
 .B /sys/src/games/md
 .SH BUGS
--- a/sys/man/4/nusb
+++ b/sys/man/4/nusb
@@ -35,6 +35,12 @@
 ]
 .I devid
 .PP
+.B nusb/joy
+[
+.B -d
+]
+.I devid
+.PP
 .B nusb/serial
 [
 .B -d
@@ -135,6 +141,27 @@
 Mouse events are sent to
 .BR /dev/mousein
 in the same way.
+.SS Joysticks
+.I Joy
+parses data packets from a given endpoint and prints back
+any changes in the device's axes or buttons.
+Buttons are identified via an integer id.
+.PP
+Directional buttons are reported as axes
+with 3 positions:
+.IR 0 ,
+.IR 128 ,
+and
+.I 255
+for left (or up), center and right (or down) respectively.
+Messages are in the form \fIaxis id position\fR.
+.PP
+On/off buttons are reported as either
+.I down
+or
+.I up
+respectively.
+Messages are in the form \fIdown\fB|\fIup id\fR.
 .SS Disks
 .I Disk
 configures and manages USB mass storage devices. It
@@ -239,6 +266,7 @@
 .SH SOURCE
 .B /sys/src/cmd/nusb
 .SH "SEE ALSO"
+.IR joy (1),
 .IR audio (3),
 .IR ether (3),
 .IR mouse (3),
@@ -248,6 +276,9 @@
 .IR shr (3),
 .IR nusbrc (8),
 .IR kbdfs (8)
+.SH HISTORY
+.I Joy
+first appeared in 9front (March, 2014).
 .SH BUGS
 The various device drivers are generic USB drivers and
 may work only for certain devices of each class.
--- a/sys/src/games/nes/joynes
+++ /tmp/diff100000014822
@@ -1,33 +1,0 @@
-#!/bin/rc
-# run as "nusb/joy epX.Y | joynes N", where N=[1,2]
-
-awk -safe -v 'joy='$1 '
-	BEGIN { k[0] = "" }
-
-	/^axis 0 0/   { k[0] = "left " }
-	/^axis 0 255/ { k[0] = "right " }
-	/^axis 0 128/ { k[0] = "" }
-
-	/^axis 1 0/   { k[1] = "up " }
-	/^axis 1 255/ { k[1] = "down " }
-	/^axis 1 128/ { k[1] = "" }
-
-	/^down 7$/ { k[3] = "b " }
-	/^down 8$/ { k[2] = "a " }
-	/^down 1$/ { k[4] = "control " }
-	/^down 2$/ { k[5] = "start " }
-
-	/^up 7$/ { k[3] = "" }
-	/^up 8$/ { k[2] = "" }
-	/^up 1$/ { k[4] = "" }
-	/^up 2$/ { k[5] = "" }
-
-	{
-		if(joy != "")
-			printf "joy%s ", joy
-		for(i = 0; i <= 5; i++)
-			printf k[i]
-		printf "\n"
-		fflush
-	}
-'

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [9front] joystick support docs
@ 2021-09-01 22:58 Lyndon Nerenberg (VE7TFX/VE6BBM)
  2021-09-01 23:31 ` qwx
  0 siblings, 1 reply; 13+ messages in thread
From: Lyndon Nerenberg (VE7TFX/VE6BBM) @ 2021-09-01 22:58 UTC (permalink / raw)
  To: 9front

Shouldn't that

  .TH MUS

be

  .TH JOY

?

--lyndon

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-02 18:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 22:54 [9front] joystick support docs qwx
2021-09-01  5:58 ` unobe
2021-09-01 10:58   ` Stuart Morrow
2021-09-01 21:30     ` unobe
2021-09-01 22:53     ` ori
2021-09-02  0:31       ` Lyndon Nerenberg (VE7TFX/VE6BBM)
2021-09-02  5:02         ` unobe
2021-09-02 12:17       ` Stuart Morrow
2021-09-02 18:09     ` Kurt H Maier
2021-09-01 22:54   ` qwx
2021-09-02  4:59     ` unobe
2021-09-01 22:58 Lyndon Nerenberg (VE7TFX/VE6BBM)
2021-09-01 23:31 ` qwx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).