-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae05a5e
commit 67d3bcf
Showing
6 changed files
with
134 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#pragma once | ||
|
||
class StickyKeyFilter | ||
{ | ||
bool screensaverState; | ||
STICKYKEYS stickyKeys; | ||
FILTERKEYS filterKeys; | ||
TOGGLEKEYS toggleKeys; | ||
DWORD stickyKeysFlags; | ||
DWORD filterKeysFlags; | ||
DWORD toggleKeysFlags; | ||
|
||
public: | ||
StickyKeyFilter() | ||
{ | ||
screensaverState = false; | ||
stickyKeysFlags = 0; | ||
filterKeysFlags = 0; | ||
toggleKeysFlags = 0; | ||
stickyKeys = {}; | ||
filterKeys = {}; | ||
toggleKeys = {}; | ||
stickyKeys.cbSize = sizeof(stickyKeys); | ||
filterKeys.cbSize = sizeof(filterKeys); | ||
toggleKeys.cbSize = sizeof(toggleKeys); | ||
} | ||
|
||
void initialize() | ||
{ | ||
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &screensaverState, 0); | ||
|
||
if (screensaverState) | ||
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, 0); | ||
|
||
SystemParametersInfo(SPI_GETSTICKYKEYS, sizeof(stickyKeys), &stickyKeys, 0); | ||
SystemParametersInfo(SPI_GETFILTERKEYS, sizeof(filterKeys), &filterKeys, 0); | ||
SystemParametersInfo(SPI_GETTOGGLEKEYS, sizeof(toggleKeys), &toggleKeys, 0); | ||
|
||
if (stickyKeys.dwFlags & SKF_AVAILABLE) | ||
{ | ||
stickyKeysFlags = stickyKeys.dwFlags; | ||
stickyKeys.dwFlags = 0; | ||
SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(stickyKeys), &stickyKeys, 0); | ||
} | ||
|
||
if (filterKeys.dwFlags & FKF_AVAILABLE) | ||
{ | ||
filterKeysFlags = filterKeys.dwFlags; | ||
filterKeys.dwFlags = 0; | ||
SystemParametersInfo(SPI_SETFILTERKEYS, sizeof(filterKeys), &filterKeys, 0); | ||
} | ||
|
||
if (toggleKeys.dwFlags & TKF_AVAILABLE) | ||
{ | ||
toggleKeysFlags = toggleKeys.dwFlags; | ||
toggleKeys.dwFlags = 0; | ||
SystemParametersInfo(SPI_SETTOGGLEKEYS, sizeof(toggleKeys), &toggleKeys, 0); | ||
} | ||
} | ||
|
||
~StickyKeyFilter() | ||
{ | ||
if (screensaverState) | ||
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, nullptr, 0); | ||
if (stickyKeysFlags) | ||
{ | ||
stickyKeys.dwFlags = stickyKeysFlags; | ||
SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(stickyKeys), &stickyKeys, 0); | ||
} | ||
if (filterKeysFlags) | ||
{ | ||
filterKeys.dwFlags = filterKeysFlags; | ||
SystemParametersInfo(SPI_SETFILTERKEYS, sizeof(filterKeys), &filterKeys, 0); | ||
} | ||
if (toggleKeysFlags) | ||
{ | ||
toggleKeys.dwFlags = toggleKeysFlags; | ||
SystemParametersInfo(SPI_SETTOGGLEKEYS, sizeof(toggleKeys), &toggleKeys, 0); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters