Skip to content

Commit acebadd

Browse files
committed
Marked constructor explicit. Refactored comments.
1 parent c10c516 commit acebadd

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

XMapLib/SendKeyInput.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include "stdafx.h"
33
#include <bitset>
4+
#include <climits>
45
#include "XELog.h"
56
#include "MapFunctions.h"
67

@@ -20,20 +21,16 @@ namespace sds::Utilities
2021
bool m_auto_disable_numlock{ true }; // toggle this to make the default behavior not toggle off numlock on your keyboard
2122
std::map<int, int> m_scancode_store{};
2223
public:
23-
/// <summary>
24-
/// Default Constructor
25-
/// </summary>
24+
/// <summary>Default Constructor</summary>
2625
SendKeyInput() = default;
2726
//Turn auto disable numlock on or off
28-
SendKeyInput(const bool autoDisable) : m_auto_disable_numlock(autoDisable) { }
27+
explicit SendKeyInput(const bool autoDisable) : m_auto_disable_numlock(autoDisable) { }
2928
SendKeyInput(const SendKeyInput& other) = delete;
3029
SendKeyInput(SendKeyInput&& other) = delete;
3130
SendKeyInput& operator=(const SendKeyInput& other) = delete;
3231
SendKeyInput& operator=(SendKeyInput&& other) = delete;
3332
~SendKeyInput() = default;
34-
/// <summary>
35-
/// Sends the virtual keycode as a hardware scancode.
36-
/// </summary>
33+
/// <summary>Sends the virtual keycode as a hardware scancode.</summary>
3734
/// <param name="vk"> is the Virtual Keycode of the keystroke you wish to emulate </param>
3835
/// <param name="down"> is a boolean denoting if the keypress event is KEYDOWN or KEYUP</param>
3936
void SendScanCode(const int vk, const bool down)
@@ -92,9 +89,7 @@ namespace sds::Utilities
9289
Utilities::LogError("SendInput returned 0");
9390
}
9491
}
95-
/// <summary>
96-
/// Utility function to map a Virtual Keycode to a scancode
97-
/// </summary>
92+
/// <summary>Utility function to map a Virtual Keycode to a scancode</summary>
9893
/// <param name="vk"> integer virtual keycode</param>
9994
/// <returns></returns>
10095
WORD GetScanCode(const int vk)
@@ -113,10 +108,8 @@ namespace sds::Utilities
113108
return scan;
114109
}
115110
}
116-
/// <summary>
117-
/// One member function calls SendInput with the eventual built INPUT struct.
118-
/// This is useful for debugging or re-routing the output for logging/testing of a real-time system.
119-
/// </summary>
111+
/// <summary>One member function calls SendInput with the eventual built INPUT struct.
112+
/// This is useful for debugging or re-routing the output for logging/testing of a real-time system.</summary>
120113
/// <param name="inp">Pointer to first element of INPUT array.</param>
121114
/// <param name="numSent">Number of elements in the array to send.</param>
122115
UINT CallSendInput(INPUT* inp, size_t numSent) const
@@ -127,7 +120,7 @@ namespace sds::Utilities
127120
void UnsetNumlockAsync() const noexcept
128121
{
129122
const ScanCodeType NumLockState = GetKeyState(static_cast<int>((VK_NUMLOCK)));
130-
const std::bitset<sizeof(ScanCodeType)*8> bits(NumLockState);
123+
const std::bitset<sizeof(ScanCodeType)*CHAR_BIT> bits(NumLockState);
131124
if (bits[0])
132125
{
133126
auto DoNumlockSend = [this]()
@@ -140,10 +133,8 @@ namespace sds::Utilities
140133
numLockSender.detach(); // fire and forget
141134
}
142135
}
143-
/// <summary>
144-
/// Utility function to send a virtual keycode as input to the OS.
145-
/// Handles keyboard keys and several mouse click buttons.
146-
/// </summary>
136+
/// <summary>Utility function to send a virtual keycode as input to the OS.
137+
/// Handles keyboard keys and several mouse click buttons.</summary>
147138
UINT SendVirtualKey(const VirtualKeyType vk, const bool isKeyboard, const bool sendDown) const noexcept
148139
{
149140
INPUT inp{};

0 commit comments

Comments
 (0)