mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Formatting
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ using namespace BlackMisc::Input;
|
||||
|
||||
namespace BlackInput
|
||||
{
|
||||
|
||||
static const auto &keyMapping()
|
||||
{
|
||||
static const QHash<int, KeyCode> 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<KBDLLHOOKSTRUCT*>(lParam);
|
||||
KBDLLHOOKSTRUCT *keyboardEvent = reinterpret_cast<KBDLLHOOKSTRUCT *>(lParam);
|
||||
WPARAM vkCode = keyboardEvent->vkCode;
|
||||
g_keyboardWindows->processKeyEvent(vkCode, wParam);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user