diff --git a/src/blackinput/joystick.cpp b/src/blackinput/joystick.cpp index b33ab8bb5..c42273251 100644 --- a/src/blackinput/joystick.cpp +++ b/src/blackinput/joystick.cpp @@ -24,8 +24,7 @@ namespace BlackInput IJoystick::IJoystick(QObject *parent) : QObject(parent) - { - } + { } std::unique_ptr IJoystick::create(QObject *parent) { diff --git a/src/blackinput/win/joystickwindows.cpp b/src/blackinput/win/joystickwindows.cpp index 0f5d7a39f..899d2138e 100644 --- a/src/blackinput/win/joystickwindows.cpp +++ b/src/blackinput/win/joystickwindows.cpp @@ -33,7 +33,7 @@ namespace BlackInput this->initDirectInput(); this->enumJoystickDevices(); this->filterJoystickDevices(); - if (!m_availableJoystickDevices.isEmpty()) { createJoystickDevice(); } + if (!m_availableJoystickDevices.isEmpty()) { this->createJoystickDevice(); } } CJoystickWindows::~CJoystickWindows() @@ -167,7 +167,7 @@ namespace BlackInput return hr; } - createHelperWindow(); + this->createHelperWindow(); // Set cooperative level if (FAILED(hr = m_directInputDevice->SetCooperativeLevel(m_helperWindow, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))) @@ -201,7 +201,7 @@ namespace BlackInput CLogMessage(this).info("Created joystick device '%1' with %2 buttons") << deviceData.deviceName << deviceCaps.dwButtons; - startTimer(50); + this->startTimer(50); return hr; } @@ -210,13 +210,13 @@ namespace BlackInput HINSTANCE hInstance = GetModuleHandle(nullptr); WNDCLASS wce; - /* Make sure window isn't created twice. */ + // Make sure window isn't created twice if (m_helperWindow != nullptr) { return 0; } - /* Create the class. */ + // Create the class ZeroMemory(&wce, sizeof(WNDCLASS)); wce.lpfnWndProc = DefWindowProc; wce.lpszClassName = (LPCWSTR) m_helperWindowClassName; @@ -317,7 +317,7 @@ namespace BlackInput for (CJoystickDeviceInput input : m_joystickDeviceInputs) { - qint32 buttonIndex = input.m_offset - DIJOFS_BUTTON0; + const qint32 buttonIndex = input.m_offset - DIJOFS_BUTTON0; updateAndSendButtonStatus(buttonIndex, state.rgbButtons[buttonIndex] & 0x80); } diff --git a/src/blackinput/win/keyboardwindows.cpp b/src/blackinput/win/keyboardwindows.cpp index 1602f7449..f45df2c84 100644 --- a/src/blackinput/win/keyboardwindows.cpp +++ b/src/blackinput/win/keyboardwindows.cpp @@ -13,7 +13,6 @@ using namespace BlackMisc::Input; namespace BlackInput { - static const auto &keyMapping() { static const QHash hash @@ -69,13 +68,11 @@ namespace BlackInput CKeyboardWindows::CKeyboardWindows(QObject *parent) : IKeyboard(parent), m_keyboardHook(nullptr) - { - } + { } CKeyboardWindows::~CKeyboardWindows() { - if (m_keyboardHook) - UnhookWindowsHookEx(m_keyboardHook); + if (m_keyboardHook) { UnhookWindowsHookEx(m_keyboardHook); } } bool CKeyboardWindows::init() @@ -95,7 +92,7 @@ namespace BlackInput if (key == Key_Unknown) { return; } m_keyCombination.addKeyboardKey(CKeyboardKey(key)); } - else if ((event == WM_KEYUP) || (event == WM_SYSKEYUP) ) + else if ((event == WM_KEYUP) || (event == WM_SYSKEYUP)) { auto key = keyMapping().value(vkcode); if (key == Key_Unknown) { return; } @@ -112,7 +109,7 @@ namespace BlackInput { if (nCode == HC_ACTION) { - KBDLLHOOKSTRUCT *keyboardEvent =reinterpret_cast(lParam); + KBDLLHOOKSTRUCT *keyboardEvent = reinterpret_cast(lParam); WPARAM vkCode = keyboardEvent->vkCode; g_keyboardWindows->processKeyEvent(vkCode, wParam); } diff --git a/src/blackinput/win/keyboardwindows.h b/src/blackinput/win/keyboardwindows.h index c4a3ee225..690c64e3e 100644 --- a/src/blackinput/win/keyboardwindows.h +++ b/src/blackinput/win/keyboardwindows.h @@ -26,55 +26,46 @@ namespace BlackInput { - //! \brief Windows implemenation of IKeyboard using hook procedure + //! Windows implemenation of IKeyboard using hook procedure class BLACKINPUT_EXPORT CKeyboardWindows : public IKeyboard { Q_OBJECT + public: + //! Copy Constructor + CKeyboardWindows(CKeyboardWindows const &) = delete; - //! \brief Copy Constructor - CKeyboardWindows(CKeyboardWindows const&) = delete; + //! Assignment operator + CKeyboardWindows &operator=(CKeyboardWindows const &) = delete; - //! \brief Assignment operator - CKeyboardWindows &operator=(CKeyboardWindows const&) = delete; - - //! \brief Destructor + //! Destructor virtual ~CKeyboardWindows(); - //! \brief Keyboard hook handle + //! Keyboard hook handle HHOOK keyboardHook() const { return m_keyboardHook; } //! \private void processKeyEvent(WPARAM vkCode, uint event); protected: - //! \copydoc IKeyboard::init() virtual bool init() override; private: - friend class IKeyboard; - //! \brief Constructor + //! Constructor CKeyboardWindows(QObject *parent = nullptr); void addKey(WPARAM vkcode); void removeKey(WPARAM vkcode); - /*! - * \brief Keyboard hook procedure - * \param nCode - * \param wParam - * \param lParam - * \return - */ + //! Keyboard hook procedure static LRESULT CALLBACK keyboardProc(int nCode, WPARAM wParam, LPARAM lParam); - - BlackMisc::Input::CHotkeyCombination m_keyCombination; //!< Set of virtual keys pressed in the last cycle - HHOOK m_keyboardHook; //!< Keyboard hook handle + BlackMisc::Input::CHotkeyCombination m_keyCombination; //!< Set of virtual keys pressed in the last cycle + HHOOK m_keyboardHook; //!< Keyboard hook handle }; } -#endif // BLACKINPUT_KEYBOARD_WINDOWS_H +#endif // guard