summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/hl2h.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp
index 74a8c6c..f7106cd 100644
--- a/src/hl2h.cpp
+++ b/src/hl2h.cpp
@@ -664,25 +664,14 @@ static void install_uniform_random_hook() {
664// and monitor gamma are plain client cvars. 664// and monitor gamma are plain client cvars.
665 665
666static void view_settings_apply(void *ent) { 666static void view_settings_apply(void *ent) {
667 if (g_net.default_fov >= 0 && ent) { 667 if (g_net.default_fov >= 0 && ent)
668 static int last = -2; 668 *(int *)((uintptr_t)ent + g_net.default_fov) = g_fov_camera;
669 int want = g_fov_camera > 0 ? g_fov_camera : 0; 669 static int last_vm = 54;
670 if (want != last || g_fov_camera > 0) { 670 if (g_fov_viewmodel != last_vm) {
671 *(int *)((uintptr_t)ent + g_net.default_fov) = want;
672 last = want;
673 }
674 }
675 // 0 means "leave the game's value alone": only send a command once the
676 // slider is non-zero, then restore the stock value when it returns to 0.
677 static int last_vm = 0;
678 if (g_fov_viewmodel > 0 && g_fov_viewmodel != last_vm) {
679 char cmd[48]; 671 char cmd[48];
680 snprintf(cmd, sizeof(cmd), "viewmodel_fov %d", g_fov_viewmodel); 672 snprintf(cmd, sizeof(cmd), "viewmodel_fov %d", g_fov_viewmodel);
681 console_cmd(cmd); 673 console_cmd(cmd);
682 last_vm = g_fov_viewmodel; 674 last_vm = g_fov_viewmodel;
683 } else if (g_fov_viewmodel == 0 && last_vm > 0) {
684 console_cmd("viewmodel_fov 54");
685 last_vm = 0;
686 } 675 }
687 static int last_gamma = 22; 676 static int last_gamma = 22;
688 if (g_gamma != last_gamma) { 677 if (g_gamma != last_gamma) {
@@ -690,6 +679,18 @@ static void view_settings_apply(void *ent) {
690 snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10, 679 snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10,
691 g_gamma % 10); 680 g_gamma % 10);
692 console_cmd(cmd); 681 console_cmd(cmd);
682 // Read back through ICvar to tell an ignored command from an OS gamma
683 // ramp that the compositor discards.
684 float got = -1.0f;
685 if (g_iface.cvar) {
686 using FindFn = void *(*)(void *, const char *);
687 void *v = vfunc<FindFn>(g_iface.cvar, 12)(g_iface.cvar,
688 "mat_monitorgamma");
689 if (v)
690 got = *(float *)((uintptr_t)v + 0x2c); // ConVar m_Value.f
691 }
692 logf("view: gamma request %d.%d, cvar reports %.2f", g_gamma / 10,
693 g_gamma % 10, got);
693 last_gamma = g_gamma; 694 last_gamma = g_gamma;
694 } 695 }
695} 696}