Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
Go to file
Jean Raby cdbf783fc4 gtk: Support adding/removing joysticks at runtime
Reworked how/where SDL events are polled:
  - poll_joystick_events is now a static member of JoyDevice so it can be
    called from outside when needed (preference window for config and
    caliration).
  - S9xProcessEvents calls JoyDevice::poll_joystick_events directly so
    events are polled when no joysticks are attached.
  - JoyDevice::poll_joystick_events handles SDL_JOYDEVICE{ADDED,REMOVED}
    events.
  - Individual JoyDevice no longer call poll_joystick_events from
    get_events.

Reworked how attached joysticks are maintained in Snes9xConfig:
  - Use a map for joysticks keyed on SDL JoystickID (instance id in sdl
    parlance), which is stable while a joystick is attached instead of
    an array keyed on device_index.
    The instance id is what poll_joystick_events gets with every
    event (except for SDL_JOYDEVICEADDED which gets a device_index...)
    Instance id is an incrementing int starting from 0, they are never reused.
    i.e. each attach/dettach/attach cycle yields a new id.
    Whereas device index are reused and can "move".
  - On SDL_JOYDEVICEADDED the joystick is handed a "joynum", that is, an
    int from 0 to NUM_JOYPADS-1. A new joystick always get the lowest
    available joynum.
    (joynum was already a member of JoyDevice but wasn't initialized,
    this seemed like a proper way to use it.)
  - On SDL_JOYDEVICEREMOVED, the joystick associated with the instance
    id is simply removed from the map.

All this allows for the following behaviors.
It is possible to start without any joystick, add one joystick and it works.
(disconnect/reconnect cycles with a single joystick also work)

Joystick numbers are "stable" while they remain connected. For example:
 - Start with joystick0 and joystick1 connected
 - if joystick0 is disconnected, joystick1 keeps its number and keeps
   working
 - if joystick0 (or any new joystick) is connected at this time,
   it gets to become joystick0

If all joysticks are disconnected while snes9x is running, the order of
the "reconnections" will determine the joystick number of each joystick.

I think there is room for improvement still, with regards to code
organization. For instance, there could be a "JoyDevices" class which
would handle all the attached JoyDevice. This would allow moving all the
"joystick_*" methods from Snes9xConfig to that new class, and
poll_joystick_events could also be moved there.
The functionality wouldn't change, but the intent/ownership would probably be clearer.
2022-02-17 11:02:53 -05:00
apu Fix out-of-bounds memory access. (Sour via byuu) 2019-08-01 13:07:44 -05:00
data Cheats: Use "name" instead of "description". Allow whitespace. 2018-06-04 10:29:46 -05:00
docs Update changes.txt. 2022-01-31 16:21:29 -06:00
filter Merge `FORCE_INLINE` macro to `alwaysinline` into port.h. 2019-04-08 01:07:16 +09:00
gtk gtk: Support adding/removing joysticks at runtime 2022-02-17 11:02:53 -05:00
jma Remove useless 'register' storage class. 2018-11-17 15:02:37 -06:00
libretro libretro: Fix 4:3 aspect ratio to actually be 4:3 regardless of cropping 2022-02-02 20:13:17 +02:00
macosx Mac: Set marketing version to 1.61 2022-02-02 10:58:18 -08:00
shaders Shaders: Use C++ style struct types. 2020-08-07 14:59:03 -05:00
unix Unix: Regenerate configure. 2022-01-31 16:18:33 -06:00
unzip Remove useless 'register' storage class. 2018-11-17 15:02:37 -06:00
vulkan Gtk: OpenGL: Fix non-PBO output path. 2021-05-15 11:23:12 -05:00
win32 win32: stop trying to send audio data after device removal 2022-02-14 01:05:57 +01:00
.cirrus.yml Update cirrus.yml to get all submodules. 2020-07-29 19:22:29 -05:00
.gitignore add temp osx files to .gitignore 2020-09-13 20:07:06 -04:00
.gitmodules Gtk: OpenGL: Fix non-PBO output path. 2021-05-15 11:23:12 -05:00
65c816.h Missed a couple. 2018-11-15 17:35:52 -06:00
LICENSE Update version and copyright for 1.61. 2022-01-30 17:52:50 -06:00
README.md Add Linux & FreeBSD X11 CI builds 2019-12-16 13:21:57 +06:00
appveyor.yml Update version and copyright for 1.61. 2022-01-30 17:52:50 -06:00
bml.cpp Trim data elements beginning with colons in bml. 2019-06-23 16:43:28 -05:00
bml.h C++ification of bml parser. 2019-06-02 19:09:52 -05:00
bsx.cpp Fix unused variables. 2018-11-17 15:27:53 -06:00
bsx.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
c4.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
c4.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
c4emu.cpp C4: Do the sign extend manually. 2019-02-12 22:27:36 -06:00
cheats.cpp Add 128KByte SRAM support in cheats and netplay client 2021-08-25 10:12:11 -07:00
cheats.h Add 128KByte SRAM support in cheats and netplay client 2021-08-25 10:12:11 -07:00
cheats2.cpp Add 128KByte SRAM support in cheats and netplay client 2021-08-25 10:12:11 -07:00
clip.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
compat.cpp Handle . in extension for _makepath. 2020-09-07 11:09:52 -05:00
conffile.cpp win32: fix compilation error in vs2019 2020-01-19 12:48:06 +09:00
conffile.h win32: fix compilation error in vs2019 2020-01-19 12:48:06 +09:00
controls.cpp Remove S9xChooseMovieFilename 2020-08-07 14:08:51 -05:00
controls.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
cpu.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
cpuaddr.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
cpuexec.cpp Fix Chou Aniki. Remove hack. 2019-03-09 17:16:54 -06:00
cpuexec.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
cpumacro.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
cpuops.cpp Fix Chou Aniki. Remove hack. 2019-03-09 17:16:54 -06:00
cpuops.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
crosshairs.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
crosshairs.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
debug.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
debug.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
display.h Remove S9xChooseFilename 2020-08-07 14:08:51 -05:00
dma.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dma.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp1.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp2.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp3.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
dsp4.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
font.h Add special S9xDisplayStringType to pass additional info. 2018-12-12 16:15:56 -06:00
fxdbg.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
fxemu.cpp Revert "SFX: Make SFX2 1/3 faster than 1.59.2." 2019-05-31 12:25:08 -05:00
fxemu.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
fxinst.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
fxinst.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
getset.h Add support for mapping more than 128KByte SRAM 2021-08-20 15:33:23 -07:00
gfx.cpp Remove S9xSetPalette 2020-08-07 14:08:51 -05:00
gfx.h Remove S9xSetPalette 2020-08-07 14:08:51 -05:00
globals.cpp Remove most of GFX_MULTI_FORMAT. 2019-03-07 17:14:51 -06:00
language.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
loadzip.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
logger.cpp Get rid of "ignore" warnings. 2018-11-18 12:03:14 -06:00
logger.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
memmap.cpp Add scanline timing for Full Throttle Racing. 2022-01-31 19:47:21 -06:00
memmap.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
messages.h BUildfix for PS3 - error: comma at end of enumerator list 2018-12-29 11:50:22 -06:00
missing.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
movie.cpp Fix some warnings. 2020-06-20 10:44:11 -05:00
movie.h Remove S9xChooseMovieFilename 2020-08-07 14:08:51 -05:00
msu1.cpp Restore MSU1_AUDIO_POS. 2019-04-17 12:27:16 -05:00
msu1.h Fix Windows build. Tweak XAudio a bit. 2019-02-09 16:46:08 -06:00
netplay.cpp Add 128KByte SRAM support in cheats and netplay client 2021-08-25 10:12:11 -07:00
netplay.h Merge pull request #428 from CapnCrinklepants/master 2019-03-09 18:14:50 -06:00
obc1.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
obc1.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
pixform.h Proper 16-bit color conversion. 2019-03-21 15:28:31 -05:00
port.h Fix some warnings. 2020-06-20 10:44:11 -05:00
ppu.cpp Fix Chou Aniki. Remove hack. 2019-03-09 17:16:54 -06:00
ppu.h Fix PPU blending with unoptimized change. 2019-03-06 19:00:29 -06:00
sa1.cpp SA1: Remove memory remapping at load state. 2020-06-07 15:38:01 -05:00
sa1.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sa1cpu.cpp Revert "Don't spin when SA1 is stopped." 2019-01-14 14:08:03 -06:00
sar.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
screenshot.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
screenshot.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sdd1.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sdd1.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sdd1emu.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sdd1emu.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
server.cpp Add support for mapping more than 128KByte SRAM 2021-08-20 15:33:23 -07:00
seta.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
seta.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
seta010.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
seta011.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
seta018.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
sha256.cpp (PS3) Buildfixes 2018-08-29 09:49:51 -05:00
sha256.h Add bml parser and sha256 sum support. 2018-04-24 16:16:22 -05:00
snapshot.cpp Increase SRAM size to 512KB 2020-03-31 06:35:29 -04:00
snapshot.h Add function to load only screenshot from snapshot file 2019-12-19 18:18:45 +01:00
snes9x.cpp Add a compat.cpp file for compatibility symbols. 2020-09-07 10:57:17 -05:00
snes9x.h Update version and copyright for 1.61. 2022-01-30 17:52:50 -06:00
spc7110.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
spc7110.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
spc7110dec.cpp Get rid of some more warnings 2019-02-23 15:01:59 +01:00
spc7110dec.h Get rid of some more warnings 2019-02-23 15:01:59 +01:00
spc7110emu.cpp Add support for Tengai Makyou Zero English patch mapping 2017-10-23 09:03:19 -07:00
spc7110emu.h Initial 1.52 import 2010-09-25 17:46:12 +02:00
srtc.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
srtc.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
srtcemu.cpp Initial 1.52 import 2010-09-25 17:46:12 +02:00
srtcemu.h Initial 1.52 import 2010-09-25 17:46:12 +02:00
statemanager.cpp Move statemanager to s9x folder, add rewind support to unix port 2012-03-29 15:31:41 +02:00
statemanager.h Move statemanager to s9x folder, add rewind support to unix port 2012-03-29 15:31:41 +02:00
stream.cpp Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
stream.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
tile.cpp Add explicit declaration of tile unit templates. 2020-08-07 15:36:03 -05:00
tile.h Use a license stub everywhere. 2018-11-15 17:31:39 -06:00
tileimpl-h2x1.cpp Fix Mode7 mosaic glitch from tile cleanup. 2019-10-10 17:59:16 -05:00
tileimpl-n1x1.cpp Fix Mode7 mosaic glitch from tile cleanup. 2019-10-10 17:59:16 -05:00
tileimpl-n2x1.cpp Fix Mode7 mosaic glitch from tile cleanup. 2019-10-10 17:59:16 -05:00
tileimpl.h Add explicit declaration of tile unit templates. 2020-08-07 15:36:03 -05:00

README.md

Snes9x

Snes9x - Portable Super Nintendo Entertainment System (TM) emulator

This is the official source code repository for the Snes9x project.

Please check the Wiki for additional information.

Nightly builds

Download nightly builds from continuous integration:

snes9x

OS status
Windows Status
Linux (GTK) Status
Linux (X11) Status
FreeBSD (X11) Status
macOS Status

libretro core

OS status
Linux/amd64 Status
Linux/i386 Status
Linux/armhf Status
Linux/armv7-neon-hf Status
Linux/arm64 Status
Android/arm Status
Android/arm64 Status
Emscripten Status
macOS/amd64 Status
Nintendo Wii Status
Nintendo Switch Status
Nintendo GameCube Status
PSP Status