OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Super Scope Input

SNES Super Scope support (port 2 only). More...

Macros

#define SSC_CURSOR   0x4000
#define SSC_FIRE   0x8000
#define SSC_NOISE   0x0100
#define SSC_OFFSCREEN   0x0200
#define SSC_PAUSE   0x1000
#define SSC_TURBO   0x2000

Functions

u16 scopeButtonsHeld (void)
 Buttons currently down — the same meaning as padHeld() and mouseButtonsHeld().
u16 scopeButtonsPressed (void)
 Get newly pressed buttons this frame.
u16 scopeButtonsRepeat (void)
 Buttons held past the hold delay, re-triggering every repeat delay (see scopeSetRepeatDelay()) — a keyboard-style auto-repeat.
void scopeCalibrate (void)
 Calibrate aim from a center-screen shot.
u16 scopeGetRawX (void)
 Get raw (uncalibrated) H position from PPU.
u16 scopeGetRawY (void)
 Get raw (uncalibrated) V position from PPU.
u16 scopeGetX (void)
 Get calibration-adjusted H position.
u16 scopeGetY (void)
 Get calibration-adjusted V position.
u8 scopeInit (void)
 Detect Super Scope on port 2.
u8 scopeIsConnected (void)
 Check if Super Scope is connected.
void scopeSetHoldDelay (u16 frames)
 Set hold delay (frames before hold triggers).
void scopeSetRepeatDelay (u16 frames)
 Set repeat delay (frames between repeat fires after hold).
u16 scopeSinceShot (void)
 Get frames since last detected shot.

Detailed Description

SNES Super Scope support (port 2 only).

The Super Scope is a light gun that uses the PPU H/V counter latch to determine aim position. It provides 4 buttons and 2 status flags.

Usage

// Detect and initialize Super Scope
if (scopeInit()) {
// Super Scope found on port 2!
}
// Calibration: ask user to fire at screen center
// Wait for fire...
// Main loop
while (1) {
u16 x = scopeGetX();
u16 y = scopeGetY();
// Shot fired!
}
}
void WaitForVBlank(void)
Wait for next VBlank period.
#define SSC_FIRE
Definition input.h:347
void scopeCalibrate(void)
Calibrate aim from a center-screen shot.
u16 scopeButtonsPressed(void)
Get newly pressed buttons this frame.
u16 scopeGetX(void)
Get calibration-adjusted H position.
u8 scopeInit(void)
Detect Super Scope on port 2.
u16 scopeGetY(void)
Get calibration-adjusted V position.
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53

Macro Definition Documentation

◆ SSC_CURSOR

#define SSC_CURSOR   0x4000

Cursor button

◆ SSC_FIRE

#define SSC_FIRE   0x8000

Fire button (trigger)

◆ SSC_NOISE

#define SSC_NOISE   0x0100

Noise flag (no signal)

◆ SSC_OFFSCREEN

#define SSC_OFFSCREEN   0x0200

Off-screen flag

◆ SSC_PAUSE

#define SSC_PAUSE   0x1000

Pause button

◆ SSC_TURBO

#define SSC_TURBO   0x2000

Turbo switch

Function Documentation

◆ scopeButtonsHeld()

u16 scopeButtonsHeld ( void )

Buttons currently down — the same meaning as padHeld() and mouseButtonsHeld().

Until 2026-09-22 this name returned the auto-repeat mask (now scopeButtonsRepeat()) and "currently down" had a name ending in Down (removed 2026-10-05): the one word had the opposite meaning on the third device. A caller that wanted the repeat behaviour from this name must move to scopeButtonsRepeat().

Returns
Button mask (SSC_FIRE, SSC_CURSOR, SSC_TURBO, SSC_PAUSE, SSC_OFFSCREEN, SSC_NOISE)

◆ scopeButtonsPressed()

u16 scopeButtonsPressed ( void )

Get newly pressed buttons this frame.

Returns
Button mask of buttons pressed this frame (edge detection)

◆ scopeButtonsRepeat()

u16 scopeButtonsRepeat ( void )

Buttons held past the hold delay, re-triggering every repeat delay (see scopeSetRepeatDelay()) — a keyboard-style auto-repeat.

Returns
Button mask of auto-repeating buttons (scopeButtonsHeld() until 2026-09-22)

◆ scopeCalibrate()

void scopeCalibrate ( void )

Calibrate aim from a center-screen shot.

Call this after the user fires at the center of the screen (128, 112). Computes calibration offsets: centerh = 128 - rawX, centerv = 112 - rawY. The NMI handler applies these offsets to all subsequent readings.

◆ scopeGetRawX()

u16 scopeGetRawX ( void )

Get raw (uncalibrated) H position from PPU.

Returns
Raw X coordinate from PPU H counter

◆ scopeGetRawY()

u16 scopeGetRawY ( void )

Get raw (uncalibrated) V position from PPU.

Returns
Raw Y coordinate from PPU V counter

◆ scopeGetX()

u16 scopeGetX ( void )

Get calibration-adjusted H position.

Returns
Adjusted X coordinate (0-255 visible range)

◆ scopeGetY()

u16 scopeGetY ( void )

Get calibration-adjusted V position.

Returns
Adjusted Y coordinate (0-223 visible range)

◆ scopeInit()

u8 scopeInit ( void )

Detect Super Scope on port 2.

Checks the auto-joypad device signature on port 2. If a Super Scope is found, enables reading in the NMI handler and sets default hold/repeat delays (60/20 frames).

Returns
1 if Super Scope detected, 0 if not

◆ scopeIsConnected()

u8 scopeIsConnected ( void )

Check if Super Scope is connected.

1 from a scopeInit() that found the Super Scope on port 2, until the NMI handler sees its signature disappear (unplugged); then 0 until the next scopeInit(). Unlike the mouse, a scope plugged in later is not detected on its own: call scopeInit() again.

Returns
1 if connected, 0 if not

◆ scopeSetHoldDelay()

void scopeSetHoldDelay ( u16 frames)

Set hold delay (frames before hold triggers).

Parameters
framesNumber of frames (default: 60 = 1 second at 60Hz)

◆ scopeSetRepeatDelay()

void scopeSetRepeatDelay ( u16 frames)

Set repeat delay (frames between repeat fires after hold).

Parameters
framesNumber of frames (default: 20)

◆ scopeSinceShot()

u16 scopeSinceShot ( void )

Get frames since last detected shot.

Returns
Number of frames since last PPU latch (shot detection)