Misc: Post-refactor cleanups
This commit is contained in:
@ -232,7 +232,6 @@ if(WIN32)
|
||||
elseif(APPLE)
|
||||
target_sources(util PRIVATE
|
||||
cocoa_tools.h
|
||||
cocoa_tools.mm
|
||||
metal_device.h
|
||||
metal_device.mm
|
||||
metal_stream_buffer.h
|
||||
|
||||
@ -3,9 +3,23 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
struct WindowInfo;
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
namespace CocoaTools {
|
||||
NSString* StringViewToNSString(const std::string_view& str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace CocoaTools {
|
||||
/// Add a handler to be run when macOS changes between dark and light themes
|
||||
void AddThemeChangeHandler(void* ctx, void(handler)(void* ctx));
|
||||
|
||||
/// Remove a handler previously added using AddThemeChangeHandler with the given context
|
||||
void RemoveThemeChangeHandler(void* ctx);
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "cocoa_tools.h"
|
||||
|
||||
NSString* CocoaTools::StringViewToNSString(const std::string_view& str)
|
||||
{
|
||||
if (str.empty())
|
||||
return nil;
|
||||
|
||||
return [[[NSString alloc] initWithBytes:str.data()
|
||||
length:static_cast<NSUInteger>(str.length())
|
||||
encoding:NSUTF8StringEncoding] autorelease];
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "d3d11_device.h"
|
||||
#include "core/host_settings.h" // TODO: Remove me
|
||||
#include "core/host.h" // TODO: Remove me
|
||||
#include "d3d11_pipeline.h"
|
||||
#include "d3d11_texture.h"
|
||||
#include "d3d_common.h"
|
||||
|
||||
@ -4,13 +4,16 @@
|
||||
#define INITGUID
|
||||
|
||||
#include "dinput_source.h"
|
||||
#include "input_manager.h"
|
||||
#include "platform_misc.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/log.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/host.h"
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "input_manager.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
Log_SetChannel(DInputSource);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "gpu_device.h"
|
||||
#include "core/host_settings.h"
|
||||
#include "core/host.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/system.h"
|
||||
#include "postprocessing_chain.h"
|
||||
|
||||
@ -1071,7 +1071,7 @@ bool InputManager::HasPointerAxisBinds()
|
||||
return false;
|
||||
}
|
||||
|
||||
void InputManager::SetDefaultConfig(SettingsInterface& si)
|
||||
void InputManager::SetDefaultSourceConfig(SettingsInterface& si)
|
||||
{
|
||||
si.ClearSection("InputSources");
|
||||
si.SetBoolValue("InputSources", "SDL", true);
|
||||
|
||||
@ -319,7 +319,7 @@ bool IsUsingRawInput();
|
||||
bool HasPointerAxisBinds();
|
||||
|
||||
/// Restores default configuration.
|
||||
void SetDefaultConfig(SettingsInterface& si);
|
||||
void SetDefaultSourceConfig(SettingsInterface& si);
|
||||
|
||||
/// Clears all bindings for a given port.
|
||||
void ClearPortBindings(SettingsInterface& si, u32 port);
|
||||
@ -343,9 +343,6 @@ void OnInputDeviceDisconnected(const std::string_view& identifier);
|
||||
} // namespace InputManager
|
||||
|
||||
namespace Host {
|
||||
/// Return the current window handle. Needed for DInput.
|
||||
std::optional<WindowInfo> GetTopLevelWindowInfo();
|
||||
|
||||
/// Called when a new input device is connected.
|
||||
void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name);
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "metal_device.h"
|
||||
#include "core/host_settings.h"
|
||||
#include "spirv_compiler.h"
|
||||
|
||||
#include "common/align.h"
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
namespace FrontendCommon {
|
||||
#include "window_info.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace PlatformMisc {
|
||||
void SuspendScreensaver();
|
||||
void ResumeScreensaver();
|
||||
|
||||
/// Abstracts platform-specific code for asynchronously playing a sound.
|
||||
/// On Windows, this will use PlaySound(). On Linux, it will shell out to aplay. On MacOS, it uses NSSound.
|
||||
bool PlaySoundAsync(const char* path);
|
||||
} // namespace PlatformMisc
|
||||
|
||||
#ifdef __APPLE__
|
||||
/// Add a handler to be run when macOS changes between dark and light themes
|
||||
void AddThemeChangeHandler(void* ctx, void(handler)(void* ctx));
|
||||
/// Remove a handler previously added using AddThemeChangeHandler with the given context
|
||||
void RemoveThemeChangeHandler(void* ctx);
|
||||
#endif
|
||||
} // namespace FrontendCommon
|
||||
namespace Host {
|
||||
/// Return the current window handle. Needed for DInput.
|
||||
std::optional<WindowInfo> GetTopLevelWindowInfo();
|
||||
} // namespace Host
|
||||
@ -2,16 +2,23 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "platform_misc.h"
|
||||
#include "window_info.h"
|
||||
#include "cocoa_tools.h"
|
||||
|
||||
#include "common/log.h"
|
||||
#include "common/string.h"
|
||||
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
#include <cinttypes>
|
||||
#include <vector>
|
||||
Log_SetChannel(FrontendCommon);
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
Log_SetChannel(PlatformMisc);
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
#error ARC should not be enabled.
|
||||
#endif
|
||||
|
||||
static IOPMAssertionID s_prevent_idle_assertion = kIOPMNullAssertionID;
|
||||
|
||||
@ -39,7 +46,7 @@ static bool SetScreensaverInhibitMacOS(bool inhibit)
|
||||
|
||||
static bool s_screensaver_suspended;
|
||||
|
||||
void FrontendCommon::SuspendScreensaver()
|
||||
void PlatformMisc::SuspendScreensaver()
|
||||
{
|
||||
if (s_screensaver_suspended)
|
||||
|
||||
@ -52,7 +59,7 @@ void FrontendCommon::SuspendScreensaver()
|
||||
s_screensaver_suspended = true;
|
||||
}
|
||||
|
||||
void FrontendCommon::ResumeScreensaver()
|
||||
void PlatformMisc::ResumeScreensaver()
|
||||
{
|
||||
if (!s_screensaver_suspended)
|
||||
return;
|
||||
@ -63,7 +70,7 @@ void FrontendCommon::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool FrontendCommon::PlaySoundAsync(const char* path)
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
NSString* nspath = [[NSString alloc] initWithUTF8String:path];
|
||||
NSSound* sound = [[NSSound alloc] initWithContentsOfFile:nspath byReference:YES];
|
||||
@ -73,6 +80,16 @@ bool FrontendCommon::PlaySoundAsync(const char* path)
|
||||
return result;
|
||||
}
|
||||
|
||||
NSString* CocoaTools::StringViewToNSString(const std::string_view& str)
|
||||
{
|
||||
if (str.empty())
|
||||
return nil;
|
||||
|
||||
return [[[NSString alloc] initWithBytes:str.data()
|
||||
length:static_cast<NSUInteger>(str.length())
|
||||
encoding:NSUTF8StringEncoding] autorelease];
|
||||
}
|
||||
|
||||
// From https://github.com/PCSX2/pcsx2/blob/1b673d9dd0829a48f5f0b6604c1de2108e981399/common/CocoaTools.mm
|
||||
|
||||
@interface PCSX2KVOHelper : NSObject
|
||||
@ -110,7 +127,7 @@ bool FrontendCommon::PlaySoundAsync(const char* path)
|
||||
|
||||
static PCSX2KVOHelper* s_themeChangeHandler;
|
||||
|
||||
void FrontendCommon::AddThemeChangeHandler(void* ctx, void(handler)(void* ctx))
|
||||
void CocoaTools::AddThemeChangeHandler(void* ctx, void(handler)(void* ctx))
|
||||
{
|
||||
assert([NSThread isMainThread]);
|
||||
if (!s_themeChangeHandler)
|
||||
@ -125,7 +142,7 @@ void FrontendCommon::AddThemeChangeHandler(void* ctx, void(handler)(void* ctx))
|
||||
[s_themeChangeHandler addCallback:ctx run:handler];
|
||||
}
|
||||
|
||||
void FrontendCommon::RemoveThemeChangeHandler(void* ctx)
|
||||
void CocoaTools::RemoveThemeChangeHandler(void* ctx)
|
||||
{
|
||||
assert([NSThread isMainThread]);
|
||||
[s_themeChangeHandler removeCallback:ctx];
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "input_manager.h"
|
||||
#include "platform_misc.h"
|
||||
#include <cinttypes>
|
||||
Log_SetChannel(FrontendCommon);
|
||||
Log_SetChannel(PlatformMisc);
|
||||
|
||||
#include <spawn.h>
|
||||
#include <unistd.h>
|
||||
@ -146,7 +146,7 @@ static bool SetScreensaverInhibit(bool inhibit)
|
||||
|
||||
static bool s_screensaver_suspended;
|
||||
|
||||
void FrontendCommon::SuspendScreensaver()
|
||||
void PlatformMisc::SuspendScreensaver()
|
||||
{
|
||||
if (s_screensaver_suspended)
|
||||
return;
|
||||
@ -160,7 +160,7 @@ void FrontendCommon::SuspendScreensaver()
|
||||
s_screensaver_suspended = true;
|
||||
}
|
||||
|
||||
void FrontendCommon::ResumeScreensaver()
|
||||
void PlatformMisc::ResumeScreensaver()
|
||||
{
|
||||
if (!s_screensaver_suspended)
|
||||
return;
|
||||
@ -171,7 +171,7 @@ void FrontendCommon::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool FrontendCommon::PlaySoundAsync(const char* path)
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
#ifdef __linux__
|
||||
// This is... pretty awful. But I can't think of a better way without linking to e.g. gstreamer.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include "common/string_util.h"
|
||||
#include "platform_misc.h"
|
||||
#include <cinttypes>
|
||||
Log_SetChannel(FrontendCommon);
|
||||
Log_SetChannel(PlatformMisc);
|
||||
|
||||
#include "common/windows_headers.h"
|
||||
#include <mmsystem.h>
|
||||
@ -24,7 +24,7 @@ static bool SetScreensaverInhibitWin32(bool inhibit)
|
||||
|
||||
static bool s_screensaver_suspended;
|
||||
|
||||
void FrontendCommon::SuspendScreensaver()
|
||||
void PlatformMisc::SuspendScreensaver()
|
||||
{
|
||||
if (s_screensaver_suspended)
|
||||
return;
|
||||
@ -38,7 +38,7 @@ void FrontendCommon::SuspendScreensaver()
|
||||
s_screensaver_suspended = true;
|
||||
}
|
||||
|
||||
void FrontendCommon::ResumeScreensaver()
|
||||
void PlatformMisc::ResumeScreensaver()
|
||||
{
|
||||
if (!s_screensaver_suspended)
|
||||
return;
|
||||
@ -49,7 +49,7 @@ void FrontendCommon::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool FrontendCommon::PlaySoundAsync(const char* path)
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
const std::wstring wpath(StringUtil::UTF8StringToWideString(path));
|
||||
return PlaySoundW(wpath.c_str(), NULL, SND_ASYNC | SND_NODEFAULT);
|
||||
|
||||
@ -2,17 +2,21 @@
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "sdl_input_source.h"
|
||||
#include "input_manager.h"
|
||||
|
||||
#include "core/host.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/bitutils.h"
|
||||
#include "common/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/host.h"
|
||||
#include "core/host_settings.h"
|
||||
#include "input_manager.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
Log_SetChannel(SDLInputSource);
|
||||
|
||||
static constexpr const char* s_sdl_axis_names[] = {
|
||||
|
||||
Reference in New Issue
Block a user