Commit Graph

1987 Commits

Author SHA1 Message Date
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
OV2 d7dc9acf2f win32: stop trying to send audio data after device removal 2022-02-14 01:05:57 +01:00
bearoso f1ac3dc6d3
Merge pull request #734 from realnc/fix-43-aspect-ratio-upstream
libretro: Fix 4:3 aspect ratio to actually be 4:3 regardless of cropping
2022-02-02 16:13:37 -06:00
Michael Buckley f73ef51014 Mac: Set marketing version to 1.61 2022-02-02 10:58:18 -08:00
Michael Buckley 68f536dcbe Revert "Mac: prefer integrated GPU"
This reverts commit cf1a5901fc.
2022-02-02 10:53:32 -08:00
Nikos Chantziaras 1d1140db1c
libretro: Fix 4:3 aspect ratio to actually be 4:3 regardless of cropping 2022-02-02 20:13:17 +02:00
BearOso 8b1f127404 Add scanline timing for Full Throttle Racing. 2022-01-31 19:47:21 -06:00
BearOso d4cec8eb2a Gtk: Wayland: Use older wayland API for compatibility. 2022-01-31 16:56:17 -06:00
BearOso 41fb9eb4c4 Set SRAM initialization to set whole buffer, not just a few bytes.
Add a TODO comment at allocation. These never change, so they should
ideally be static.
2022-01-31 16:39:04 -06:00
BearOso da23559f2f Gtk: Add wayland-client as wayland dep. 2022-01-31 16:32:27 -06:00
BearOso 8ed8fdab86 Update changes.txt. 2022-01-31 16:21:29 -06:00
BearOso 12e19abbe9 Unix: Regenerate configure. 2022-01-31 16:18:33 -06:00
BearOso 111b92ca58 Unix: xvideo: Prefer RGB then YUY2 then I420. 2022-01-31 16:15:42 -06:00
bearoso 951de39c87
Merge pull request #727 from cjacker/master
Add alsa sound output and I420 Xvideo image format support for unix CLI.
2022-01-31 16:10:44 -06:00
OV2 13d68ad3cc Update changes.txt 2022-01-31 17:59:50 +01:00
OV2 bdb27635e0 win32: fix frame advance hotkey no longer working after 25 days
(fixes #716)
2022-01-31 17:29:01 +01:00
BearOso f56b1e7668 Gtk: Wayland: Add idle inhibitor. 2022-01-30 21:23:33 -06:00
BearOso 2bc5302478 Add ability of FastROM hacks to use SuperFX. 2022-01-30 20:17:52 -06:00
BearOso a4efafbd2e libretro: Fix interaction with Blargg filter and hires. 2022-01-30 20:03:34 -06:00
BearOso 82891ce976 changes.txt: Add some unix port changes. 2022-01-30 18:40:32 -06:00
BearOso c8ffda83e7 Gtk: Set default background to starfield. 2022-01-30 18:34:51 -06:00
BearOso 71da4e3c07 Update changes.txt. 2022-01-30 18:30:11 -06:00
BearOso eb2c993a91 Update version and copyright for 1.61. 2022-01-30 17:52:50 -06:00
BearOso 34b6160805 pulseaudio: Fix potential stall with Pipewire
Pipewire allows very small buffer sizes. It's possible that Snes9x
will accumulate enough samples in fast-forward to exceed this.
Instead of waiting forever for the buffer capacity to free up, just
write the number of samples for the free space after one small wait.
2021-12-20 12:21:43 -06:00
OV2 a283596722
Merge pull request #728 from Jamiras/custom_frame_advance
fix custom key bind for frame advance
2021-12-13 21:40:10 +01:00
Jamiras 32f3f81a2c fix custom key bind for frame advance 2021-12-13 13:24:45 -07:00
Cjacker a57531b9f8 fix realloc error 2021-11-25 21:34:51 +08:00
Cjacker bd996da4af Add I420 Xvideo image format support, with both libyuv hardware acceleration and software conversion support. 2021-11-23 15:59:38 +08:00
Cjacker d65789edc4 Add alsa sound output support 2021-11-23 15:20:01 +08:00
Cjacker 64bf636b5c fix paddev[n] args 2021-11-23 15:18:41 +08:00
Michael Buckley cf1a5901fc Mac: prefer integrated GPU 2021-11-17 19:22:00 -08:00
Michael Buckley edc32fc0bd Mac: Implement emulation hack preferences. 2021-11-15 11:15:09 -08:00
qwertymodo 46f11f61da Add 128KByte SRAM support in cheats and netplay client 2021-08-25 10:12:11 -07:00
OV2 041108ddf2
Merge pull request #717 from ImmaturityRules/win10-sdk-fix
Fix Win10 SDK and v142 toolset build
2021-08-25 16:34:54 +02:00
Steve Sharples a2ac3b98b1 Fix Win10 SDK and vc142 toolset build 2021-08-24 18:30:55 +01:00
qwertymodo e66acceeda Add support for mapping more than 128KByte SRAM 2021-08-20 15:33:23 -07:00
OV2 9398d21e01 win32: specify filter scale for blargg rf (fixes #704) 2021-05-27 15:15:54 +02:00
BearOso 4811462f11 cheats: Fix of delete instead of free on strdup. 2021-05-15 11:33:27 -05:00
BearOso cf2d1bf791 Gtk: OpenGL: Fix non-PBO output path. 2021-05-15 11:23:12 -05:00
BearOso da4bd2a018 Gtk: Make sound driver check a little simpler. 2021-05-15 11:23:12 -05:00
Michael Buckley ebe96e91de Mac: attempt to fix a reproted crash 2021-04-25 20:43:09 -07:00
Michael Buckley 4b66a6a955 Mac: refactor preferences code, fix a couple connections, and add new icons 2021-04-25 17:44:40 -07:00
BearOso 8a5d29c4a9 memmap: Add a comment about the new hack detection. 2021-02-07 12:07:37 -06:00
BearOso a146093e4e memmap: Add heuristic to detect Earthbound hack.
Fixes issue #691.
2021-02-06 13:08:46 -06:00
OV2 cc7e028179 win32: poll joypads in hotkey handler if paused or stopped (#684) 2021-01-11 20:31:23 +01:00
Michael Buckley f7c6625d67 Mac: Restore Mouse, SuperScope and Justifier support 2020-12-28 21:13:09 -08:00
BearOso 364aa1ba5d Gtk: OpenGL: Use correct screen for fbconfig. 2020-11-04 13:11:28 -06:00
BearOso 77fb6ff958 Gtk: Unthread preferences creation. 2020-11-04 12:55:25 -06:00
BearOso 2bab4c41b1 Revert "Gtk: OpenGL: Try to ensure window is mapped."
This reverts commit c4a269b32a.
2020-11-04 12:54:44 -06:00
BearOso b4de90a0f1 Revert "Gtk: Reorder init."
This reverts commit a9a9b0fafb.
2020-11-04 12:41:55 -06:00