overlay: create a dedicated thread for polling hotkeys (#864)
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change Create a new thread that polls for the following hotkeys: * super exit (both alt+f4 and bound key) * coin insert * screenshot The goal is to make the capture of these more reliable, because before this PR it wasn't. ## Testing
This commit is contained in:
@@ -23,10 +23,7 @@
|
||||
#include "external/imgui/backends/imgui_impl_dx11.h"
|
||||
#include "overlay/imgui/impl_spice.h"
|
||||
|
||||
#include "games/io.h"
|
||||
#include "hooks/graphics/graphics.h"
|
||||
#include "launcher/launcher.h"
|
||||
#include "misc/eamuse.h"
|
||||
#include "util/utils.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -149,26 +146,12 @@ void try_create_overlay(IDXGISwapChain *swapchain) {
|
||||
device->Release();
|
||||
}
|
||||
|
||||
// rising-edge screenshot hotkey poll (mirrors d3d9 backend behaviour).
|
||||
void poll_screenshot_hotkey() {
|
||||
static bool s_down = false;
|
||||
auto buttons = games::get_buttons_overlay(eamuse_get_game());
|
||||
const bool pressed = buttons
|
||||
&& (!overlay::OVERLAY || overlay::OVERLAY->hotkeys_triggered())
|
||||
&& GameAPI::Buttons::getState(RI_MGR,
|
||||
buttons->at(games::OverlayButtons::Screenshot));
|
||||
if (pressed && !s_down) {
|
||||
graphics_screenshot_trigger();
|
||||
}
|
||||
s_down = pressed;
|
||||
}
|
||||
|
||||
void pump_overlay(IDXGISwapChain *swapchain) {
|
||||
if (!overlay::OVERLAY || !overlay::OVERLAY->uses_swapchain(swapchain)) {
|
||||
return;
|
||||
}
|
||||
|
||||
poll_screenshot_hotkey();
|
||||
graphics_poll_screenshot_hotkey();
|
||||
|
||||
// size imgui to the backbuffer (not window client). dxgi may upscale
|
||||
// a small backbuffer into a larger client rect; without this override
|
||||
|
||||
@@ -1522,7 +1522,7 @@ void graphics_d3d9_on_present(
|
||||
wintouchemu::update();
|
||||
}
|
||||
|
||||
graphics_d3d9_poll_screenshot_hotkey();
|
||||
graphics_poll_screenshot_hotkey();
|
||||
graphics_d3d9_process_screenshot_and_capture(device, SUB_SWAP_CHAIN);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,9 @@
|
||||
#endif
|
||||
|
||||
#include "avs/game.h"
|
||||
#include "games/io.h"
|
||||
#include "hooks/graphics/graphics.h"
|
||||
#include "launcher/launcher.h"
|
||||
#include "misc/clipboard.h"
|
||||
#include "misc/eamuse.h"
|
||||
#include "overlay/notifications.h"
|
||||
#include "overlay/overlay.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/libutils.h"
|
||||
#include "util/logging.h"
|
||||
@@ -240,21 +236,6 @@ static void save_screenshot(
|
||||
}
|
||||
}
|
||||
|
||||
void graphics_d3d9_poll_screenshot_hotkey() {
|
||||
static bool trigger_last = false;
|
||||
auto buttons = games::get_buttons_overlay(eamuse_get_game());
|
||||
if (buttons && (!overlay::OVERLAY || overlay::OVERLAY->hotkeys_triggered()) &&
|
||||
GameAPI::Buttons::getState(RI_MGR, buttons->at(games::OverlayButtons::Screenshot)))
|
||||
{
|
||||
if (!trigger_last) {
|
||||
graphics_screenshot_trigger();
|
||||
}
|
||||
trigger_last = true;
|
||||
} else {
|
||||
trigger_last = false;
|
||||
}
|
||||
}
|
||||
|
||||
static std::optional<BackbufferCopy> acquire_backbuffer_copy(
|
||||
IDirect3DDevice9 *device, IDirect3DSwapChain9 *sub_swap_chain, int screen) {
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
void graphics_d3d9_poll_screenshot_hotkey();
|
||||
|
||||
void graphics_d3d9_process_screenshot_and_capture(
|
||||
IDirect3DDevice9 *device,
|
||||
IDirect3DSwapChain9 *sub_swap_chain);
|
||||
|
||||
Reference in New Issue
Block a user