|
|
|
@ -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
|
|
|
|
|