mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Clean up dynamic loading of Win32 funcs, remove makepanda touchinput setting, remove checks for pre-WinXP
This commit is contained in:
parent
c410d812ff
commit
6344c05b18
@ -94,7 +94,6 @@ PkgListSet(["PYTHON", "DIRECT", # Python support
|
|||||||
"PANDAPARTICLESYSTEM", # Built in particle system
|
"PANDAPARTICLESYSTEM", # Built in particle system
|
||||||
"CONTRIB", # Experimental
|
"CONTRIB", # Experimental
|
||||||
"SSE2", "NEON", # Compiler features
|
"SSE2", "NEON", # Compiler features
|
||||||
"TOUCHINPUT", # Touchinput interface (requires Windows 7)
|
|
||||||
])
|
])
|
||||||
|
|
||||||
CheckPandaSourceTree()
|
CheckPandaSourceTree()
|
||||||
@ -170,7 +169,8 @@ def parseopts(args):
|
|||||||
"version=","lzma","no-python","threads=","outputdir=","override=",
|
"version=","lzma","no-python","threads=","outputdir=","override=",
|
||||||
"static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
|
"static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
|
||||||
"directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
|
"directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
|
||||||
"universal", "target=", "arch=", "git-commit="]
|
"universal", "target=", "arch=", "git-commit=",
|
||||||
|
"use-touchinput", "no-touchinput"]
|
||||||
anything = 0
|
anything = 0
|
||||||
optimize = ""
|
optimize = ""
|
||||||
target = None
|
target = None
|
||||||
@ -316,18 +316,6 @@ def parseopts(args):
|
|||||||
print("No Windows SDK version specified. Defaulting to '7.1'.")
|
print("No Windows SDK version specified. Defaulting to '7.1'.")
|
||||||
WINDOWS_SDK = '7.1'
|
WINDOWS_SDK = '7.1'
|
||||||
|
|
||||||
is_win7 = False
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
# Note: not available in cygwin.
|
|
||||||
winver = sys.getwindowsversion()
|
|
||||||
if winver[0] >= 6 and winver[1] >= 1:
|
|
||||||
is_win7 = True
|
|
||||||
|
|
||||||
if RUNTIME or not is_win7:
|
|
||||||
PkgDisable("TOUCHINPUT")
|
|
||||||
else:
|
|
||||||
PkgDisable("TOUCHINPUT")
|
|
||||||
|
|
||||||
if clean_build and os.path.isdir(GetOutputDir()):
|
if clean_build and os.path.isdir(GetOutputDir()):
|
||||||
print("Deleting %s" % (GetOutputDir()))
|
print("Deleting %s" % (GetOutputDir()))
|
||||||
shutil.rmtree(GetOutputDir())
|
shutil.rmtree(GetOutputDir())
|
||||||
@ -1055,10 +1043,7 @@ def CompileCxx(obj,src,opts):
|
|||||||
cmd += "/favor:blend "
|
cmd += "/favor:blend "
|
||||||
cmd += "/wd4996 /wd4275 /wd4273 "
|
cmd += "/wd4996 /wd4275 /wd4273 "
|
||||||
|
|
||||||
# Enable Windows 7 interfaces if we need Touchinput.
|
# We still target Windows XP.
|
||||||
if PkgSkip("TOUCHINPUT") == 0:
|
|
||||||
cmd += "/DWINVER=0x601 "
|
|
||||||
else:
|
|
||||||
cmd += "/DWINVER=0x501 "
|
cmd += "/DWINVER=0x501 "
|
||||||
# Work around a WinXP/2003 bug when using VS 2015+.
|
# Work around a WinXP/2003 bug when using VS 2015+.
|
||||||
if SDK.get("VISUALSTUDIO_VERSION") == '14.0':
|
if SDK.get("VISUALSTUDIO_VERSION") == '14.0':
|
||||||
@ -1113,11 +1098,6 @@ def CompileCxx(obj,src,opts):
|
|||||||
if GetTargetArch() == 'x64':
|
if GetTargetArch() == 'x64':
|
||||||
cmd += "/favor:blend "
|
cmd += "/favor:blend "
|
||||||
cmd += "/wd4996 /wd4275 /wd4267 /wd4101 /wd4273 "
|
cmd += "/wd4996 /wd4275 /wd4267 /wd4101 /wd4273 "
|
||||||
|
|
||||||
# Enable Windows 7 interfaces if we need Touchinput.
|
|
||||||
if PkgSkip("TOUCHINPUT") == 0:
|
|
||||||
cmd += "/DWINVER=0x601 "
|
|
||||||
else:
|
|
||||||
cmd += "/DWINVER=0x501 "
|
cmd += "/DWINVER=0x501 "
|
||||||
cmd += "/Fo" + obj + " /c"
|
cmd += "/Fo" + obj + " /c"
|
||||||
for x in ipath: cmd += " /I" + x
|
for x in ipath: cmd += " /I" + x
|
||||||
@ -2129,7 +2109,6 @@ DTOOL_CONFIG=[
|
|||||||
("REPORT_OPENSSL_ERRORS", '1', '1'),
|
("REPORT_OPENSSL_ERRORS", '1', '1'),
|
||||||
("USE_PANDAFILESTREAM", '1', '1'),
|
("USE_PANDAFILESTREAM", '1', '1'),
|
||||||
("USE_DELETED_CHAIN", '1', '1'),
|
("USE_DELETED_CHAIN", '1', '1'),
|
||||||
("HAVE_WIN_TOUCHINPUT", 'UNDEF', 'UNDEF'),
|
|
||||||
("HAVE_GLX", 'UNDEF', '1'),
|
("HAVE_GLX", 'UNDEF', '1'),
|
||||||
("HAVE_WGL", '1', 'UNDEF'),
|
("HAVE_WGL", '1', 'UNDEF'),
|
||||||
("HAVE_DX9", 'UNDEF', 'UNDEF'),
|
("HAVE_DX9", 'UNDEF', 'UNDEF'),
|
||||||
@ -2347,9 +2326,6 @@ def WriteConfigSettings():
|
|||||||
if (PkgSkip("PYTHON") != 0):
|
if (PkgSkip("PYTHON") != 0):
|
||||||
dtool_config["HAVE_ROCKET_PYTHON"] = 'UNDEF'
|
dtool_config["HAVE_ROCKET_PYTHON"] = 'UNDEF'
|
||||||
|
|
||||||
if (PkgSkip("TOUCHINPUT") == 0 and GetTarget() == "windows"):
|
|
||||||
dtool_config["HAVE_WIN_TOUCHINPUT"] = '1'
|
|
||||||
|
|
||||||
if (GetOptimize() <= 3):
|
if (GetOptimize() <= 3):
|
||||||
dtool_config["HAVE_ROCKET_DEBUGGER"] = '1'
|
dtool_config["HAVE_ROCKET_DEBUGGER"] = '1'
|
||||||
|
|
||||||
|
@ -19,6 +19,16 @@
|
|||||||
|
|
||||||
TypeHandle wdxGraphicsPipe9::_type_handle;
|
TypeHandle wdxGraphicsPipe9::_type_handle;
|
||||||
|
|
||||||
|
static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) {
|
||||||
|
*pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName);
|
||||||
|
if (*pFn == NULL) {
|
||||||
|
wdxdisplay9_cat.error()
|
||||||
|
<< "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() <<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#define LOWVIDMEMTHRESHOLD 5700000 // 4MB cards should fall below this
|
#define LOWVIDMEMTHRESHOLD 5700000 // 4MB cards should fall below this
|
||||||
#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000 // if # is > 1MB, card is lying and I cant tell what it is
|
#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000 // if # is > 1MB, card is lying and I cant tell what it is
|
||||||
#define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF
|
#define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF
|
||||||
@ -154,7 +164,10 @@ make_output(const string &name,
|
|||||||
*/
|
*/
|
||||||
bool wdxGraphicsPipe9::
|
bool wdxGraphicsPipe9::
|
||||||
init() {
|
init() {
|
||||||
if (!MyLoadLib(_hDDrawDLL, "ddraw.dll")) {
|
_hDDrawDLL = LoadLibrary("ddraw.dll");
|
||||||
|
if (_hDDrawDLL == NULL) {
|
||||||
|
wdxdisplay9_cat.error()
|
||||||
|
<< "LoadLibrary failed for ddraw.dll, error=" << GetLastError() <<endl;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +179,10 @@ init() {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MyLoadLib(_hD3D9_DLL, "d3d9.dll")) {
|
_hD3D9_DLL = LoadLibrary("d3d9.dll");
|
||||||
|
if (_hD3D9_DLL == NULL) {
|
||||||
|
wdxdisplay9_cat.error()
|
||||||
|
<< "LoadLibrary failed for d3d9.dll, error=" << GetLastError() <<endl;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,15 +47,12 @@ typedef struct _PROCESSOR_POWER_INFORMATION {
|
|||||||
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
|
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
|
||||||
|
|
||||||
typedef BOOL (WINAPI *GetProcessMemoryInfoType) (HANDLE Process, PROCESS_MEMORY_COUNTERS *ppsmemCounters, DWORD cb);
|
typedef BOOL (WINAPI *GetProcessMemoryInfoType) (HANDLE Process, PROCESS_MEMORY_COUNTERS *ppsmemCounters, DWORD cb);
|
||||||
typedef BOOL (WINAPI *GlobalMemoryStatusExType) (LPMEMORYSTATUSEX lpBuffer);
|
|
||||||
typedef long (__stdcall *CallNtPowerInformationType) (POWER_INFORMATION_LEVEL information_level, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength);
|
typedef long (__stdcall *CallNtPowerInformationType) (POWER_INFORMATION_LEVEL information_level, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength);
|
||||||
|
|
||||||
static int initialize = false;
|
static int initialize = false;
|
||||||
static HMODULE psapi_dll = 0;
|
static HMODULE psapi_dll = 0;
|
||||||
static HMODULE kernel32_dll = 0;
|
|
||||||
static HMODULE power_dll = 0;
|
static HMODULE power_dll = 0;
|
||||||
static GetProcessMemoryInfoType GetProcessMemoryInfoFunction = 0;
|
static GetProcessMemoryInfoType GetProcessMemoryInfoFunction = 0;
|
||||||
static GlobalMemoryStatusExType GlobalMemoryStatusExFunction = 0;
|
|
||||||
static CallNtPowerInformationType CallNtPowerInformationFunction = 0;
|
static CallNtPowerInformationType CallNtPowerInformationFunction = 0;
|
||||||
|
|
||||||
void get_memory_information (DisplayInformation *display_information) {
|
void get_memory_information (DisplayInformation *display_information) {
|
||||||
@ -65,19 +62,13 @@ void get_memory_information (DisplayInformation *display_information) {
|
|||||||
GetProcessMemoryInfoFunction = (GetProcessMemoryInfoType) GetProcAddress(psapi_dll, "GetProcessMemoryInfo");
|
GetProcessMemoryInfoFunction = (GetProcessMemoryInfoType) GetProcAddress(psapi_dll, "GetProcessMemoryInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel32_dll = LoadLibrary("kernel32.dll");
|
|
||||||
if (kernel32_dll) {
|
|
||||||
GlobalMemoryStatusExFunction = (GlobalMemoryStatusExType) GetProcAddress(kernel32_dll, "GlobalMemoryStatusEx");
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize = true;
|
initialize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalMemoryStatusExFunction) {
|
|
||||||
MEMORYSTATUSEX memory_status;
|
MEMORYSTATUSEX memory_status;
|
||||||
|
|
||||||
memory_status.dwLength = sizeof(MEMORYSTATUSEX);
|
memory_status.dwLength = sizeof(MEMORYSTATUSEX);
|
||||||
if (GlobalMemoryStatusExFunction(&memory_status)) {
|
if (GlobalMemoryStatusEx(&memory_status)) {
|
||||||
display_information->_physical_memory = memory_status.ullTotalPhys;
|
display_information->_physical_memory = memory_status.ullTotalPhys;
|
||||||
display_information->_available_physical_memory = memory_status.ullAvailPhys;
|
display_information->_available_physical_memory = memory_status.ullAvailPhys;
|
||||||
display_information->_page_file_size = memory_status.ullTotalPageFile;
|
display_information->_page_file_size = memory_status.ullTotalPageFile;
|
||||||
@ -86,20 +77,6 @@ void get_memory_information (DisplayInformation *display_information) {
|
|||||||
display_information->_available_process_virtual_memory = memory_status.ullAvailVirtual;
|
display_information->_available_process_virtual_memory = memory_status.ullAvailVirtual;
|
||||||
display_information->_memory_load = memory_status.dwMemoryLoad;
|
display_information->_memory_load = memory_status.dwMemoryLoad;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MEMORYSTATUS memory_status;
|
|
||||||
|
|
||||||
memory_status.dwLength = sizeof(MEMORYSTATUS);
|
|
||||||
GlobalMemoryStatus (&memory_status);
|
|
||||||
|
|
||||||
display_information->_physical_memory = memory_status.dwTotalPhys;
|
|
||||||
display_information->_available_physical_memory = memory_status.dwAvailPhys;
|
|
||||||
display_information->_page_file_size = memory_status.dwTotalPageFile;
|
|
||||||
display_information->_available_page_file_size = memory_status.dwAvailPageFile;
|
|
||||||
display_information->_process_virtual_memory = memory_status.dwTotalVirtual;
|
|
||||||
display_information->_available_process_virtual_memory = memory_status.dwAvailVirtual;
|
|
||||||
display_information->_memory_load = memory_status.dwMemoryLoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetProcessMemoryInfoFunction) {
|
if (GetProcessMemoryInfoFunction) {
|
||||||
HANDLE process;
|
HANDLE process;
|
||||||
@ -687,19 +664,12 @@ WinGraphicsPipe() {
|
|||||||
|
|
||||||
_supported_types = OT_window | OT_fullscreen_window;
|
_supported_types = OT_window | OT_fullscreen_window;
|
||||||
|
|
||||||
// these fns arent defined on win95, so get dynamic ptrs to them to avoid
|
HMODULE user32 = GetModuleHandleA("user32.dll");
|
||||||
// ugly DLL loader failures on w95
|
if (user32 != NULL) {
|
||||||
_pfnTrackMouseEvent = NULL;
|
|
||||||
|
|
||||||
_hUser32 = (HINSTANCE)LoadLibrary("user32.dll");
|
|
||||||
if (_hUser32 != NULL) {
|
|
||||||
_pfnTrackMouseEvent =
|
|
||||||
(PFN_TRACKMOUSEEVENT)GetProcAddress(_hUser32, "TrackMouseEvent");
|
|
||||||
|
|
||||||
if (dpi_aware) {
|
if (dpi_aware) {
|
||||||
typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness);
|
typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness);
|
||||||
PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness =
|
PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness =
|
||||||
(PFN_SETPROCESSDPIAWARENESS)GetProcAddress(_hUser32, "SetProcessDpiAwarenessInternal");
|
(PFN_SETPROCESSDPIAWARENESS)GetProcAddress(user32, "SetProcessDpiAwarenessInternal");
|
||||||
|
|
||||||
if (pfnSetProcessDpiAwareness == NULL) {
|
if (pfnSetProcessDpiAwareness == NULL) {
|
||||||
if (windisplay_cat.is_debug()) {
|
if (windisplay_cat.is_debug()) {
|
||||||
@ -908,26 +878,4 @@ lookup_cpu_data() {
|
|||||||
*/
|
*/
|
||||||
WinGraphicsPipe::
|
WinGraphicsPipe::
|
||||||
~WinGraphicsPipe() {
|
~WinGraphicsPipe() {
|
||||||
if (_hUser32 != NULL) {
|
|
||||||
FreeLibrary(_hUser32);
|
|
||||||
_hUser32 = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) {
|
|
||||||
*pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName);
|
|
||||||
if (*pFn == NULL) {
|
|
||||||
windisplay_cat.error() << "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() <<endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyLoadLib(HINSTANCE &hDLL, const char *DLLname) {
|
|
||||||
hDLL = LoadLibrary(DLLname);
|
|
||||||
if(hDLL == NULL) {
|
|
||||||
windisplay_cat.error() << "LoadLibrary failed for " << DLLname << ", error=" << GetLastError() <<endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,6 @@ public:
|
|||||||
|
|
||||||
virtual void lookup_cpu_data();
|
virtual void lookup_cpu_data();
|
||||||
|
|
||||||
private:
|
|
||||||
HINSTANCE _hUser32;
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT);
|
|
||||||
PFN_TRACKMOUSEEVENT _pfnTrackMouseEvent;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
@ -56,13 +50,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
friend class WinGraphicsWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EXPCL_PANDAWIN bool MyLoadLib(HINSTANCE &hDLL, const char *DLLname);
|
|
||||||
extern EXPCL_PANDAWIN bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName);
|
|
||||||
|
|
||||||
#include "winGraphicsPipe.I"
|
#include "winGraphicsPipe.I"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,6 +29,17 @@
|
|||||||
#define WM_DPICHANGED 0x02E0
|
#define WM_DPICHANGED 0x02E0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_TOUCH
|
||||||
|
#define WM_TOUCH 0x0240
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WINVER < 0x0601
|
||||||
|
// Not used on Windows XP, but we still need to define it.
|
||||||
|
#define TOUCH_COORD_TO_PIXEL(l) ((l) / 100)
|
||||||
|
|
||||||
|
DECLARE_HANDLE(HTOUCHINPUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
TypeHandle WinGraphicsWindow::_type_handle;
|
TypeHandle WinGraphicsWindow::_type_handle;
|
||||||
TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle;
|
TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle;
|
||||||
|
|
||||||
@ -56,22 +67,15 @@ int WinGraphicsWindow::_window_class_index = 0;
|
|||||||
|
|
||||||
static const char * const errorbox_title = "Panda3D Error";
|
static const char * const errorbox_title = "Panda3D Error";
|
||||||
|
|
||||||
// These static variables contain pointers to the Raw Input functions, which
|
// These static variables contain pointers to the touch input functions, which
|
||||||
// are dynamically extracted from USER32.DLL
|
// are dynamically extracted from USER32.DLL
|
||||||
|
typedef WINUSERAPI BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags);
|
||||||
|
typedef WINUSERAPI BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize);
|
||||||
|
typedef WINUSERAPI BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput);
|
||||||
|
|
||||||
typedef WINUSERAPI UINT (WINAPI *tGetRawInputDeviceList)
|
static PFN_REGISTERTOUCHWINDOW pRegisterTouchWindow = 0;
|
||||||
(OUT PRAWINPUTDEVICELIST pRawInputDeviceList, IN OUT PUINT puiNumDevices, IN UINT cbSize);
|
static PFN_GETTOUCHINPUTINFO pGetTouchInputInfo = 0;
|
||||||
typedef WINUSERAPI UINT(WINAPI *tGetRawInputData)
|
static PFN_CLOSETOUCHINPUTHANDLE pCloseTouchInputHandle = 0;
|
||||||
(IN HRAWINPUT hRawInput, IN UINT uiCommand, OUT LPVOID pData, IN OUT PUINT pcbSize, IN UINT cbSizeHeader);
|
|
||||||
typedef WINUSERAPI UINT(WINAPI *tGetRawInputDeviceInfoA)
|
|
||||||
(IN HANDLE hDevice, IN UINT uiCommand, OUT LPVOID pData, IN OUT PUINT pcbSize);
|
|
||||||
typedef WINUSERAPI BOOL (WINAPI *tRegisterRawInputDevices)
|
|
||||||
(IN PCRAWINPUTDEVICE pRawInputDevices, IN UINT uiNumDevices, IN UINT cbSize);
|
|
||||||
|
|
||||||
static tGetRawInputDeviceList pGetRawInputDeviceList;
|
|
||||||
static tGetRawInputData pGetRawInputData;
|
|
||||||
static tGetRawInputDeviceInfoA pGetRawInputDeviceInfoA;
|
|
||||||
static tRegisterRawInputDevices pRegisterRawInputDevices;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -100,9 +104,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
_lalt_down = false;
|
_lalt_down = false;
|
||||||
_ralt_down = false;
|
_ralt_down = false;
|
||||||
_hparent = NULL;
|
_hparent = NULL;
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
_num_touches = 0;
|
||||||
_numTouches = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,13 +514,13 @@ open_window() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Registers to receive the WM_INPUT messages
|
// Registers to receive the WM_INPUT messages
|
||||||
if ((pRegisterRawInputDevices)&&(_input_devices.size() > 1)) {
|
if (_input_devices.size() > 1) {
|
||||||
RAWINPUTDEVICE Rid;
|
RAWINPUTDEVICE Rid;
|
||||||
Rid.usUsagePage = 0x01;
|
Rid.usUsagePage = 0x01;
|
||||||
Rid.usUsage = 0x02;
|
Rid.usUsage = 0x02;
|
||||||
Rid.dwFlags = 0;// RIDEV_NOLEGACY; // adds HID mouse and also ignores legacy mouse messages
|
Rid.dwFlags = 0;// RIDEV_NOLEGACY; // adds HID mouse and also ignores legacy mouse messages
|
||||||
Rid.hwndTarget = _hWnd;
|
Rid.hwndTarget = _hWnd;
|
||||||
pRegisterRawInputDevices(&Rid, 1, sizeof (Rid));
|
RegisterRawInputDevices(&Rid, 1, sizeof (Rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a WindowHandle for ourselves
|
// Create a WindowHandle for ourselves
|
||||||
@ -535,10 +537,23 @@ open_window() {
|
|||||||
// set us as the focus window for keyboard input
|
// set us as the focus window for keyboard input
|
||||||
set_focus();
|
set_focus();
|
||||||
|
|
||||||
|
// Try initializing the touch function pointers.
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized) {
|
||||||
|
initialized = true;
|
||||||
|
HMODULE user32 = GetModuleHandleA("user32.dll");
|
||||||
|
if (user32) {
|
||||||
|
// Introduced in Windows 7.
|
||||||
|
pRegisterTouchWindow = (PFN_REGISTERTOUCHWINDOW)GetProcAddress(user32, "RegisterTouchWindow");
|
||||||
|
pGetTouchInputInfo = (PFN_GETTOUCHINPUTINFO)GetProcAddress(user32, "GetTouchInputInfo");
|
||||||
|
pCloseTouchInputHandle = (PFN_CLOSETOUCHINPUTHANDLE)GetProcAddress(user32, "CloseTouchInputHandle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Register for Win7 touch events.
|
// Register for Win7 touch events.
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
if (pRegisterTouchWindow != NULL) {
|
||||||
RegisterTouchWindow(_hWnd, 0);
|
pRegisterTouchWindow(_hWnd, 0);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -563,45 +578,35 @@ initialize_input_devices() {
|
|||||||
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
||||||
add_input_device(device);
|
add_input_device(device);
|
||||||
|
|
||||||
// Try initializing the Raw Input function pointers.
|
|
||||||
if (pRegisterRawInputDevices==0) {
|
|
||||||
HMODULE user32 = LoadLibrary("user32.dll");
|
|
||||||
if (user32) {
|
|
||||||
pRegisterRawInputDevices = (tRegisterRawInputDevices)GetProcAddress(user32,"RegisterRawInputDevices");
|
|
||||||
pGetRawInputDeviceList = (tGetRawInputDeviceList) GetProcAddress(user32,"GetRawInputDeviceList");
|
|
||||||
pGetRawInputDeviceInfoA = (tGetRawInputDeviceInfoA) GetProcAddress(user32,"GetRawInputDeviceInfoA");
|
|
||||||
pGetRawInputData = (tGetRawInputData) GetProcAddress(user32,"GetRawInputData");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRegisterRawInputDevices==0) return;
|
|
||||||
if (pGetRawInputDeviceList==0) return;
|
|
||||||
if (pGetRawInputDeviceInfoA==0) return;
|
|
||||||
if (pGetRawInputData==0) return;
|
|
||||||
|
|
||||||
// Get the number of devices.
|
// Get the number of devices.
|
||||||
if (pGetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0)
|
if (GetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate the array to hold the DeviceList
|
// Allocate the array to hold the DeviceList
|
||||||
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
|
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
|
||||||
if (pRawInputDeviceList==0) return;
|
if (pRawInputDeviceList==0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Fill the Array
|
// Fill the Array
|
||||||
if (pGetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1)
|
if (GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through all raw devices and find the raw mice
|
// Loop through all raw devices and find the raw mice
|
||||||
for (int i = 0; i < (int)nInputDevices; i++) {
|
for (int i = 0; i < (int)nInputDevices; i++) {
|
||||||
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
|
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
|
||||||
// Fetch information about specified mouse device.
|
// Fetch information about specified mouse device.
|
||||||
UINT nSize;
|
UINT nSize;
|
||||||
if (pGetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0)
|
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
|
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
|
||||||
if (psName == 0) return;
|
if (psName == 0) return;
|
||||||
if (pGetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0)
|
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If it's not an RDP mouse, add it to the list of raw mice.
|
// If it's not an RDP mouse, add it to the list of raw mice.
|
||||||
if (strncmp(psName,"\\??\\Root#RDP_MOU#0000#",22)!=0) {
|
if (strncmp(psName,"\\??\\Root#RDP_MOU#0000#",22)!=0) {
|
||||||
@ -1215,14 +1220,9 @@ adjust_z_order(WindowProperties::ZOrder last_z_order,
|
|||||||
*/
|
*/
|
||||||
void WinGraphicsWindow::
|
void WinGraphicsWindow::
|
||||||
track_mouse_leaving(HWND hwnd) {
|
track_mouse_leaving(HWND hwnd) {
|
||||||
// Note: could use _TrackMouseEvent in comctrl32.dll (part of IE 3.0+) which
|
|
||||||
// emulates TrackMouseEvent on w95, but that requires another 500K of memory
|
|
||||||
// to hold that DLL, which is lame just to support w95, which probably has
|
|
||||||
// other issues anyway
|
|
||||||
WinGraphicsPipe *winpipe;
|
WinGraphicsPipe *winpipe;
|
||||||
DCAST_INTO_V(winpipe, _pipe);
|
DCAST_INTO_V(winpipe, _pipe);
|
||||||
|
|
||||||
if (winpipe->_pfnTrackMouseEvent != NULL) {
|
|
||||||
TRACKMOUSEEVENT tme = {
|
TRACKMOUSEEVENT tme = {
|
||||||
sizeof(TRACKMOUSEEVENT),
|
sizeof(TRACKMOUSEEVENT),
|
||||||
TME_LEAVE,
|
TME_LEAVE,
|
||||||
@ -1231,16 +1231,15 @@ track_mouse_leaving(HWND hwnd) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// tell win32 to post WM_MOUSELEAVE msgs
|
// tell win32 to post WM_MOUSELEAVE msgs
|
||||||
BOOL bSucceeded = winpipe->_pfnTrackMouseEvent(&tme);
|
BOOL bSucceeded = TrackMouseEvent(&tme);
|
||||||
|
|
||||||
if ((!bSucceeded) && windisplay_cat.is_debug()) {
|
if (!bSucceeded && windisplay_cat.is_debug()) {
|
||||||
windisplay_cat.debug()
|
windisplay_cat.debug()
|
||||||
<< "TrackMouseEvent failed!, LastError=" << GetLastError() << endl;
|
<< "TrackMouseEvent failed!, LastError=" << GetLastError() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tracking_mouse_leaving = true;
|
_tracking_mouse_leaving = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to set this window as the "focus" window, so that keyboard events
|
* Attempts to set this window as the "focus" window, so that keyboard events
|
||||||
@ -2067,15 +2066,16 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
|
||||||
case WM_TOUCH:
|
case WM_TOUCH:
|
||||||
_numTouches = LOWORD(wparam);
|
_num_touches = LOWORD(wparam);
|
||||||
if(_numTouches > MAX_TOUCHES)
|
if (_num_touches > MAX_TOUCHES) {
|
||||||
_numTouches = MAX_TOUCHES;
|
_num_touches = MAX_TOUCHES;
|
||||||
GetTouchInputInfo((HTOUCHINPUT)lparam, _numTouches, _touches, sizeof(TOUCHINPUT));
|
}
|
||||||
CloseTouchInputHandle((HTOUCHINPUT)lparam);
|
if (pGetTouchInputInfo != 0) {
|
||||||
|
pGetTouchInputInfo((HTOUCHINPUT)lparam, _num_touches, _touches, sizeof(TOUCHINPUT));
|
||||||
|
pCloseTouchInputHandle((HTOUCHINPUT)lparam);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do custom messages processing if any has been set
|
// do custom messages processing if any has been set
|
||||||
@ -2607,7 +2607,7 @@ handle_raw_input(HRAWINPUT hraw) {
|
|||||||
if (hraw == 0) {
|
if (hraw == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pGetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
|
if (GetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2616,7 +2616,7 @@ handle_raw_input(HRAWINPUT hraw) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pGetRawInputData(hraw, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
|
if (GetRawInputData(hraw, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2974,11 +2974,7 @@ bool WinGraphicsWindow::supports_window_procs() const{
|
|||||||
*/
|
*/
|
||||||
bool WinGraphicsWindow::
|
bool WinGraphicsWindow::
|
||||||
is_touch_event(GraphicsWindowProcCallbackData *callbackData) {
|
is_touch_event(GraphicsWindowProcCallbackData *callbackData) {
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
|
||||||
return callbackData->get_msg() == WM_TOUCH;
|
return callbackData->get_msg() == WM_TOUCH;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2987,11 +2983,7 @@ is_touch_event(GraphicsWindowProcCallbackData* callbackData){
|
|||||||
*/
|
*/
|
||||||
int WinGraphicsWindow::
|
int WinGraphicsWindow::
|
||||||
get_num_touches(){
|
get_num_touches(){
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
return _num_touches;
|
||||||
return _numTouches;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3000,7 +2992,8 @@ get_num_touches(){
|
|||||||
*/
|
*/
|
||||||
TouchInfo WinGraphicsWindow::
|
TouchInfo WinGraphicsWindow::
|
||||||
get_touch_info(int index) {
|
get_touch_info(int index) {
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
nassertr(index >= 0 && index < MAX_TOUCHES, TouchInfo());
|
||||||
|
|
||||||
TOUCHINPUT ti = _touches[index];
|
TOUCHINPUT ti = _touches[index];
|
||||||
POINT point;
|
POINT point;
|
||||||
point.x = TOUCH_COORD_TO_PIXEL(ti.x);
|
point.x = TOUCH_COORD_TO_PIXEL(ti.x);
|
||||||
@ -3013,7 +3006,4 @@ get_touch_info(int index){
|
|||||||
ret.set_id(ti.dwID);
|
ret.set_id(ti.dwID);
|
||||||
ret.set_flags(ti.dwFlags);
|
ret.set_flags(ti.dwFlags);
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
|
||||||
return TouchInfo();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,23 @@ typedef struct {
|
|||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
}
|
} WINDOW_METRICS;
|
||||||
WINDOW_METRICS;
|
|
||||||
|
#if WINVER < 0x0601
|
||||||
|
// Not used on Windows XP, but we still need to define it.
|
||||||
|
typedef struct tagTOUCHINPUT {
|
||||||
|
LONG x;
|
||||||
|
LONG y;
|
||||||
|
HANDLE hSource;
|
||||||
|
DWORD dwID;
|
||||||
|
DWORD dwFlags;
|
||||||
|
DWORD dwMask;
|
||||||
|
DWORD dwTime;
|
||||||
|
ULONG_PTR dwExtraInfo;
|
||||||
|
DWORD cxContact;
|
||||||
|
DWORD cyContact;
|
||||||
|
} TOUCHINPUT, *PTOUCHINPUT;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract base class for glGraphicsWindow and dxGraphicsWindow (and, in
|
* An abstract base class for glGraphicsWindow and dxGraphicsWindow (and, in
|
||||||
@ -177,10 +192,8 @@ private:
|
|||||||
typedef pset<GraphicsWindowProc*> WinProcClasses;
|
typedef pset<GraphicsWindowProc*> WinProcClasses;
|
||||||
WinProcClasses _window_proc_classes;
|
WinProcClasses _window_proc_classes;
|
||||||
|
|
||||||
#ifdef HAVE_WIN_TOUCHINPUT
|
UINT _num_touches;
|
||||||
UINT _numTouches;
|
|
||||||
TOUCHINPUT _touches[MAX_TOUCHES];
|
TOUCHINPUT _touches[MAX_TOUCHES];
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// We need this map to support per-window calls to window_proc().
|
// We need this map to support per-window calls to window_proc().
|
||||||
|
Loading…
x
Reference in New Issue
Block a user