amiga-bootcamp/10_devices/gameport.md
Ilia Sharin 21751c0025 docs(amiga): complete AmigaOS 3.1/3.2 developer reference — 172 files across 17 sections
Comprehensive technical documentation covering:
- Hardware: OCS/ECS/AGA custom chip registers, Copper & Blitter deep dives
- Boot sequence: cold boot through startup-sequence
- Binary format: HUNK executable spec, relocation, debug info
- Linking & ABI: .fd files, LVO tables, register calling conventions
- Exec kernel: tasks, interrupts, memory, signals, semaphores
- AmigaDOS: file I/O, FFS/OFS layout, CLI/Shell scripting
- Graphics: planar bitmaps, Copper programming, HAM/EHB modes
- Intuition: screens, windows, IDCMP, BOOPSI
- Devices: trackdisk, SCSI, serial, timer, audio, keyboard
- Libraries: utility, expansion, IFFParse, locale, ARexx
- Networking: bsdsocket API, SANA-II, TCP/IP stack comparison
- Toolchain: GCC, vasm/vlink, SAS/C, NDK, debugging
- Reverse engineering: IDA/Ghidra setup, compiler fingerprints, case studies
- CPU & MMU: 68040/060 emulation libs, PMMU, cache management
- Driver development: SANA-II, Picasso96/RTG, AHI audio

All files include breadcrumb navigation. No local paths or proprietary content.
2026-04-23 12:17:35 -04:00

1.5 KiB

← Home · Devices

gameport.device — Joystick and Mouse

Overview

gameport.device reads joystick and mouse ports (active on port 1 for joystick, port 0 for mouse). Uses CIA and custom chip registers.


Controller Types

/* devices/gameport.h */
#define GPCT_ALLOCATED   -1   /* port is allocated */
#define GPCT_NOCONTROLLER 0   /* nothing connected */
#define GPCT_MOUSE       1   /* mouse */
#define GPCT_RELJOYSTICK 2   /* relative joystick (proportional) */
#define GPCT_ABSJOYSTICK 3   /* absolute joystick */

Reading a Joystick

struct IOStdReq *gp = CreateStdIO(port);
OpenDevice("gameport.device", 1, (struct IORequest *)gp, 0);

/* Set controller type: */
UBYTE type = GPCT_ABSJOYSTICK;
gp->io_Command = GPD_SETCTYPE;
gp->io_Data    = &type;
gp->io_Length  = 1;
DoIO((struct IORequest *)gp);

/* Set trigger conditions: */
struct GamePortTrigger trigger = {
    GPTF_UPKEYS | GPTF_DOWNKEYS,  /* report buttons */
    10000,   /* X delta timeout */
    10000,   /* Y delta timeout */
    1, 1     /* X/Y delta threshold */
};
gp->io_Command = GPD_SETTRIGGER;
gp->io_Data    = &trigger;
gp->io_Length  = sizeof(trigger);
DoIO((struct IORequest *)gp);

/* Read events: */
struct InputEvent ie;
gp->io_Command = GPD_READEVENT;
gp->io_Data    = &ie;
gp->io_Length  = sizeof(ie);
DoIO((struct IORequest *)gp);
/* ie.ie_Code, ie.ie_position.ie_xy give button/direction */

CloseDevice((struct IORequest *)gp);

References

  • NDK39: devices/gameport.h