diff --git a/GlosSITarget/.clang-format b/GlosSITarget/.clang-format
index fdf9b92..dc813fd 100644
--- a/GlosSITarget/.clang-format
+++ b/GlosSITarget/.clang-format
@@ -3,4 +3,5 @@ IndentWidth: 4
BreakBeforeBraces: "Stroustrup"
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
-ColumnLimit: 0
\ No newline at end of file
+ColumnLimit: 0
+PointerAlignment: "Left"
\ No newline at end of file
diff --git a/GlosSITarget/GlosSITarget.vcxproj b/GlosSITarget/GlosSITarget.vcxproj
index 13b21bb..abbbfa6 100644
--- a/GlosSITarget/GlosSITarget.vcxproj
+++ b/GlosSITarget/GlosSITarget.vcxproj
@@ -129,7 +129,7 @@
Console
true
- sfml-window-d.lib;sfml-system-d.lib;sfml-graphics-d.lib;dwmapi.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)
+ hid.lib;Cfgmgr32.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-graphics-d.lib;dwmapi.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)
@@ -147,11 +147,12 @@
true
true
true
- xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)
+ hid.lib;Cfgmgr32.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)
+
@@ -160,6 +161,7 @@
+
diff --git a/GlosSITarget/GlosSITarget.vcxproj.filters b/GlosSITarget/GlosSITarget.vcxproj.filters
index 7ac33ba..8a34bf5 100644
--- a/GlosSITarget/GlosSITarget.vcxproj.filters
+++ b/GlosSITarget/GlosSITarget.vcxproj.filters
@@ -33,6 +33,9 @@
Source Files
+
+ Source Files
+
@@ -53,6 +56,9 @@
Header Files
+
+ Header Files
+
diff --git a/GlosSITarget/InputRedirector.cpp b/GlosSITarget/InputRedirector.cpp
index e5d46be..0a09626 100644
--- a/GlosSITarget/InputRedirector.cpp
+++ b/GlosSITarget/InputRedirector.cpp
@@ -1,3 +1,18 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#include "InputRedirector.h"
#include
@@ -11,7 +26,8 @@ InputRedirector::InputRedirector()
vigem_connected_ = VIGEM_SUCCESS(vigem_connect(driver_));
if (vigem_connected_) {
spdlog::debug("Connected to ViGEm");
- } else {
+ }
+ else {
spdlog::error("Error initializing ViGEm");
// TODO: setup some mechanic to draw to window...
}
@@ -39,7 +55,7 @@ void InputRedirector::stop()
{
run_ = false;
if (vigem_connected_) {
- for (const auto &target : vt_x360_) {
+ for (const auto& target : vt_x360_) {
vigem_target_remove(driver_, target);
}
}
@@ -59,8 +75,9 @@ void InputRedirector::runLoop()
XINPUT_STATE state{};
if (XInputGetState(i, &state) == ERROR_SUCCESS) {
if (vt_x360_[i] != nullptr) {
- vigem_target_x360_update(driver_, vt_x360_[i], *reinterpret_cast(&state.Gamepad));
- } else {
+ vigem_target_x360_update(driver_, vt_x360_[i], *reinterpret_cast(&state.Gamepad));
+ }
+ else {
vt_x360_[i] = vigem_target_x360_alloc();
// By using VID and PID of Valve's Emulated Controller
// ( https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices )
@@ -95,7 +112,8 @@ void InputRedirector::runLoop()
}
}
}
- } else {
+ }
+ else {
if (vt_x360_[i] != nullptr) {
if (VIGEM_SUCCESS(vigem_target_remove(driver_, vt_x360_[i]))) {
spdlog::info("Unplugged controller {}, {}", i, vigem_target_get_index(vt_x360_[i]));
diff --git a/GlosSITarget/InputRedirector.h b/GlosSITarget/InputRedirector.h
index b810b4a..659e29a 100644
--- a/GlosSITarget/InputRedirector.h
+++ b/GlosSITarget/InputRedirector.h
@@ -1,10 +1,25 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#pragma once
#include
#ifdef _WIN32
#define NOMINMAX
#include
-#include
#include
+#include
#endif
class InputRedirector {
diff --git a/GlosSITarget/OverlayDetector.cpp b/GlosSITarget/OverlayDetector.cpp
index c77f17a..8fa4921 100644
--- a/GlosSITarget/OverlayDetector.cpp
+++ b/GlosSITarget/OverlayDetector.cpp
@@ -22,7 +22,6 @@ limitations under the License.
#include
#endif
-
OverlayDetector::OverlayDetector(std::function overlay_changed)
: overlay_changed_(std::move(overlay_changed))
{
@@ -68,5 +67,4 @@ void OverlayDetector::update()
}
}
#endif
-
}
\ No newline at end of file
diff --git a/GlosSITarget/OverlayDetector.h b/GlosSITarget/OverlayDetector.h
index b0b002d..8a2c80f 100644
--- a/GlosSITarget/OverlayDetector.h
+++ b/GlosSITarget/OverlayDetector.h
@@ -24,7 +24,6 @@ limitations under the License.
class OverlayDetector {
public:
-
explicit OverlayDetector(
std::function overlay_changed = [](bool) {});
void update();
@@ -35,5 +34,4 @@ class OverlayDetector {
bool overlay_open_ = false;
int msg_count_ = 0;
#endif
-
};
diff --git a/GlosSITarget/SteamTarget.cpp b/GlosSITarget/SteamTarget.cpp
index 57a92a3..267a64c 100644
--- a/GlosSITarget/SteamTarget.cpp
+++ b/GlosSITarget/SteamTarget.cpp
@@ -37,7 +37,7 @@ HWND keepForegroundWindow()
#endif
-SteamTarget::SteamTarget(int argc, char *argv[])
+SteamTarget::SteamTarget(int argc, char* argv[])
: window_([this] { run_ = false; }, getScreenshotHotkey()),
detector_([this](bool overlay_open) { onOverlayChanged(overlay_open); }), target_window_handle_(window_.getSystemHandle())
{
@@ -229,12 +229,12 @@ void SteamTarget::overlayHotkeyWorkaround()
{
static bool pressed = false;
if (std::ranges::all_of(overlay_hotkey_,
- [](const auto &key) {
+ [](const auto& key) {
return sf::Keyboard::isKeyPressed(keymap::sfkey[key]);
})) {
spdlog::debug("Detected overlay hotkey(s)");
pressed = true;
- std::ranges::for_each(overlay_hotkey_, [this](const auto &key) {
+ std::ranges::for_each(overlay_hotkey_, [this](const auto& key) {
#ifdef _WIN32
PostMessage(target_window_handle_, WM_KEYDOWN, keymap::winkey[key], 0);
#else
@@ -245,7 +245,7 @@ void SteamTarget::overlayHotkeyWorkaround()
}
else if (pressed) {
pressed = false;
- std::ranges::for_each(overlay_hotkey_, [this](const auto &key) {
+ std::ranges::for_each(overlay_hotkey_, [this](const auto& key) {
#ifdef _WIN32
PostMessage(target_window_handle_, WM_KEYUP, keymap::winkey[key], 0);
#else
diff --git a/GlosSITarget/SteamTarget.h b/GlosSITarget/SteamTarget.h
index 1f7d2db..0270450 100644
--- a/GlosSITarget/SteamTarget.h
+++ b/GlosSITarget/SteamTarget.h
@@ -15,14 +15,17 @@ limitations under the License.
*/
#pragma once
-#include "InputRedirector.h"
#include "OverlayDetector.h"
#include "TargetWindow.h"
+#ifdef _WIN32
+#include "InputRedirector.h"
+#endif
+
class SteamTarget {
public:
- explicit SteamTarget(int argc, char *argv[]);
+ explicit SteamTarget(int argc, char* argv[]);
int run();
private:
diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp
index 3cedb5b..9cadc84 100644
--- a/GlosSITarget/TargetWindow.cpp
+++ b/GlosSITarget/TargetWindow.cpp
@@ -17,7 +17,6 @@ limitations under the License.
#include "steam_sf_keymap.h"
-#include
#include
#include
@@ -119,7 +118,7 @@ void TargetWindow::screenShotWorkaround()
{
#ifdef _WIN32
if (std::ranges::all_of(screenshot_keys_,
- [](const auto &key) {
+ [](const auto& key) {
return sf::Keyboard::isKeyPressed(keymap::sfkey[key]);
})) {
spdlog::debug("Detected screenshot hotkey(s); Taking screenshot");
@@ -168,10 +167,10 @@ void TargetWindow::screenShotWorkaround()
sprite.setTexture(texture);
spdlog::debug("Sending screenshot key events and rendering screen...");
- std::ranges::for_each(screenshot_keys_, [this](const auto &key) {
+ std::ranges::for_each(screenshot_keys_, [this](const auto& key) {
PostMessage(window_.getSystemHandle(), WM_KEYDOWN, keymap::winkey[key], 0);
});
- std::ranges::for_each(screenshot_keys_, [this](const auto &key) {
+ std::ranges::for_each(screenshot_keys_, [this](const auto& key) {
PostMessage(window_.getSystemHandle(), WM_KEYUP, keymap::winkey[key], 0);
});
//actually run event loop, so steam gets notified about keys.
diff --git a/GlosSITarget/TargetWindow.h b/GlosSITarget/TargetWindow.h
index 0057b07..9e09606 100644
--- a/GlosSITarget/TargetWindow.h
+++ b/GlosSITarget/TargetWindow.h
@@ -26,7 +26,6 @@ using WindowHandle = HWND;
using WindowHandle = int; // ???
#endif
-
class TargetWindow {
public:
explicit TargetWindow(
@@ -56,5 +55,4 @@ class TargetWindow {
const std::function on_close_;
sf::RenderWindow window_;
std::vector screenshot_keys_;
-
};
diff --git a/GlosSITarget/main.cpp b/GlosSITarget/main.cpp
index 99bd64b..8451df8 100644
--- a/GlosSITarget/main.cpp
+++ b/GlosSITarget/main.cpp
@@ -27,17 +27,16 @@ limitations under the License.
#define CONSOLE
#ifdef _WIN32
#ifdef CONSOLE
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
#else
int CALLBACK WinMain(
- _In_ HINSTANCE hInstance,
- _In_ HINSTANCE hPrevInstance,
- _In_ LPSTR lpCmdLine,
- _In_ int nCmdShow
-)
+ _In_ HINSTANCE hInstance,
+ _In_ HINSTANCE hPrevInstance,
+ _In_ LPSTR lpCmdLine,
+ _In_ int nCmdShow)
#endif
#else
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
#endif
{
const auto console_sink = std::make_shared();
diff --git a/GlosSITarget/steam_sf_keymap.h b/GlosSITarget/steam_sf_keymap.h
index 4984037..da267d8 100644
--- a/GlosSITarget/steam_sf_keymap.h
+++ b/GlosSITarget/steam_sf_keymap.h
@@ -1,3 +1,18 @@
+/*
+Copyright 2021 Peter Repukat - FlatspotSoftware
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
#pragma once
#include
#include