diff --git a/A320UE/A320UE.vcxproj b/A320UE/A320UE.vcxproj index c343400..69e5ca4 100644 --- a/A320UE/A320UE.vcxproj +++ b/A320UE/A320UE.vcxproj @@ -38,32 +38,32 @@ {3684F283-A3DB-48E7-BD8F-C9351A38138F} Win32Proj A320UE - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/BetterMouseYoke/BetterMouseYoke.vcxproj b/BetterMouseYoke/BetterMouseYoke.vcxproj index fc33a97..cb68a0f 100644 --- a/BetterMouseYoke/BetterMouseYoke.vcxproj +++ b/BetterMouseYoke/BetterMouseYoke.vcxproj @@ -34,32 +34,32 @@ {D9E54848-F19F-4DBD-B4EC-4871922541CA} Win32Proj BetterMouseYoke - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/BetterMouseYoke/plugin.c b/BetterMouseYoke/plugin.c index 5b75bab..0d0dec2 100644 --- a/BetterMouseYoke/plugin.c +++ b/BetterMouseYoke/plugin.c @@ -14,7 +14,7 @@ #define PLUGIN_DESCRIPTION "Does away with X-Plane's idiotic centered little box " \ "for mouse steering that has caused much grieve and " \ "countless loss of virtual lives." -#define PLUGIN_VERSION "1.5" +#define PLUGIN_VERSION "1.5.1" #define RUDDER_DEFL_DIST 200 #define RUDDER_RET_SPEED 2.0f @@ -45,6 +45,35 @@ static HCURSOR yoke_cursor; static HCURSOR rudder_cursor; static HCURSOR arrow_cursor; static HCURSOR(WINAPI *true_set_cursor) (HCURSOR cursor) = SetCursor; + +static BOOL CALLBACK find_xplane_window_cb(HWND hwnd, LPARAM lParam) +{ + char class_name[64] = { 0 }; + if (GetClassNameA(hwnd, class_name, sizeof(class_name))) { + if (strcmp(class_name, "X-System") == 0) { + HWND *out = (HWND *)lParam; + *out = hwnd; + return FALSE; + } + } + return TRUE; +} + +static int find_xplane_window(HWND *out_hwnd) +{ + *out_hwnd = NULL; + if (EnumWindows(find_xplane_window_cb, (LPARAM)out_hwnd) && *out_hwnd) { + return 1; + } + if (*out_hwnd) { + return 1; + } + *out_hwnd = FindWindowA("X-System", "X-System"); + if (*out_hwnd) { + return 1; + } + return 0; +} #endif /** @@ -94,9 +123,8 @@ PLUGIN_API int XPluginStart(char *name, char *sig, char *desc) { rudder_defl_dist = ini_geti("rudder_deflection_distance", RUDDER_DEFL_DIST); rudder_ret_spd = ini_getf("rudder_return_speed", RUDDER_RET_SPEED); #ifdef IBM - xp_hwnd = FindWindowA("X-System", "X-System"); - if (!xp_hwnd) { - _log("could not find X-Plane 11 window"); + if (!find_xplane_window(&xp_hwnd)) { + _log("could not find X-Plane window"); return 0; } if (!hook_set_cursor(1)) { diff --git a/CycleQuickLooks/CycleQuickLooks.vcxproj b/CycleQuickLooks/CycleQuickLooks.vcxproj index a1915c8..fbc7930 100644 --- a/CycleQuickLooks/CycleQuickLooks.vcxproj +++ b/CycleQuickLooks/CycleQuickLooks.vcxproj @@ -31,32 +31,32 @@ {9FD9E482-7A36-4B3A-B352-79C35D744F98} Win32Proj CycleQuickLooks - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/MouseButtons/MouseButtons.vcxproj b/MouseButtons/MouseButtons.vcxproj index 255ae40..d668092 100644 --- a/MouseButtons/MouseButtons.vcxproj +++ b/MouseButtons/MouseButtons.vcxproj @@ -35,32 +35,32 @@ {71988D8C-AEF8-45DB-8609-69E6F6315C71} Win32Proj MouseButtons - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/MouseButtons/plugin.c b/MouseButtons/plugin.c index 3655949..364ca25 100644 --- a/MouseButtons/plugin.c +++ b/MouseButtons/plugin.c @@ -13,7 +13,7 @@ #define PLUGIN_DESCRIPTION "Enables the use of extra mouse buttons and allows " \ "the right mouse button and mouse wheel to be re-" \ "assigned to arbitrary commands." -#define PLUGIN_VERSION "1.0" +#define PLUGIN_VERSION "1.0.1" /** * X-Plane 11 Plugin Entry Point. @@ -96,6 +96,35 @@ PLUGIN_API void XPluginReceiveMessage(XPLMPluginID from, int msg, void *param) { static HWND xp_hwnd; static WNDPROC old_wnd_proc; +static BOOL CALLBACK find_xplane_window_cb(HWND hwnd, LPARAM lParam) +{ + char class_name[64] = { 0 }; + if (GetClassNameA(hwnd, class_name, sizeof(class_name))) { + if (strcmp(class_name, "X-System") == 0) { + HWND* out = (HWND*)lParam; + *out = hwnd; + return FALSE; + } + } + return TRUE; +} + +static int find_xplane_window(HWND* out_hwnd) +{ + *out_hwnd = NULL; + if (EnumWindows(find_xplane_window_cb, (LPARAM)out_hwnd) && *out_hwnd) { + return 1; + } + if (*out_hwnd) { + return 1; + } + *out_hwnd = FindWindowA("X-System", "X-System"); + if (*out_hwnd) { + return 1; + } + return 0; +} + static mbutton_t wm_to_mbutton(UINT msg, WPARAM wParam, int *state) { switch (msg) { case WM_LBUTTONDOWN: @@ -169,9 +198,8 @@ LRESULT CALLBACK xp_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, } int hook_wnd_proc() { - xp_hwnd = FindWindowA("X-System", "X-System"); - if (!xp_hwnd) { - _log("could not find X-Plane 11 window"); + if (!find_xplane_window(&xp_hwnd)) { + _log("could not find X-Plane window"); return 0; } old_wnd_proc = (WNDPROC)SetWindowLongPtrA(xp_hwnd, GWLP_WNDPROC, diff --git a/PluginLoader/PluginLoader.vcxproj b/PluginLoader/PluginLoader.vcxproj index eff2608..2f15741 100644 --- a/PluginLoader/PluginLoader.vcxproj +++ b/PluginLoader/PluginLoader.vcxproj @@ -34,32 +34,32 @@ {6A2982AA-8DC6-4217-94ED-87D956767507} Win32Proj PluginLoader - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/ToggleMouseLook/ToggleMouseLook.vcxproj b/ToggleMouseLook/ToggleMouseLook.vcxproj index c1dfe37..1ec126e 100644 --- a/ToggleMouseLook/ToggleMouseLook.vcxproj +++ b/ToggleMouseLook/ToggleMouseLook.vcxproj @@ -34,32 +34,32 @@ {5AF5AA8B-673B-4D43-B077-EB5F9AAAE4A5} Win32Proj ToggleMouseLook - 10.0.17134.0 + 10.0 DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet DynamicLibrary true - v141 + v143 NotSet DynamicLibrary false - v141 + v143 true NotSet diff --git a/ToggleMouseLook/plugin.c b/ToggleMouseLook/plugin.c index 549c996..c9d6415 100644 --- a/ToggleMouseLook/plugin.c +++ b/ToggleMouseLook/plugin.c @@ -11,7 +11,7 @@ #define PLUGIN_SIG "S22.ToggleMouseLook" #define PLUGIN_DESCRIPTION "Adds new commands for better control of mouse " \ "look inside the cockpit." -#define PLUGIN_VERSION "1.2" +#define PLUGIN_VERSION "1.2.1" static XPLMCommandRef toggle_mouse_look; static XPLMCommandRef hold_mouse_look; @@ -130,6 +130,35 @@ int draw_cb(XPLMDrawingPhase phase, int before, void *ref) { static HWND xp_hwnd; static WNDPROC old_wnd_proc; +static BOOL CALLBACK find_xplane_window_cb(HWND hwnd, LPARAM lParam) +{ + char class_name[64] = { 0 }; + if (GetClassNameA(hwnd, class_name, sizeof(class_name))) { + if (strcmp(class_name, "X-System") == 0) { + HWND* out = (HWND*)lParam; + *out = hwnd; + return FALSE; + } + } + return TRUE; +} + +static int find_xplane_window(HWND* out_hwnd) +{ + *out_hwnd = NULL; + if (EnumWindows(find_xplane_window_cb, (LPARAM)out_hwnd) && *out_hwnd) { + return 1; + } + if (*out_hwnd) { + return 1; + } + *out_hwnd = FindWindowA("X-System", "X-System"); + if (*out_hwnd) { + return 1; + } + return 0; +} + LRESULT CALLBACK xp_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -149,9 +178,8 @@ LRESULT CALLBACK xp_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, } int hook_wnd_proc() { - xp_hwnd = FindWindowA("X-System", "X-System"); - if (!xp_hwnd) { - _log("could not find X-Plane 11 window"); + if (!find_xplane_window(&xp_hwnd)) { + _log("could not find X-Plane window"); return 0; } old_wnd_proc = (WNDPROC) SetWindowLongPtrA(xp_hwnd, GWLP_WNDPROC, diff --git a/Util/Util.vcxproj b/Util/Util.vcxproj index ceb4ba9..c7b4b1c 100644 --- a/Util/Util.vcxproj +++ b/Util/Util.vcxproj @@ -36,32 +36,32 @@ {1A1C2295-5251-42A2-A088-3E027FA34795} Win32Proj Util - 10.0.17134.0 + 10.0 StaticLibrary true - v141 + v143 NotSet StaticLibrary false - v141 + v143 true NotSet StaticLibrary true - v141 + v143 NotSet StaticLibrary false - v141 + v143 true NotSet