mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-03 04:24:11 +01:00
[d3d9] Add CallCharsetFunction helper
This commit is contained in:
parent
6cf052b3f2
commit
a340cd4dd3
@ -21,6 +21,14 @@ namespace dxvk {
|
|||||||
static std::unordered_map<HWND, D3D9WindowData> g_windowProcMap;
|
static std::unordered_map<HWND, D3D9WindowData> g_windowProcMap;
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename J, typename ... Args>
|
||||||
|
auto CallCharsetFunction(T unicode, J ascii, bool isUnicode, Args... args) {
|
||||||
|
return isUnicode
|
||||||
|
? unicode(args...)
|
||||||
|
: ascii (args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT CALLBACK D3D9WindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
|
static LRESULT CALLBACK D3D9WindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
|
||||||
if (message == WM_NCCALCSIZE && wparam == TRUE)
|
if (message == WM_NCCALCSIZE && wparam == TRUE)
|
||||||
return 0;
|
return 0;
|
||||||
@ -40,13 +48,13 @@ namespace dxvk {
|
|||||||
: IsWindowUnicode(window);
|
: IsWindowUnicode(window);
|
||||||
|
|
||||||
if (!windowData.proc || windowData.filter)
|
if (!windowData.proc || windowData.filter)
|
||||||
return unicode
|
return CallCharsetFunction(
|
||||||
? DefWindowProcW(window, message, wparam, lparam)
|
DefWindowProcW, DefWindowProcA, unicode,
|
||||||
: DefWindowProcA(window, message, wparam, lparam);
|
window, message, wparam, lparam);
|
||||||
|
|
||||||
return unicode
|
return CallCharsetFunction(
|
||||||
? CallWindowProcW(windowData.proc, window, message, wparam, lparam)
|
CallWindowProcW, CallWindowProcA, unicode,
|
||||||
: CallWindowProcA(windowData.proc, window, message, wparam, lparam);
|
windowData.proc, window, message, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1480,9 +1488,10 @@ namespace dxvk {
|
|||||||
D3D9WindowData windowData;
|
D3D9WindowData windowData;
|
||||||
windowData.unicode = IsWindowUnicode(m_window);
|
windowData.unicode = IsWindowUnicode(m_window);
|
||||||
windowData.filter = true;
|
windowData.filter = true;
|
||||||
windowData.proc = windowData.unicode
|
windowData.proc = reinterpret_cast<WNDPROC>(
|
||||||
? (WNDPROC)SetWindowLongPtrW(m_window, GWLP_WNDPROC, (LONG_PTR)D3D9WindowProc)
|
CallCharsetFunction(
|
||||||
: (WNDPROC)SetWindowLongPtrA(m_window, GWLP_WNDPROC, (LONG_PTR)D3D9WindowProc);
|
SetWindowLongPtrW, SetWindowLongPtrA, windowData.unicode,
|
||||||
|
m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(D3D9WindowProc)));
|
||||||
|
|
||||||
g_windowProcMap[m_window] = std::move(windowData);
|
g_windowProcMap[m_window] = std::move(windowData);
|
||||||
}
|
}
|
||||||
@ -1494,15 +1503,16 @@ namespace dxvk {
|
|||||||
if (it == g_windowProcMap.end())
|
if (it == g_windowProcMap.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto proc = it->second.unicode
|
auto proc = reinterpret_cast<WNDPROC>(
|
||||||
? (WNDPROC)GetWindowLongPtrW(m_window, GWLP_WNDPROC)
|
CallCharsetFunction(
|
||||||
: (WNDPROC)GetWindowLongPtrA(m_window, GWLP_WNDPROC);
|
GetWindowLongPtrW, GetWindowLongPtrA, it->second.unicode,
|
||||||
|
m_window, GWLP_WNDPROC));
|
||||||
|
|
||||||
if (proc == D3D9WindowProc) {
|
|
||||||
it->second.unicode
|
if (proc == D3D9WindowProc)
|
||||||
? SetWindowLongPtrW(m_window, GWLP_WNDPROC, (LONG_PTR)it->second.proc)
|
CallCharsetFunction(
|
||||||
: SetWindowLongPtrA(m_window, GWLP_WNDPROC, (LONG_PTR)it->second.proc);
|
SetWindowLongPtrW, SetWindowLongPtrA, it->second.unicode,
|
||||||
}
|
m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(it->second.proc));
|
||||||
|
|
||||||
g_windowProcMap.erase(m_window);
|
g_windowProcMap.erase(m_window);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user