Possible workaround (not a proper fix) for #8969. Also filter out accelerometer events.

We should really make sure the events come in on the UI thread
instead...
This commit is contained in:
Henrik Rydgard 2016-09-11 18:47:21 +02:00
parent fd287664ab
commit 0926cabb00

View File

@ -316,26 +316,32 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
return true;
}
bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) {
if (mapped_)
return false;
switch (axis.axisId) {
// Ignore the accelerometer for mapping for now.
static bool IgnoreAxisForMapping(int axis) {
switch (axis) {
// Ignore the accelerometer for mapping for now.
case JOYSTICK_AXIS_ACCELEROMETER_X:
case JOYSTICK_AXIS_ACCELEROMETER_Y:
case JOYSTICK_AXIS_ACCELEROMETER_Z:
return false;
return true;
// Also ignore some weird axis events we get on Ouya.
// Also ignore some weird axis events we get on Ouya.
case JOYSTICK_AXIS_OUYA_UNKNOWN1:
case JOYSTICK_AXIS_OUYA_UNKNOWN2:
case JOYSTICK_AXIS_OUYA_UNKNOWN3:
case JOYSTICK_AXIS_OUYA_UNKNOWN4:
return false;
return true;
default:
;
return false;
}
}
bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) {
if (mapped_)
return false;
if (IgnoreAxisForMapping(axis.axisId))
return false;
if (axis.value > AXIS_BIND_THRESHOLD) {
mapped_ = true;
@ -437,8 +443,10 @@ bool AnalogTestScreen::key(const KeyInput &key) {
(key.flags & KEY_UP) ? "UP" : "",
(key.flags & KEY_DOWN) ? "DOWN" : "",
(key.flags & KEY_CHAR) ? "CHAR" : "");
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
if (lastLastKeyEvent_ && lastKeyEvent_) {
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
}
return retval;
}
@ -448,11 +456,18 @@ bool AnalogTestScreen::axis(const AxisInput &axis) {
// into arrow keys, since seeing keyboard arrow key events appear when using
// a controller would be confusing for the user.
char buf[512];
if (IgnoreAxisForMapping(axis.axisId))
return false;
if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) {
snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d",
axis.axisId, axis.value, axis.deviceId);
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
// Null-check just in case they weren't created yet.
if (lastLastKeyEvent_ && lastKeyEvent_) {
lastLastKeyEvent_->SetText(lastKeyEvent_->GetText());
lastKeyEvent_->SetText(buf);
}
return true;
}
return false;