mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2024-11-22 02:35:57 +01:00
csgo-vulkan-fix: update for cs2
This commit is contained in:
parent
f9578d28d2
commit
15ac326593
1 changed files with 5 additions and 22 deletions
|
@ -9,10 +9,8 @@
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
inline CFunctionHook* g_pMouseMotionHook = nullptr;
|
|
||||||
inline CFunctionHook* g_pSurfaceSizeHook = nullptr;
|
inline CFunctionHook* g_pSurfaceSizeHook = nullptr;
|
||||||
inline CFunctionHook* g_pSurfaceDamageHook = nullptr;
|
inline CFunctionHook* g_pSurfaceDamageHook = nullptr;
|
||||||
typedef void (*origMotion)(wlr_seat*, uint32_t, double, double);
|
|
||||||
typedef void (*origSurfaceSize)(wlr_xwayland_surface*, int16_t, int16_t, uint16_t, uint16_t);
|
typedef void (*origSurfaceSize)(wlr_xwayland_surface*, int16_t, int16_t, uint16_t, uint16_t);
|
||||||
typedef void (*origSurfaceDamage)(wlr_surface*, pixman_region32_t*);
|
typedef void (*origSurfaceDamage)(wlr_surface*, pixman_region32_t*);
|
||||||
|
|
||||||
|
@ -30,26 +28,13 @@ void onNewWindow(void* self, std::any data) {
|
||||||
// data is guaranteed
|
// data is guaranteed
|
||||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||||
|
|
||||||
if (g_pXWaylandManager->getAppIDClass(PWINDOW) == "csgo_linux64") {
|
if (g_pXWaylandManager->getAppIDClass(PWINDOW) == "cs2") {
|
||||||
pCSGOSurface = g_pXWaylandManager->getWindowSurface(PWINDOW);
|
pCSGOSurface = g_pXWaylandManager->getWindowSurface(PWINDOW);
|
||||||
pCSGOXWSurface = PWINDOW->m_uSurface.xwayland;
|
pCSGOXWSurface = PWINDOW->m_uSurface.xwayland;
|
||||||
csgoMonitor = PWINDOW->m_iMonitorID;
|
csgoMonitor = PWINDOW->m_iMonitorID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hkNotifyMotion(wlr_seat* wlr_seat, uint32_t time_msec, double sx, double sy) {
|
|
||||||
static auto* const RESX = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w")->intValue;
|
|
||||||
static auto* const RESY = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h")->intValue;
|
|
||||||
|
|
||||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_szInitialClass == "csgo_linux64" && g_pCompositor->m_pLastMonitor) {
|
|
||||||
// fix the coords
|
|
||||||
sx *= *RESX / g_pCompositor->m_pLastMonitor->vecSize.x;
|
|
||||||
sy *= *RESY / g_pCompositor->m_pLastMonitor->vecSize.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*(origMotion)g_pMouseMotionHook->m_pOriginal)(wlr_seat, time_msec, sx, sy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hkSetWindowSize(wlr_xwayland_surface* surface, int16_t x, int16_t y, uint16_t width, uint16_t height) {
|
void hkSetWindowSize(wlr_xwayland_surface* surface, int16_t x, int16_t y, uint16_t width, uint16_t height) {
|
||||||
static auto* const RESX = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w")->intValue;
|
static auto* const RESX = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w")->intValue;
|
||||||
static auto* const RESY = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h")->intValue;
|
static auto* const RESY = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h")->intValue;
|
||||||
|
@ -62,7 +47,7 @@ void hkSetWindowSize(wlr_xwayland_surface* surface, int16_t x, int16_t y, uint16
|
||||||
const auto SURF = surface->surface;
|
const auto SURF = surface->surface;
|
||||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(SURF);
|
const auto PWINDOW = g_pCompositor->getWindowFromSurface(SURF);
|
||||||
|
|
||||||
if (PWINDOW && PWINDOW->m_szInitialClass == "csgo_linux64") {
|
if (PWINDOW && PWINDOW->m_szInitialClass == "cs2") {
|
||||||
width = *RESX;
|
width = *RESX;
|
||||||
height = *RESY;
|
height = *RESY;
|
||||||
}
|
}
|
||||||
|
@ -87,21 +72,19 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w", SConfigValue{.intValue = 1680});
|
HyprlandAPI::addConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_w", SConfigValue{.intValue = 1680});
|
||||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h", SConfigValue{.intValue = 1050});
|
HyprlandAPI::addConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h", SConfigValue{.intValue = 1050});
|
||||||
|
|
||||||
g_pMouseMotionHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_seat_pointer_notify_motion, (void*)&hkNotifyMotion);
|
|
||||||
g_pSurfaceSizeHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_xwayland_surface_configure, (void*)&hkSetWindowSize);
|
g_pSurfaceSizeHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_xwayland_surface_configure, (void*)&hkSetWindowSize);
|
||||||
g_pSurfaceDamageHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_surface_get_effective_damage, (void*)&hkSurfaceDamage);
|
g_pSurfaceDamageHook = HyprlandAPI::createFunctionHook(PHANDLE, (void*)&wlr_surface_get_effective_damage, (void*)&hkSurfaceDamage);
|
||||||
bool hkResult = g_pMouseMotionHook->hook();
|
bool hkResult = hkResult && g_pSurfaceSizeHook->hook();
|
||||||
hkResult = hkResult && g_pSurfaceSizeHook->hook();
|
|
||||||
hkResult = hkResult && g_pSurfaceDamageHook->hook();
|
hkResult = hkResult && g_pSurfaceDamageHook->hook();
|
||||||
|
|
||||||
HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, std::any data) { onNewWindow(self, data); });
|
HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, std::any data) { onNewWindow(self, data); });
|
||||||
|
|
||||||
if (hkResult)
|
if (hkResult)
|
||||||
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Initialized successfully!", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
|
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Initialized successfully! (CS2 version)", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
|
||||||
else
|
else
|
||||||
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization (hook failed)!", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
|
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization (hook failed)!", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
|
||||||
|
|
||||||
return {"csgo-vulkan-fix", "A plugin to fix incorrect mouse offsets on csgo in Vulkan", "Vaxry", "1.0"};
|
return {"csgo-vulkan-fix", "A plugin to fix incorrect mouse offsets on csgo in Vulkan", "Vaxry", "1.1"};
|
||||||
}
|
}
|
||||||
|
|
||||||
APICALL EXPORT void PLUGIN_EXIT() {
|
APICALL EXPORT void PLUGIN_EXIT() {
|
||||||
|
|
Loading…
Reference in a new issue