Merge pull request #7925 from FireyFly/analog-testscreen-fix

Add axis event listener to the analog test screen.
This commit is contained in:
Henrik Rydgård 2015-08-30 13:45:29 +02:00
commit bbde0919d8
2 changed files with 17 additions and 1 deletions

View file

@ -432,6 +432,21 @@ bool AnalogTestScreen::key(const KeyInput &key) {
return true;
}
bool AnalogTestScreen::axis(const AxisInput &axis) {
// This is mainly to catch axis events that would otherwise get translated
// into arrow keys, since seeing keyboard arrow key events appear when using
// a controller would be confusing for the user.
char buf[512];
if (axis.value > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) {
int value = axis.value > AXIS_BIND_THRESHOLD ? 1 : -1;
snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d",
axis.axisId, axis.value, axis.deviceId);
lastKeyEvent_->SetText(buf);
return true;
}
return false;
}
void AnalogTestScreen::CreateViews() {
using namespace UI;

View file

@ -74,9 +74,10 @@ public:
AnalogTestScreen() {}
bool key(const KeyInput &key) override;
bool axis(const AxisInput &axis) override;
protected:
virtual void CreateViews() override;
UI::TextView *lastKeyEvent_;
};
};