mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-23 07:37:00 +00:00
UI: Improvements and fixes for Windows dark mode (#1728)
This commit is contained in:
parent
1382ee0381
commit
934cc3eb9d
17 changed files with 180 additions and 203 deletions
|
|
@ -22,9 +22,10 @@ DirectInputController::~DirectInputController()
|
|||
// TODO: test if really needed
|
||||
// workaround for gamecube controllers crash on release?
|
||||
bool should_release_device = true;
|
||||
if (m_product_guid == GUID{}) {
|
||||
DIDEVICEINSTANCE info{};
|
||||
info.dwSize = sizeof(DIDEVICEINSTANCE);
|
||||
if (m_product_guid == GUID{})
|
||||
{
|
||||
DIDEVICEINSTANCEW info{};
|
||||
info.dwSize = sizeof(DIDEVICEINSTANCEW);
|
||||
if (SUCCEEDED(m_device->GetDeviceInfo(&info)))
|
||||
{
|
||||
m_product_guid = info.guidProduct;
|
||||
|
|
@ -90,8 +91,8 @@ bool DirectInputController::connect()
|
|||
if (FAILED(hr) || m_device == nullptr)
|
||||
return false;
|
||||
|
||||
DIDEVICEINSTANCE idi{};
|
||||
idi.dwSize = sizeof(DIDEVICEINSTANCE);
|
||||
DIDEVICEINSTANCEW idi{};
|
||||
idi.dwSize = sizeof(DIDEVICEINSTANCEW);
|
||||
if (SUCCEEDED(m_device->GetDeviceInfo(&idi)))
|
||||
{
|
||||
// overwrite guid name with "real" display name
|
||||
|
|
@ -147,8 +148,8 @@ bool DirectInputController::connect()
|
|||
}
|
||||
}
|
||||
|
||||
DIDEVICEINSTANCE info{};
|
||||
info.dwSize = sizeof(DIDEVICEINSTANCE);
|
||||
DIDEVICEINSTANCEW info{};
|
||||
info.dwSize = sizeof(DIDEVICEINSTANCEW);
|
||||
if (SUCCEEDED(m_device->GetDeviceInfo(&info)))
|
||||
{
|
||||
m_product_guid = info.guidProduct;
|
||||
|
|
@ -157,7 +158,7 @@ bool DirectInputController::connect()
|
|||
std::fill(m_min_axis.begin(), m_min_axis.end(), 0);
|
||||
std::fill(m_max_axis.begin(), m_max_axis.end(), std::numeric_limits<uint16>::max());
|
||||
m_device->EnumObjects(
|
||||
[](LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) -> BOOL
|
||||
[](LPCDIDEVICEOBJECTINSTANCEW lpddoi, LPVOID pvRef) -> BOOL
|
||||
{
|
||||
auto* thisptr = (DirectInputController*)pvRef;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ private:
|
|||
GUID m_product_guid{};
|
||||
|
||||
std::shared_mutex m_mutex;
|
||||
Microsoft::WRL::ComPtr<IDirectInputDevice8> m_device;
|
||||
Microsoft::WRL::ComPtr<IDirectInputDevice8W> m_device;
|
||||
Microsoft::WRL::ComPtr<IDirectInputEffect> m_effect;
|
||||
|
||||
std::array<LONG, 6> m_min_axis{};
|
||||
|
|
|
|||
|
|
@ -4,34 +4,16 @@
|
|||
|
||||
DirectInputControllerProvider::DirectInputControllerProvider()
|
||||
{
|
||||
/*m_module = LoadLibraryA("dinput8.dll");
|
||||
if (!m_module)
|
||||
throw std::runtime_error("can't load any xinput dll");
|
||||
|
||||
m_DirectInput8Create = (decltype(&DirectInput8Create))GetProcAddress(m_module, "DirectInput8Create");
|
||||
m_GetdfDIJoystick = (decltype(&GetdfDIJoystick))GetProcAddress(m_module, "GetdfDIJoystick");
|
||||
|
||||
if (!m_DirectInput8Create)
|
||||
{
|
||||
FreeLibrary(m_module);
|
||||
throw std::runtime_error("can't find the DirectInput8Create export");
|
||||
}*/
|
||||
|
||||
|
||||
const auto r = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_dinput8, nullptr);
|
||||
const auto r = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8W, (void**)&m_dinput8, nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
const auto error = GetLastError();
|
||||
//FreeLibrary(m_module);
|
||||
throw std::runtime_error(fmt::format("can't create direct input object (error: {:#x})", error));
|
||||
}
|
||||
}
|
||||
|
||||
DirectInputControllerProvider::~DirectInputControllerProvider()
|
||||
{
|
||||
/*if (m_module)
|
||||
FreeLibrary(m_module);
|
||||
*/
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ControllerBase>> DirectInputControllerProvider::get_controllers()
|
||||
|
|
@ -39,7 +21,7 @@ std::vector<std::shared_ptr<ControllerBase>> DirectInputControllerProvider::get_
|
|||
std::vector<std::shared_ptr<ControllerBase>> result;
|
||||
|
||||
m_dinput8->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||
[](LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) -> BOOL
|
||||
[](LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef) -> BOOL
|
||||
{
|
||||
auto* controllers = (decltype(&result))pvRef;
|
||||
|
||||
|
|
@ -55,8 +37,5 @@ std::vector<std::shared_ptr<ControllerBase>> DirectInputControllerProvider::get_
|
|||
|
||||
LPCDIDATAFORMAT DirectInputControllerProvider::get_data_format() const
|
||||
{
|
||||
/*if (m_GetdfDIJoystick)
|
||||
return m_GetdfDIJoystick();*/
|
||||
|
||||
return GetdfDIJoystick();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
std::vector<std::shared_ptr<ControllerBase>> get_controllers() override;
|
||||
|
||||
IDirectInput8* get_dinput() const { return m_dinput8.Get(); }
|
||||
IDirectInput8W* get_dinput() const { return m_dinput8.Get(); }
|
||||
LPCDIDATAFORMAT get_data_format() const;
|
||||
|
||||
private:
|
||||
|
|
@ -32,7 +32,7 @@ private:
|
|||
decltype(&DirectInput8Create) m_DirectInput8Create;
|
||||
decltype(&GetdfDIJoystick) m_GetdfDIJoystick = nullptr;
|
||||
|
||||
Microsoft::WRL::ComPtr<IDirectInput8> m_dinput8;
|
||||
Microsoft::WRL::ComPtr<IDirectInput8W> m_dinput8;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue