MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / init_vigem

Method init_vigem

source/MaaGamepadControlUnit/Input/ViGEmInput.cpp:94–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94bool ViGEmInput::init_vigem()
95{
96 if (!load_vigem_library()) {
97 return false;
98 }
99
100 vigem_client_ = fn_vigem_alloc_();
101 if (!vigem_client_) {
102 LogError << "Failed to allocate ViGEm client";
103 return false;
104 }
105
106 auto ret = fn_vigem_connect_(vigem_client_);
107 if (ret != VIGEM_ERROR_NONE) {
108 LogError << "Failed to connect to ViGEm bus, error:" << std::hex << ret;
109 cleanup_vigem();
110 return false;
111 }
112
113 vigem_target_ = alloc_target();
114 if (!vigem_target_) {
115 LogError << "Failed to allocate ViGEm target";
116 cleanup_vigem();
117 return false;
118 }
119
120 ret = fn_vigem_target_add_(vigem_client_, vigem_target_);
121 if (ret != VIGEM_ERROR_NONE) {
122 LogError << "Failed to add ViGEm target, error:" << std::hex << ret;
123 cleanup_vigem();
124 return false;
125 }
126
127 LogInfo << "ViGEm gamepad connected, type:" << (type_ == MaaGamepadType_Xbox360 ? "Xbox360" : "DualShock4");
128 return true;
129}
130
131void ViGEmInput::cleanup_vigem()
132{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected