From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RDNS_NONE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 29584 invoked from network); 1 Sep 2021 01:28:28 -0000 Received: from unknown (HELO 4ess.inri.net) (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 1 Sep 2021 01:28:28 -0000 Received: from wopr.sciops.net ([216.126.196.60]) by 4ess; Tue Aug 31 18:55:05 -0400 2021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sciops.net; s=20210706; t=1630450497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xfpEsmCgYxxnYO7HZ04IU12dY/2+BeG02F0EuuPRql4=; b=jc6NpsOVOaCcrS8Ht4mD1Fj4/QQOrIF8c+3VtipR79OhGaqZUj4ggQgDCyUAARmvzHdvaA EEf5ARxJ02q8sBQuhydjxreIEm+Pc0fdi9ExyWnyZWIZozG/ewngIuz0wZGv4TPbIOgLO+ pdzaE8WcGWfjQ+bysyo3R6tB04FUQkA= Received: by wopr.sciops.net (OpenSMTPD) with ESMTPSA id c15f4be3 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO) for <9front@9front.org>; Tue, 31 Aug 2021 15:54:56 -0700 (PDT) Message-ID: From: qwx Date: Wed, 01 Sep 2021 00:54:54 +0200 To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: blockchain-aware map/reduce STM method Subject: [9front] joystick support docs Reply-To: 9front@9front.org Precedence: bulk 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 - } -'