Skip to content

Commit

Permalink
Added command console variable to control cursor visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Sep 30, 2023
1 parent a509a9c commit 1efc5b7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
23.9.30.1
23.9.30.2
=========
+ Added command console variable to control cursor visibility using macros

Cursor.Visible {true|false}

23.9.30.1
=========
+ Fixed D3D12 SwapChain resize failures in FSR3 Frame Generation games.

Expand Down
4 changes: 2 additions & 2 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define SK_YEAR 23
#define SK_MONTH 9
#define SK_DATE 30
#define SK_REV_N 1
#define SK_REV 1
#define SK_REV_N 2
#define SK_REV 2

#ifndef _A2
#define _A2(a) #a
Expand Down
29 changes: 29 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6612,6 +6612,35 @@ SK_InstallWindowHook (HWND hWnd)
SK_GetCommandProcessor ()
);

class CursorListener : public SK_IVariableListener
{
public:
bool cursor_visible = false;

virtual bool OnVarChange (SK_IVariable* var, void* val = nullptr)
{
if (val != nullptr && var != nullptr )
{
if (var->getValuePointer () == &cursor_visible)
{
cursor_visible = *(bool *)val;

static constexpr auto _MaxTries = 25;
for ( UINT tries = 0 ; tries < _MaxTries ; ++tries )
{
if ( cursor_visible && ShowCursor (TRUE) >= 0)
break;
if ((! cursor_visible) && ShowCursor (FALSE) < 0)
break;
}
}
}

return true;
}
} static cursor_control;

cmd->AddVariable ("Cursor.Visible", SK_CreateVar (SK_IVariable::Boolean, (bool *)&cursor_control.cursor_visible, &cursor_control));
cmd->AddVariable ("Cursor.Manage", SK_CreateVar (SK_IVariable::Boolean, (bool *)&config.input.cursor.manage));
cmd->AddVariable ("Cursor.Timeout", SK_CreateVar (SK_IVariable::Int, (int *)&config.input.cursor.timeout));
cmd->AddVariable ("Cursor.KeysActivate", SK_CreateVar (SK_IVariable::Boolean, (bool *)&config.input.cursor.keys_activate));
Expand Down

0 comments on commit 1efc5b7

Please sign in to comment.