More logs and clarify what the VID/PID id hack does

pull/130/head
Peter Repukat 3 years ago
parent 0232b73d19
commit c7467003fb

@ -58,42 +58,47 @@ void InputRedirector::runLoop()
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
XINPUT_STATE state{};
if (XInputGetState(i, &state) == ERROR_SUCCESS) {
if (vt_x360_[i] != nullptr) {
vigem_target_x360_update(driver_, vt_x360_[i], *reinterpret_cast<XUSB_REPORT *>(&state.Gamepad));
} else {
vt_x360_[i] = vigem_target_x360_alloc();
// By using VID and PID of Valve's SteamController, Steam doesn't give us ANOTHER "fake" XInput device
// By using VID and PID of Valve's Emulated Controller
// ( https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices )
// Steam doesn't give us ANOTHER "fake" XInput device
// -> Leading to endless pain and suffering.
// Or really, leading to plugging in one virtual controller after another and mirroring inputs
// Also annoying the shit out of the user when they open the overlay as steam prompts to setup new XInput devices
// Also avoiding any fake inputs from Valve's default controller profile
// -> Leading to endless pain and suffering
//
// this surprisingly works, even with no SteamController connected
vigem_target_set_vid(vt_x360_[i], 0x28de); //Valve SteamController VID
vigem_target_set_pid(vt_x360_[i], 0x1102); //Valve SteamController PID
// Additonaly, Steam does pick up the emulated controller this way, and Hides it from our application
// but Steam ONLY does this if it is configured to support X360 controller rebinding!!!
// Otherwise, this application (GloSC/GlosSI) will pickup the emulated controller as well!
vigem_target_set_vid(vt_x360_[i], 0x28de); //VALVE_DIRECTINPUT_GAMEPAD_VID
vigem_target_set_pid(vt_x360_[i], 0x11FF); //VALVE_DIRECTINPUT_GAMEPAD_PID
// TODO: MAYBE!: In a future version, use something like OpenXInput
//and filter out emulated controllers to support a greater amount of controllers simultaneously
const int target_add_res = vigem_target_add(driver_, vt_x360_[i]);
if (target_add_res == VIGEM_ERROR_TARGET_UNINITIALIZED) {
vt_x360_[i] = vigem_target_x360_alloc();
}
if (target_add_res == VIGEM_ERROR_NONE) {
spdlog::info("Plugged in controller {}", vigem_target_get_index(vt_x360_[i]));
spdlog::info("Plugged in controller {}, {}", i, vigem_target_get_index(vt_x360_[i]));
const auto callback_register_res = vigem_target_x360_register_notification(
driver_,
vt_x360_[i],
&InputRedirector::controllerCallback,
nullptr);
if (!VIGEM_SUCCESS(callback_register_res)) {
spdlog::error("Registering controller {} for notification failed with error code: {1:#x}", vigem_target_get_index(vt_x360_[i]), callback_register_res);
spdlog::error("Registering controller {}, {} for notification failed with error code: {:#x}", i, vigem_target_get_index(vt_x360_[i]), callback_register_res);
}
}
}
} else {
if (vt_x360_[i] != nullptr) {
if (VIGEM_SUCCESS(vigem_target_remove(driver_, vt_x360_[i]))) {
spdlog::info("Unplugged controller {}", vigem_target_get_index(vt_x360_[i]));
spdlog::info("Unplugged controller {}, {}", i, vigem_target_get_index(vt_x360_[i]));
vt_x360_[i] = nullptr;
}
}

Loading…
Cancel
Save