| 8881 | |
| 8882 | |
| 8883 | ResultType Line::SetToggleState(vk_type aVK, ToggleValueType &ForceLock, LPTSTR aToggleText) |
| 8884 | // Caller must have already validated that the args are correct. |
| 8885 | // Always returns OK, for use as caller's return value. |
| 8886 | { |
| 8887 | ToggleValueType toggle = ConvertOnOffAlways(aToggleText, NEUTRAL); |
| 8888 | switch (toggle) |
| 8889 | { |
| 8890 | case TOGGLED_ON: |
| 8891 | case TOGGLED_OFF: |
| 8892 | // Turning it on or off overrides any prior AlwaysOn or AlwaysOff setting. |
| 8893 | // Probably need to change the setting BEFORE attempting to toggle the |
| 8894 | // key state, otherwise the hook may prevent the state from being changed |
| 8895 | // if it was set to be AlwaysOn or AlwaysOff: |
| 8896 | ForceLock = NEUTRAL; |
| 8897 | ToggleKeyState(aVK, toggle); |
| 8898 | break; |
| 8899 | case ALWAYS_ON: |
| 8900 | case ALWAYS_OFF: |
| 8901 | ForceLock = (toggle == ALWAYS_ON) ? TOGGLED_ON : TOGGLED_OFF; // Must do this first. |
| 8902 | ToggleKeyState(aVK, ForceLock); |
| 8903 | // The hook is currently needed to support keeping these keys AlwaysOn or AlwaysOff, though |
| 8904 | // there may be better ways to do it (such as registering them as a hotkey, but |
| 8905 | // that may introduce quite a bit of complexity): |
| 8906 | Hotkey::InstallKeybdHook(); |
| 8907 | break; |
| 8908 | case NEUTRAL: |
| 8909 | // Note: No attempt is made to detect whether the keybd hook should be deinstalled |
| 8910 | // because it's no longer needed due to this change. That would require some |
| 8911 | // careful thought about the impact on the status variables in the Hotkey class, etc., |
| 8912 | // so it can be left for a future enhancement: |
| 8913 | ForceLock = NEUTRAL; |
| 8914 | break; |
| 8915 | } |
| 8916 | return OK; |
| 8917 | } |
| 8918 | |
| 8919 | |
| 8920 |
nothing calls this directly
no test coverage detected