Allow Caps Lock to be used as a key modifier.

master
Pacman Ghost 7 years ago
parent f27f570472
commit f230ae95a0
  1. 2
      MainApp/AppConfig.cs
  2. 4
      MouseDll/keyboardState.cpp
  3. 3
      MouseDll/keyboardState.hpp
  4. 6
      MouseDll/sendInput.cpp

@ -18,7 +18,7 @@ namespace MouseInterception
// alignment issues. It's safer to send through a separate array for each type of struct, and then
// elements specify which ones they want via a start index and item count. Sigh...
public enum KeyModifiers { ctrl=0x0001 , alt=0x0002 , shift=0x0004 }
public enum KeyModifiers { ctrl=0x0001 , alt=0x0002 , shift=0x0004 , caps=0x0008 }
// --- SETTINGS: application settings ---
[StructLayout( LayoutKind.Sequential , CharSet=CharSet.Unicode , Pack=1 )]

@ -25,6 +25,8 @@ KeyboardState::getCurrKeyboardState()
flags |= kmAlt ;
if ( GetAsyncKeyState( VK_SHIFT ) < 0 )
flags |= kmShift ;
if ( GetAsyncKeyState( VK_CAPITAL ) < 0 )
flags |= kmCapsLock ;
return KeyboardState( flags ) ;
}
@ -39,6 +41,7 @@ KeyboardState::asString() const
{ KeyboardState::kmCtrl , "Ctrl" } ,
{ KeyboardState::kmAlt , "Alt" } ,
{ KeyboardState::kmShift , "Shift" } ,
{ KeyboardState::kmCapsLock , "CapsLock" } ,
{ -1 , NULL } ,
} ;
return MAKE_STRING( bitFlagsString( stringTable , mFlags , '+' ) ) ;
@ -49,6 +52,7 @@ KeyboardState::asString() const
bool KeyboardState::isCtrlDown() const { return (mFlags & kmCtrl) != 0 ; }
bool KeyboardState::isAltDown() const { return (mFlags & kmAlt) != 0 ; }
bool KeyboardState::isShiftDown() const { return (mFlags & kmShift) != 0 ; }
bool KeyboardState::isCapsLockDown() const { return (mFlags & kmCapsLock) != 0 ; }
bool KeyboardState::isAnythingDown() const { return (mFlags != 0) ; }
bool KeyboardState::operator==( const KeyboardState& rhs ) const { return mFlags == rhs.mFlags ; }

@ -13,7 +13,7 @@ class KeyboardState
// data types:
public:
enum eKeyModifiers { kmCtrl=0x0001 , kmAlt=0x0002 , kmShift=0x0004 } ;
enum eKeyModifiers { kmCtrl=0x0001 , kmAlt=0x0002 , kmShift=0x0004 , kmCapsLock=0x0008 } ;
// constructors/destructor:
public:
@ -24,6 +24,7 @@ public:
bool isCtrlDown() const ;
bool isAltDown() const ;
bool isShiftDown() const ;
bool isCapsLockDown() const ;
bool isAnythingDown() const ;
std::string asString() const ;

@ -37,6 +37,12 @@ CSendInput::setKeyboardState( const KeyboardState& newKeyboardState , const Keyb
sendKeyboardInput( VK_SHIFT , true ) ;
else if ( !newKeyboardState.isShiftDown() && currKeyboardState.isShiftDown() )
sendKeyboardInput( VK_SHIFT , false ) ;
// set the new keyboard state
if ( newKeyboardState.isCapsLockDown() && !currKeyboardState.isCapsLockDown() )
sendKeyboardInput( VK_CAPITAL , true ) ;
else if ( !newKeyboardState.isCapsLockDown() && currKeyboardState.isCapsLockDown() )
sendKeyboardInput( VK_CAPITAL , false ) ;
}
// ---------------------------------------------------------------------

Loading…
Cancel
Save