mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-05-11 05:44:15 -05:00
mingw: add WindowsRT compatibility shim for incomplete implementation
This commit is contained in:
parent
01e1a68d34
commit
bfea29cd33
|
|
@ -6,7 +6,11 @@
|
|||
#include <fmt/format.h>
|
||||
#include <string>
|
||||
#include <winerror.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <winrt/base.h>
|
||||
#elif defined(__MINGW32__)
|
||||
#include "Common/WindowsRTShim.h"
|
||||
#endif
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
|
|
|
|||
222
Source/Core/Common/WindowsRTShim.h
Normal file
222
Source/Core/Common/WindowsRTShim.h
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
// Copyright 2008 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
// This header contains type definitions that are shared between the Dolphin core and
|
||||
// other parts of the code. Any definitions that are only used by the core should be
|
||||
// placed in "Common.h" instead.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <winerror.h>
|
||||
|
||||
namespace winrt
|
||||
{
|
||||
struct event_token
|
||||
{
|
||||
int value{};
|
||||
};
|
||||
inline void init_apartment()
|
||||
{
|
||||
}
|
||||
inline void uninit_apartment()
|
||||
{
|
||||
}
|
||||
|
||||
struct hresult
|
||||
{
|
||||
HRESULT value;
|
||||
constexpr hresult(HRESULT v = 0) noexcept : value(v) {}
|
||||
constexpr operator HRESULT() const noexcept { return value; }
|
||||
};
|
||||
|
||||
struct hresult_error
|
||||
{
|
||||
HRESULT m_hr;
|
||||
explicit hresult_error(HRESULT hr) : m_hr(hr) {}
|
||||
HRESULT code() const noexcept { return m_hr; }
|
||||
|
||||
std::string message() const noexcept
|
||||
{
|
||||
return "HRESULT 0x" + std::to_string(static_cast<unsigned long>(m_hr));
|
||||
}
|
||||
};
|
||||
|
||||
inline void check_hresult(HRESULT hr) noexcept
|
||||
{
|
||||
if (FAILED(hr))
|
||||
std::abort();
|
||||
}
|
||||
|
||||
inline std::string to_string(const std::string& s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct array_view
|
||||
{
|
||||
using pointer = T*;
|
||||
using size_type = size_t;
|
||||
array_view(pointer, size_type) {}
|
||||
};
|
||||
|
||||
namespace Windows
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
namespace Power
|
||||
{
|
||||
enum BatteryStatus
|
||||
{
|
||||
NotPresent,
|
||||
Discharging,
|
||||
Idle,
|
||||
Charging
|
||||
};
|
||||
}
|
||||
} // namespace System
|
||||
|
||||
namespace Devices
|
||||
{
|
||||
namespace Haptics
|
||||
{
|
||||
struct SimpleHapticsControllerFeedback
|
||||
{
|
||||
uint16_t Waveform() const { return 0; }
|
||||
};
|
||||
struct SimpleHapticsController
|
||||
{
|
||||
void StopFeedback() {}
|
||||
void SendHapticFeedback(SimpleHapticsControllerFeedback, double) {}
|
||||
std::vector<SimpleHapticsControllerFeedback> SupportedFeedback() const { return {}; }
|
||||
};
|
||||
struct KnownSimpleHapticsControllerWaveforms
|
||||
{
|
||||
static uint16_t Click() { return 1; }
|
||||
static uint16_t BuzzContinuous() { return 2; }
|
||||
static uint16_t RumbleContinuous() { return 3; }
|
||||
};
|
||||
} // namespace Haptics
|
||||
|
||||
namespace Power
|
||||
{
|
||||
struct BatteryReport
|
||||
{
|
||||
winrt::Windows::System::Power::BatteryStatus Status() const
|
||||
{
|
||||
return winrt::Windows::System::Power::BatteryStatus::NotPresent;
|
||||
}
|
||||
struct Capacity
|
||||
{
|
||||
int GetInt32() const { return 0; }
|
||||
};
|
||||
Capacity FullChargeCapacityInMilliwattHours() const { return {}; }
|
||||
Capacity RemainingCapacityInMilliwattHours() const { return {}; }
|
||||
explicit operator bool() const { return false; }
|
||||
};
|
||||
} // namespace Power
|
||||
} // namespace Devices
|
||||
|
||||
namespace Foundation
|
||||
{
|
||||
namespace Collections
|
||||
{
|
||||
template <typename T>
|
||||
struct IVectorView
|
||||
{
|
||||
};
|
||||
} // namespace Collections
|
||||
} // namespace Foundation
|
||||
|
||||
namespace Gaming
|
||||
{
|
||||
namespace Input
|
||||
{
|
||||
struct GamepadReading
|
||||
{
|
||||
double LeftTrigger{}, RightTrigger{}, LeftThumbstickX{}, LeftThumbstickY{}, RightThumbstickX{},
|
||||
RightThumbstickY{};
|
||||
};
|
||||
struct GamepadVibration
|
||||
{
|
||||
double LeftMotor{}, RightMotor{}, LeftTrigger{}, RightTrigger{};
|
||||
};
|
||||
enum GameControllerSwitchPosition
|
||||
{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
enum GameControllerSwitchKind
|
||||
{
|
||||
TwoWay,
|
||||
FourWay
|
||||
};
|
||||
enum GameControllerButtonLabel
|
||||
{
|
||||
None
|
||||
};
|
||||
|
||||
struct RawGameController
|
||||
{
|
||||
int AxisCount() const { return 0; }
|
||||
int SwitchCount() const { return 0; }
|
||||
GameControllerSwitchKind GetSwitchKind(int) const { return TwoWay; }
|
||||
int ButtonCount() const { return 0; }
|
||||
GameControllerButtonLabel GetButtonLabel(int) const { return None; }
|
||||
|
||||
std::vector<winrt::Windows::Devices::Haptics::SimpleHapticsController>
|
||||
SimpleHapticsControllers() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void GetCurrentReading(const winrt::array_view<bool>&,
|
||||
const std::vector<GameControllerSwitchPosition>&,
|
||||
const std::vector<double>&) const
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring DisplayName() const { return L""; }
|
||||
uint16_t HardwareVendorId() const { return 0; }
|
||||
uint16_t HardwareProductId() const { return 0; }
|
||||
|
||||
template <typename T>
|
||||
T try_as() const
|
||||
{
|
||||
return T{};
|
||||
}
|
||||
|
||||
static std::vector<RawGameController> RawGameControllers() { return {}; }
|
||||
static winrt::event_token RawGameControllerAdded(auto) { return {}; }
|
||||
static winrt::event_token RawGameControllerRemoved(auto) { return {}; }
|
||||
|
||||
bool operator==(const RawGameController&) const { return false; }
|
||||
};
|
||||
|
||||
struct Gamepad
|
||||
{
|
||||
Gamepad() = default;
|
||||
Gamepad(std::nullptr_t) {}
|
||||
explicit operator bool() const { return false; }
|
||||
static Gamepad FromGameController(const RawGameController&) { return Gamepad(nullptr); }
|
||||
GamepadReading GetCurrentReading() const { return {}; }
|
||||
void Vibration(const GamepadVibration&) {}
|
||||
};
|
||||
|
||||
struct IGameControllerBatteryInfo
|
||||
{
|
||||
winrt::Windows::Devices::Power::BatteryReport TryGetBatteryReport() const { return {}; }
|
||||
explicit operator bool() const { return false; }
|
||||
};
|
||||
} // namespace Input
|
||||
} // namespace Gaming
|
||||
} // namespace Windows
|
||||
} // namespace winrt
|
||||
|
|
@ -14,12 +14,47 @@
|
|||
|
||||
// NOTE: winrt translates com failures to c++ exceptions, so we must use try/catch in this file to
|
||||
// prevent possible errors from escaping and terminating Dolphin.
|
||||
#ifdef _MSC_VER
|
||||
#include <winrt/base.h>
|
||||
#include <winrt/windows.devices.haptics.h>
|
||||
#include <winrt/windows.devices.power.h>
|
||||
#include <winrt/windows.foundation.collections.h>
|
||||
#include <winrt/windows.gaming.input.h>
|
||||
#include <winrt/windows.system.power.h>
|
||||
#else
|
||||
#ifdef __MINGW32__
|
||||
// for: https://github.com/msys2/MINGW-packages/issues/22160
|
||||
#define ____FIReference_1_boolean_INTERFACE_DEFINED__
|
||||
enum BatteryStatus
|
||||
{
|
||||
BatteryStatus_NotPresent = 0,
|
||||
BatteryStatus_Discharging = 1,
|
||||
BatteryStatus_Idle = 2,
|
||||
BatteryStatus_Charging = 3
|
||||
};
|
||||
namespace ABI
|
||||
{
|
||||
namespace Windows
|
||||
{
|
||||
namespace Storage
|
||||
{
|
||||
enum KnownFoldersAccessStatus
|
||||
{
|
||||
KnownFoldersAccessStatus_Denied = 0,
|
||||
KnownFoldersAccessStatus_Allowed = 1
|
||||
};
|
||||
} // namespace Storage
|
||||
} // namespace Windows
|
||||
} // namespace ABI
|
||||
#include <windows.devices.haptics.h>
|
||||
#include <windows.devices.power.h>
|
||||
#include <windows.foundation.collections.h>
|
||||
#include <windows.gaming.input.forcefeedback.h>
|
||||
#include <windows.gaming.input.h>
|
||||
#include <windows.system.power.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#pragma comment(lib, "windowsapp")
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user