mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #8033 from SamGondelman/xboxFix
Game pads work after falling asleep and being reactivated
This commit is contained in:
commit
fc5214c938
5 changed files with 63 additions and 63 deletions
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "XBox to Standard",
|
"name": "XBox to Standard",
|
||||||
"channels": [
|
"channels": [
|
||||||
{ "from": "GamePad.LY", "to": "Standard.LY" },
|
{ "from": "GamePad.LY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LY" },
|
||||||
{ "from": "GamePad.LX", "to": "Standard.LX" },
|
{ "from": "GamePad.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" },
|
||||||
{ "from": "GamePad.LT", "to": "Standard.LT" },
|
{ "from": "GamePad.LT", "to": "Standard.LT" },
|
||||||
{ "from": "GamePad.LB", "to": "Standard.LB" },
|
{ "from": "GamePad.LB", "to": "Standard.LB" },
|
||||||
{ "from": "GamePad.LS", "to": "Standard.LS" },
|
{ "from": "GamePad.LS", "to": "Standard.LS" },
|
||||||
|
|
||||||
{ "from": "GamePad.RY", "to": "Standard.RY" },
|
{ "from": "GamePad.RY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RY" },
|
||||||
{ "from": "GamePad.RX", "to": "Standard.RX" },
|
{ "from": "GamePad.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" },
|
||||||
{ "from": "GamePad.RT", "to": "Standard.RT" },
|
{ "from": "GamePad.RT", "to": "Standard.RT" },
|
||||||
{ "from": "GamePad.RB", "to": "Standard.RB" },
|
{ "from": "GamePad.RB", "to": "Standard.RB" },
|
||||||
{ "from": "GamePad.RS", "to": "Standard.RS" },
|
{ "from": "GamePad.RS", "to": "Standard.RS" },
|
||||||
|
|
|
@ -62,14 +62,6 @@ namespace controller {
|
||||||
UserInputMapper::~UserInputMapper() {
|
UserInputMapper::~UserInputMapper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserInputMapper::recordDeviceOfType(const QString& deviceName) {
|
|
||||||
if (!_deviceCounts.contains(deviceName)) {
|
|
||||||
_deviceCounts[deviceName] = 0;
|
|
||||||
}
|
|
||||||
_deviceCounts[deviceName] += 1;
|
|
||||||
return _deviceCounts[deviceName];
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserInputMapper::registerDevice(InputDevice::Pointer device) {
|
void UserInputMapper::registerDevice(InputDevice::Pointer device) {
|
||||||
Locker locker(_lock);
|
Locker locker(_lock);
|
||||||
if (device->_deviceID == Input::INVALID_DEVICE) {
|
if (device->_deviceID == Input::INVALID_DEVICE) {
|
||||||
|
@ -77,8 +69,6 @@ void UserInputMapper::registerDevice(InputDevice::Pointer device) {
|
||||||
}
|
}
|
||||||
const auto& deviceID = device->_deviceID;
|
const auto& deviceID = device->_deviceID;
|
||||||
|
|
||||||
recordDeviceOfType(device->getName());
|
|
||||||
|
|
||||||
qCDebug(controllers) << "Registered input device <" << device->getName() << "> deviceID = " << deviceID;
|
qCDebug(controllers) << "Registered input device <" << device->getName() << "> deviceID = " << deviceID;
|
||||||
|
|
||||||
for (const auto& inputMapping : device->getAvailableInputs()) {
|
for (const auto& inputMapping : device->getAvailableInputs()) {
|
||||||
|
@ -134,6 +124,15 @@ void UserInputMapper::removeDevice(int deviceID) {
|
||||||
_mappingsByDevice.erase(mappingsEntry);
|
_mappingsByDevice.erase(mappingsEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& inputMapping : device->getAvailableInputs()) {
|
||||||
|
const auto& input = inputMapping.first;
|
||||||
|
auto endpoint = _endpointsByInput.find(input);
|
||||||
|
if (endpoint != _endpointsByInput.end()) {
|
||||||
|
_inputsByEndpoint.erase((*endpoint).second);
|
||||||
|
_endpointsByInput.erase(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_registeredDevices.erase(proxyEntry);
|
_registeredDevices.erase(proxyEntry);
|
||||||
|
|
||||||
emit hardwareChanged();
|
emit hardwareChanged();
|
||||||
|
|
|
@ -143,9 +143,6 @@ namespace controller {
|
||||||
std::vector<Pose> _poseStates = std::vector<Pose>(toInt(Action::NUM_ACTIONS));
|
std::vector<Pose> _poseStates = std::vector<Pose>(toInt(Action::NUM_ACTIONS));
|
||||||
std::vector<float> _lastStandardStates = std::vector<float>();
|
std::vector<float> _lastStandardStates = std::vector<float>();
|
||||||
|
|
||||||
int recordDeviceOfType(const QString& deviceName);
|
|
||||||
QHash<const QString&, int> _deviceCounts;
|
|
||||||
|
|
||||||
static float getValue(const EndpointPointer& endpoint, bool peek = false);
|
static float getValue(const EndpointPointer& endpoint, bool peek = false);
|
||||||
static Pose getPose(const EndpointPointer& endpoint, bool peek = false);
|
static Pose getPose(const EndpointPointer& endpoint, bool peek = false);
|
||||||
|
|
||||||
|
|
|
@ -81,53 +81,55 @@ bool Joystick::triggerHapticPulse(float strength, float duration, controller::Ha
|
||||||
|
|
||||||
controller::Input::NamedVector Joystick::getAvailableInputs() const {
|
controller::Input::NamedVector Joystick::getAvailableInputs() const {
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
static const Input::NamedVector availableInputs{
|
if (_availableInputs.length() == 0) {
|
||||||
makePair(A, "A"),
|
_availableInputs = {
|
||||||
makePair(B, "B"),
|
makePair(A, "A"),
|
||||||
makePair(X, "X"),
|
makePair(B, "B"),
|
||||||
makePair(Y, "Y"),
|
makePair(X, "X"),
|
||||||
// DPad
|
makePair(Y, "Y"),
|
||||||
makePair(DU, "DU"),
|
// DPad
|
||||||
makePair(DD, "DD"),
|
makePair(DU, "DU"),
|
||||||
makePair(DL, "DL"),
|
makePair(DD, "DD"),
|
||||||
makePair(DR, "DR"),
|
makePair(DL, "DL"),
|
||||||
// Bumpers
|
makePair(DR, "DR"),
|
||||||
makePair(LB, "LB"),
|
// Bumpers
|
||||||
makePair(RB, "RB"),
|
makePair(LB, "LB"),
|
||||||
// Stick press
|
makePair(RB, "RB"),
|
||||||
makePair(LS, "LS"),
|
// Stick press
|
||||||
makePair(RS, "RS"),
|
makePair(LS, "LS"),
|
||||||
// Center buttons
|
makePair(RS, "RS"),
|
||||||
makePair(START, "Start"),
|
// Center buttons
|
||||||
makePair(BACK, "Back"),
|
makePair(START, "Start"),
|
||||||
// Analog sticks
|
makePair(BACK, "Back"),
|
||||||
makePair(LX, "LX"),
|
// Analog sticks
|
||||||
makePair(LY, "LY"),
|
makePair(LX, "LX"),
|
||||||
makePair(RX, "RX"),
|
makePair(LY, "LY"),
|
||||||
makePair(RY, "RY"),
|
makePair(RX, "RX"),
|
||||||
|
makePair(RY, "RY"),
|
||||||
// Triggers
|
|
||||||
makePair(LT, "LT"),
|
|
||||||
makePair(RT, "RT"),
|
|
||||||
|
|
||||||
// Aliases, PlayStation style names
|
// Triggers
|
||||||
makePair(LB, "L1"),
|
makePair(LT, "LT"),
|
||||||
makePair(RB, "R1"),
|
makePair(RT, "RT"),
|
||||||
makePair(LT, "L2"),
|
|
||||||
makePair(RT, "R2"),
|
// Aliases, PlayStation style names
|
||||||
makePair(LS, "L3"),
|
makePair(LB, "L1"),
|
||||||
makePair(RS, "R3"),
|
makePair(RB, "R1"),
|
||||||
makePair(BACK, "Select"),
|
makePair(LT, "L2"),
|
||||||
makePair(A, "Cross"),
|
makePair(RT, "R2"),
|
||||||
makePair(B, "Circle"),
|
makePair(LS, "L3"),
|
||||||
makePair(X, "Square"),
|
makePair(RS, "R3"),
|
||||||
makePair(Y, "Triangle"),
|
makePair(BACK, "Select"),
|
||||||
makePair(DU, "Up"),
|
makePair(A, "Cross"),
|
||||||
makePair(DD, "Down"),
|
makePair(B, "Circle"),
|
||||||
makePair(DL, "Left"),
|
makePair(X, "Square"),
|
||||||
makePair(DR, "Right"),
|
makePair(Y, "Triangle"),
|
||||||
};
|
makePair(DU, "Up"),
|
||||||
return availableInputs;
|
makePair(DD, "Down"),
|
||||||
|
makePair(DL, "Left"),
|
||||||
|
makePair(DR, "Right"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return _availableInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Joystick::getDefaultMappingConfig() const {
|
QString Joystick::getDefaultMappingConfig() const {
|
||||||
|
|
|
@ -56,6 +56,8 @@ private:
|
||||||
SDL_Joystick* _sdlJoystick;
|
SDL_Joystick* _sdlJoystick;
|
||||||
SDL_Haptic* _sdlHaptic;
|
SDL_Haptic* _sdlHaptic;
|
||||||
SDL_JoystickID _instanceId;
|
SDL_JoystickID _instanceId;
|
||||||
|
|
||||||
|
mutable controller::Input::NamedVector _availableInputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Joystick_h
|
#endif // hifi_Joystick_h
|
||||||
|
|
Loading…
Reference in a new issue