JOY(4)
π joy(4) β game adapter driver π
okay so real talk: this is the joy man page from the Kernel Interfaces Manual, section 4 (kernel interfaces, bestie, that's the driver zone π). Let's get into it β¨
π SYNOPSIS
joy* at acpi?
joy* at eap?
joy* at eso?
joy0 at isa? port 0x201
joy* at isapnp?
joy* at ofisa?
joy* at pci?
joy* at pnpbios? index ?
that's the whole vibe check for how this thing attaches, no cap π«Ά
β¨ DESCRIPTION β¨
So this driver gives you access to the game adapter. And the cutest part? The lower bit in the minor device number picks which joystick you're talking to: 0 is the first joystick, 1 is the second. literally that's it, that's the whole selection mechanism π
The game control adapter lets you hook up to two joysticks to the system. The adapter plus the driver work together to convert the present resistive value into a relative joystick position. The way it works (and this is iconic honestly): on receipt of an output signal, four timing circuits get started π and by figuring out how long it takes for the circuit to time-out (which is a function of the resistance), you can determine the paddle position. oh and side quest β the adapter could totally be used as a general purpose I/O card with four analog (resistive) inputs plus four digital input points. versatility queen π
π¦ the ioctl situation π¦
Apps may call ioctl(2) on a game adapter driver file descriptor to set and get the offsets of the two potentiometers and the maximum time-out value for the circuit. These ioctl(2) commands live in <machine/joystick.h> and currently are:
JOY_SETTIMEOUTβ sets the maximum time-out for the adapter β±οΈJOY_GETTIMEOUTβ returns the current maximum time-outJOY_SET_X_OFFSETβ sets an offset on X valueJOY_GET_X_OFFSETβ returns the current X offsetJOY_SET_Y_OFFSETβ sets an offset on Y valueJOY_GET_Y_OFFSETβ returns the current Y offset
All these commands take an integer parameter. periodt π
πΈ the struct, the moment, the icon πΈ
read(2) on the file descriptor returns a joystick structure:
struct joystick {
int x;
int y;
int b1;
int b2;
};
and here's what each field is giving:
xβ current X coordinate of the joystick (or position of paddle 1) π―yβ current Y coordinate of the joystick (or position of paddle 2)b1β current state of button 1 πb2β current state of button 2
The b1 and b2 fields in struct joystick are set to 1 if the corresponding button is down, and 0 otherwise. simple as that π
π the calibration lore (important) π
The x and y coordinates are supposed to be between 0 and 255 for a good joystick and a good adapter. but unfortunately β and this is the messy part β because of the hardware hack used to measure the position (by measuring the time needed to discharge an RC circuit made from the joystick's potentiometer and a capacitor on the adapter), calibration is needed to determine exactly what values get returned for a specific joystick/adapter combo. and ngl, incorrect hardware can yield negative values or values greater than 255 π
A typical calibration procedure uses the values returned at lower left, center and upper right positions of the joystick to compute the relative position.
β οΈ heads up bestie: this calibration is not part of the driver. you gotta do it yourself, the driver is not doing that labor π
π FILES
/dev/joy0β first joystick/dev/joy1β second joystick
π SEE ALSO
acpi(4), eap(4), eso(4), isa(4), isapnp(4), ofisa(4), pci(4), pnpbios(4)
go read those, iykyk π
π AUTHORS
Jean-Marc Zucconi wrote the FreeBSD driver. Matthieu Herrb ported it to NetBSD and wrote this manual page. legends only π«Άβ¨
and that's the page!! mwah π
this cutie came from the Debian folks, dated July 22, 2006 β yeah it's giving vintage but it still ate π₯ bye bestie, go calibrate your joystick πππ¦
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 1996 Matthieu Herrb
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms