Convert keyboardinput from class to regular header

No consistent state is needed so it doesn't make sense for it to be a
class.
This commit is contained in:
Vasily
2019-04-04 14:01:11 +02:00
committed by username223
parent 82d44b4ab5
commit e7df60311c
7 changed files with 64 additions and 82 deletions
+5 -3
View File
@@ -12,7 +12,6 @@ SOURCES += src/main.cpp\
src/tabcontrollers/PttController.cpp \ src/tabcontrollers/PttController.cpp \
src/utils/ChaperoneUtils.cpp \ src/utils/ChaperoneUtils.cpp \
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \ src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \
src/openvr/openvr_init.cpp \ src/openvr/openvr_init.cpp \
src/openvr/ivrinput.cpp \ src/openvr/ivrinput.cpp \
src/utils/setup.cpp \ src/utils/setup.cpp \
@@ -31,12 +30,10 @@ HEADERS += src/overlaycontroller.h \
src/tabcontrollers/UtilitiesTabController.h \ src/tabcontrollers/UtilitiesTabController.h \
src/tabcontrollers/AudioManager.h \ src/tabcontrollers/AudioManager.h \
src/tabcontrollers/PttController.h \ src/tabcontrollers/PttController.h \
src/tabcontrollers/keyboardinput/KeyboardInput.h \
src/utils/Matrix.h \ src/utils/Matrix.h \
src/utils/ChaperoneUtils.h \ src/utils/ChaperoneUtils.h \
src/quaternion/quaternion.h \ src/quaternion/quaternion.h \
src/tabcontrollers/audiomanager/AudioManagerDummy.h \ src/tabcontrollers/audiomanager/AudioManagerDummy.h \
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \
src/openvr/openvr_init.h \ src/openvr/openvr_init.h \
src/openvr/ivrinput_action.h \ src/openvr/ivrinput_action.h \
src/openvr/ivrinput_manifest.h \ src/openvr/ivrinput_manifest.h \
@@ -54,6 +51,11 @@ win32 {
src/tabcontrollers/keyboardinput/KeyboardInputWindows.h src/tabcontrollers/keyboardinput/KeyboardInputWindows.h
} }
!win32 {
SOURCES += src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp
HEADERS += src/tabcontrollers/keyboardinput/KeyboardInputDummy.h
}
win32-msvc { win32-msvc {
INCLUDEPATH += third-party/openvr/headers \ INCLUDEPATH += third-party/openvr/headers \
third-party/easylogging++ \ third-party/easylogging++ \
@@ -36,44 +36,44 @@ void UtilitiesTabController::initStage2( OverlayController* var_parent,
void UtilitiesTabController::sendKeyboardInput( QString input ) void UtilitiesTabController::sendKeyboardInput( QString input )
{ {
keyboardInput.sendKeyboardInput( input ); keyboardinput::sendKeyboardInput( input );
} }
void UtilitiesTabController::sendKeyboardEnter() void UtilitiesTabController::sendKeyboardEnter()
{ {
keyboardInput.sendKeyboardEnter(); keyboardinput::sendKeyboardEnter();
} }
void UtilitiesTabController::sendKeyboardAltEnter() void UtilitiesTabController::sendKeyboardAltEnter()
{ {
keyboardInput.sendKeyboardAltEnter(); keyboardinput::sendKeyboardAltEnter();
} }
void UtilitiesTabController::sendKeyboardAltTab() void UtilitiesTabController::sendKeyboardAltTab()
{ {
keyboardInput.sendKeyboardAltTab(); keyboardinput::sendKeyboardAltTab();
} }
void UtilitiesTabController::sendKeyboardBackspace( const int count ) void UtilitiesTabController::sendKeyboardBackspace( const int count )
{ {
keyboardInput.sendKeyboardBackspace( count ); keyboardinput::sendKeyboardBackspace( count );
} }
void UtilitiesTabController::sendMediaNextSong() void UtilitiesTabController::sendMediaNextSong()
{ {
keyboardInput.sendMediaNextSong(); keyboardinput::sendMediaNextSong();
} }
void UtilitiesTabController::sendMediaPreviousSong() void UtilitiesTabController::sendMediaPreviousSong()
{ {
keyboardInput.sendMediaPreviousSong(); keyboardinput::sendMediaPreviousSong();
} }
void UtilitiesTabController::sendMediaPausePlay() void UtilitiesTabController::sendMediaPausePlay()
{ {
keyboardInput.sendMediaPausePlay(); keyboardinput::sendMediaPausePlay();
} }
void UtilitiesTabController::sendMediaStopSong() void UtilitiesTabController::sendMediaStopSong()
{ {
keyboardInput.sendMediaStopSong(); keyboardinput::sendMediaStopSong();
} }
bool UtilitiesTabController::alarmEnabled() const bool UtilitiesTabController::alarmEnabled() const
@@ -46,12 +46,6 @@ private:
int m_batteryState[vr::k_unMaxTrackedDeviceCount]; int m_batteryState[vr::k_unMaxTrackedDeviceCount];
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount]; bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
#ifdef WIN32
KeyboardInputWindows keyboardInput;
#else
KeyboardInputDummy keyboardInput;
#endif
public: public:
void initStage1(); void initStage1();
void initStage2( OverlayController* var_parent, QQuickWindow* var_widget ); void initStage2( OverlayController* var_parent, QQuickWindow* var_widget );
@@ -4,53 +4,53 @@
// parameter. The cast is to get GCC to shut up about it. // parameter. The cast is to get GCC to shut up about it.
#define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) ) #define UNREFERENCED_PARAMETER( P ) static_cast<void>( ( P ) )
namespace advsettings namespace keyboardinput
{ {
void KeyboardInputDummy::sendKeyboardInput( QString input ) void sendKeyboardInput( QString input )
{ {
// noop // noop
UNREFERENCED_PARAMETER( input ); UNREFERENCED_PARAMETER( input );
} }
void KeyboardInputDummy::sendKeyboardEnter() void sendKeyboardEnter()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendKeyboardBackspace( const int count ) void sendKeyboardBackspace( const int count )
{ {
// noop // noop
UNREFERENCED_PARAMETER( count ); UNREFERENCED_PARAMETER( count );
} }
void KeyboardInputDummy::sendKeyboardAltTab() void sendKeyboardAltTab()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendKeyboardAltEnter() void sendKeyboardAltEnter()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendMediaNextSong() void sendMediaNextSong()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendMediaPreviousSong() void sendMediaPreviousSong()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendMediaPausePlay() void sendMediaPausePlay()
{ {
// noop // noop
} }
void KeyboardInputDummy::sendMediaStopSong() void sendMediaStopSong()
{ {
// noop // noop
} }
} // namespace advsettings } // namespace keyboardinput
@@ -1,25 +1,18 @@
#ifndef KEYBOARDINPUTDUMMY_H #pragma once
#define KEYBOARDINPUTDUMMY_H
#include "KeyboardInput.h" #include <vector>
#include <QString>
// application namespace namespace keyboardinput
namespace advsettings
{ {
class KeyboardInputDummy void sendKeyboardInput( QString input );
{ void sendKeyboardEnter();
public: void sendKeyboardBackspace( const int count );
void sendKeyboardInput( QString input ); void sendKeyboardAltTab();
void sendKeyboardEnter(); void sendKeyboardAltEnter();
void sendKeyboardBackspace( const int count ); void sendMediaNextSong();
void sendKeyboardAltTab(); void sendMediaPreviousSong();
void sendKeyboardAltEnter(); void sendMediaPausePlay();
void sendMediaNextSong(); void sendMediaStopSong();
void sendMediaPreviousSong();
void sendMediaPausePlay();
void sendMediaStopSong();
};
} // namespace advsettings } // namespace keyboardinput
#endif // KEYBOARDINPUTDUMMY_H
@@ -2,7 +2,7 @@
#include <Windows.h> #include <Windows.h>
#include "easylogging++.h" #include "easylogging++.h"
namespace advsettings namespace keyboardinput
{ {
/*! /*!
Represents the state of a keyboard button press. Can be either Up or Down. Represents the state of a keyboard button press. Can be either Up or Down.
@@ -127,7 +127,7 @@ void sendKeyPressAndRelease( const WORD virtualKeyCode )
sendKeyboardInputRaw( numberOfActions, actions ); sendKeyboardInputRaw( numberOfActions, actions );
} }
void KeyboardInputWindows::sendKeyboardInput( QString input ) void sendKeyboardInput( QString input )
{ {
int len = input.length(); int len = input.length();
if ( len > 0 ) if ( len > 0 )
@@ -202,7 +202,7 @@ void KeyboardInputWindows::sendKeyboardInput( QString input )
/*! /*!
Sends a single Enter keypress to Windows. Sends a single Enter keypress to Windows.
*/ */
void KeyboardInputWindows::sendKeyboardEnter() void sendKeyboardEnter()
{ {
sendKeyPressAndRelease( VK_RETURN ); sendKeyPressAndRelease( VK_RETURN );
} }
@@ -211,7 +211,7 @@ void KeyboardInputWindows::sendKeyboardEnter()
Sends count amount of backspaces to Windows. count of 0 or below will do Sends count amount of backspaces to Windows. count of 0 or below will do
nothing. nothing.
*/ */
void KeyboardInputWindows::sendKeyboardBackspace( const int count ) void sendKeyboardBackspace( const int count )
{ {
// We can only send a positive amount of key presses. // We can only send a positive amount of key presses.
if ( count <= 0 ) if ( count <= 0 )
@@ -232,7 +232,7 @@ Used for tabbing out of game windows blocking other programs on desktop while in
VR. At least one use case was tabbing out of a fullscreen game to be able to use VR. At least one use case was tabbing out of a fullscreen game to be able to use
a music player. a music player.
*/ */
void KeyboardInputWindows::sendKeyboardAltTab() void sendKeyboardAltTab()
{ {
constexpr auto altKey = VK_MENU; constexpr auto altKey = VK_MENU;
constexpr auto tabKey = VK_TAB; constexpr auto tabKey = VK_TAB;
@@ -256,7 +256,7 @@ Sends an Alt + Tab combination to Windows.
Used for toggling full screen on games and various applications that appear on Used for toggling full screen on games and various applications that appear on
the desktop. the desktop.
*/ */
void KeyboardInputWindows::sendKeyboardAltEnter() void sendKeyboardAltEnter()
{ {
constexpr auto altKey = VK_MENU; constexpr auto altKey = VK_MENU;
constexpr auto enterKey = VK_RETURN; constexpr auto enterKey = VK_RETURN;
@@ -277,7 +277,7 @@ void KeyboardInputWindows::sendKeyboardAltEnter()
/*! /*!
Sends a media key Next Song button to Windows. Sends a media key Next Song button to Windows.
*/ */
void KeyboardInputWindows::sendMediaNextSong() void sendMediaNextSong()
{ {
sendKeyPressAndRelease( VK_MEDIA_NEXT_TRACK ); sendKeyPressAndRelease( VK_MEDIA_NEXT_TRACK );
} }
@@ -285,7 +285,7 @@ void KeyboardInputWindows::sendMediaNextSong()
/*! /*!
Sends a media key Previous Song button to Windows. Sends a media key Previous Song button to Windows.
*/ */
void KeyboardInputWindows::sendMediaPreviousSong() void sendMediaPreviousSong()
{ {
sendKeyPressAndRelease( VK_MEDIA_PREV_TRACK ); sendKeyPressAndRelease( VK_MEDIA_PREV_TRACK );
} }
@@ -293,7 +293,7 @@ void KeyboardInputWindows::sendMediaPreviousSong()
/*! /*!
Sends a media key Play/Pause button to Windows. Sends a media key Play/Pause button to Windows.
*/ */
void KeyboardInputWindows::sendMediaPausePlay() void sendMediaPausePlay()
{ {
sendKeyPressAndRelease( VK_MEDIA_PLAY_PAUSE ); sendKeyPressAndRelease( VK_MEDIA_PLAY_PAUSE );
} }
@@ -301,9 +301,9 @@ void KeyboardInputWindows::sendMediaPausePlay()
/*! /*!
Sends a media key Stop button to Windows. Sends a media key Stop button to Windows.
*/ */
void KeyboardInputWindows::sendMediaStopSong() void sendMediaStopSong()
{ {
sendKeyPressAndRelease( VK_MEDIA_STOP ); sendKeyPressAndRelease( VK_MEDIA_STOP );
} }
} // namespace advsettings } // namespace keyboardinput
@@ -1,25 +1,18 @@
#ifndef KEYBOARDINPUTWINDOWS_H #pragma once
#define KEYBOARDINPUTWINDOWS_H
#include "KeyboardInput.h" #include <vector>
#include <QString>
// application namespace namespace keyboardinput
namespace advsettings
{ {
class KeyboardInputWindows void sendKeyboardInput( QString input );
{ void sendKeyboardEnter();
public: void sendKeyboardBackspace( const int count );
void sendKeyboardInput( QString input ); void sendKeyboardAltTab();
void sendKeyboardEnter(); void sendKeyboardAltEnter();
void sendKeyboardBackspace( const int count ); void sendMediaNextSong();
void sendKeyboardAltTab(); void sendMediaPreviousSong();
void sendKeyboardAltEnter(); void sendMediaPausePlay();
void sendMediaNextSong(); void sendMediaStopSong();
void sendMediaPreviousSong();
void sendMediaPausePlay();
void sendMediaStopSong();
};
} // namespace advsettings } // namespace keyboardinput
#endif // KEYBOARDINPUTWINDOWS_H