Fix writing settings from GlosSITarget

pull/183/head
Peter Repukat 2 years ago
parent 315a58cfc1
commit a1397e05da

@ -50,13 +50,11 @@ void InputRedirector::run()
{
run_ = vigem_connected_;
controller_thread_ = std::thread(&InputRedirector::runLoop, this);
max_controller_count_ = Settings::controller.maxControllers;
use_real_vid_pid_ = Settings::devices.realDeviceIds;
#ifdef _WIN32
Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) {
ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver);
ImGui::Begin("Controller Emulation");
int countcopy = max_controller_count_;
int countcopy = Settings::controller.maxControllers;
ImGui::Text("Max. controller count");
ImGui::InputInt("##Max. controller count", &countcopy, 1, 1);
if (countcopy > XUSER_MAX_COUNT) {
@ -65,7 +63,7 @@ void InputRedirector::run()
if (countcopy < 0) {
countcopy = 0;
}
max_controller_count_ = countcopy;
Settings::controller.maxControllers = countcopy;
bool enable_rumbe_copy = enable_rumble_;
ImGui::Checkbox("Enable Rumble", &enable_rumbe_copy);
enable_rumble_ = enable_rumbe_copy;
@ -76,12 +74,12 @@ void InputRedirector::run()
ImGui::Text("to prevent having multiple mirrored controllers plugged in");
ImGui::Spacing();
ImGui::Text("If enabled, Device hiding won't work! Use \"Max. Controller count\"-setting.");
bool use_real_copy = use_real_vid_pid_;
bool use_real_copy = Settings::devices.realDeviceIds;
ImGui::Checkbox("Use real USB-IDs", &use_real_copy);
if (use_real_vid_pid_ != use_real_copy) {
if (Settings::devices.realDeviceIds != use_real_copy) {
use_real_vid_pid_changed_ = true;
}
use_real_vid_pid_ = use_real_copy;
Settings::devices.realDeviceIds = use_real_copy;
}
ImGui::End();
});
@ -115,12 +113,12 @@ void InputRedirector::runLoop()
unplugVigemPad(i);
}
}
if (max_controller_count_ < XUSER_MAX_COUNT) {
for (int i = max_controller_count_; i < XUSER_MAX_COUNT; i++) {
if (Settings::controller.maxControllers < XUSER_MAX_COUNT) {
for (int i = Settings::controller.maxControllers; i < XUSER_MAX_COUNT; i++) {
unplugVigemPad(i);
}
}
for (int i = 0; i < XUSER_MAX_COUNT && i < max_controller_count_; i++) {
for (int i = 0; i < XUSER_MAX_COUNT && i < Settings::controller.maxControllers; i++) {
XINPUT_STATE state{};
if (XInputGetState(i, &state) == ERROR_SUCCESS) {
if (vt_pad_[i] != nullptr) {
@ -160,7 +158,7 @@ void InputRedirector::runLoop()
// Otherwise, this application (GloSC/GlosSI) will pickup the emulated controller as well!
// This however is configurable withon GlosSI overlay;
// Multiple controllers can be worked around with by setting max count.
if (!use_real_vid_pid_) {
if (!Settings::devices.realDeviceIds) {
vigem_target_set_vid(vt_pad_[i], 0x28de); //VALVE_DIRECTINPUT_GAMEPAD_VID
//vigem_target_set_pid(vt_pad_[i], 0x11FF); //VALVE_DIRECTINPUT_GAMEPAD_PID
vigem_target_set_pid(vt_pad_[i], 0x028E); // XBOX 360 Controller

@ -41,9 +41,7 @@ class InputRedirector {
PVIGEM_CLIENT driver_;
// variables for overlay element; run in different thread
std::atomic<int> max_controller_count_ = XUSER_MAX_COUNT;
static inline std::atomic<bool> enable_rumble_ = true;
static inline std::atomic<bool> use_real_vid_pid_ = false;
static inline std::atomic<bool> use_real_vid_pid_changed_ = false;
bool vigem_connected_;

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,9,1014000053108
PRODUCTVERSION 0,0,9,1014000053108
FILEVERSION 0,0,9,1017003150580
PRODUCTVERSION 0,0,9,1017003150580
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - SteamTarget"
VALUE "FileVersion", "0.0.9.1-14-gda531f8"
VALUE "FileVersion", "0.0.9.1-17-g315a58c"
VALUE "InternalName", "GlosSITarget"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSITarget.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.0.9.1-14-gda531f8"
VALUE "ProductVersion", "0.0.9.1-17-g315a58c"
END
END
BLOCK "VarFileInfo"

@ -48,15 +48,16 @@ TargetWindow::TargetWindow(
screenshot_keys_(std::move(screenshot_hotkey)),
on_window_changed_(std::move(on_window_changed))
{
createWindow(Settings::window.windowMode);
createWindow();
Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) {
ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver);
bool windowed_copy = windowed_;
bool windowed_copy = Settings::window.windowMode;
ImGui::Begin("Window mode");
if (ImGui::Checkbox("Window mode", &windowed_copy)) {
toggle_window_mode_after_frame_ = true;
}
Settings::window.windowMode = windowed_copy;
ImGui::End();
});
@ -102,7 +103,7 @@ void TargetWindow::update()
overlay_->update();
window_.display();
if (toggle_window_mode_after_frame_) {
createWindow(!windowed_);
createWindow();
}
// As SFML screws us out of most windows-events, just poll resolution every once in a while
// If changed, recreate window.
@ -110,7 +111,7 @@ void TargetWindow::update()
// (WHY?!)
if (check_resolution_clock_.getElapsedTime().asSeconds() > RES_CHECK_SECONDS) {
if (sf::VideoMode::getDesktopMode().width != old_desktop_mode_.width) {
createWindow(windowed_);
createWindow();
}
check_resolution_clock_.restart();
}
@ -238,17 +239,16 @@ WORD TargetWindow::GetWindowDPI(HWND hWnd)
}
#endif
void TargetWindow::createWindow(bool window_mode)
void TargetWindow::createWindow()
{
toggle_window_mode_after_frame_ = false;
auto desktop_mode = sf::VideoMode::getDesktopMode();
spdlog::info("Detected resolution: {}x{}", desktop_mode.width, desktop_mode.height);
old_desktop_mode_ = desktop_mode;
if (window_mode) {
if (Settings::window.windowMode) {
spdlog::info("Creating Overlay window...");
window_.create(sf::VideoMode(desktop_mode.width * 0.75, desktop_mode.height * 0.75, 32), "GlosSITarget");
windowed_ = true;
}
else {
#ifdef _WIN32
@ -270,12 +270,11 @@ void TargetWindow::createWindow(bool window_mode)
#else
window_.create(desktop_mode, "GlosSITarget", sf::Style::None);
#endif
windowed_ = false;
}
window_.setActive(true);
spdlog::debug("Window position: {}x{}", window_.getPosition().x, window_.getPosition().y);
if (!window_mode) {
if (!Settings::window.windowMode) {
spdlog::info("Resizing window to 1px smaller than fullscreen...");
window_.setSize(sf::Vector2u(desktop_mode.width - 1, desktop_mode.height - 1));
}
@ -315,7 +314,7 @@ void TargetWindow::createWindow(bool window_mode)
}
overlay_ = std::make_shared<Overlay>(
window_, [this]() { close(); }, toggle_overlay_state_, windowed_);
window_, [this]() { close(); }, toggle_overlay_state_, Settings::window.windowMode);
ImGuiIO& io = ImGui::GetIO();
io.FontGlobalScale = dpi / 96.f;

@ -77,8 +77,7 @@ class TargetWindow {
std::shared_ptr<Overlay> overlay_;
void createWindow(bool window_mode);
void createWindow();
bool windowed_ = false;
bool toggle_window_mode_after_frame_ = false;
};

Loading…
Cancel
Save