diff options
| author | 2023-01-23 12:41:01 -0800 | |
|---|---|---|
| committer | 2023-01-24 04:52:17 -0800 | |
| commit | 5df3493d3cf633f8ac7447bc5474a0dfbc1a8359 (patch) | |
| tree | f7831ace6032ff030e3e83df5e17a8c503f454e0 /libs/input/Input.cpp | |
| parent | 0026b4cfc864e6cbd32ef911235e39b31de54aba (diff) | |
Validate axes and led labels correctly
Before this CL, a number of checks for kl file validity were incorrect.
Some of the APIs were supposed to return an invalid value, but instead
were always returning a valid value, no matter what the input was.
Correct these values by switching to std::optional.
Bug: 266400536
Test: m libinput_tests && adb sync data && adb shell -t /data/nativetest64/libinput_tests/libinput_tests
Change-Id: I4ef45f3249dca4f4f033fb85e9fecbc2ad1f1395
Diffstat (limited to 'libs/input/Input.cpp')
| -rw-r--r-- | libs/input/Input.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index c356c2e5e9..133b260a61 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -299,7 +299,7 @@ const char* KeyEvent::getLabel(int32_t keyCode) { return InputEventLookup::getLabelByKeyCode(keyCode); } -int32_t KeyEvent::getKeyCodeFromLabel(const char* label) { +std::optional<int> KeyEvent::getKeyCodeFromLabel(const char* label) { return InputEventLookup::getKeyCodeByLabel(label); } @@ -891,7 +891,7 @@ const char* MotionEvent::getLabel(int32_t axis) { return InputEventLookup::getAxisLabel(axis); } -int32_t MotionEvent::getAxisFromLabel(const char* label) { +std::optional<int> MotionEvent::getAxisFromLabel(const char* label) { return InputEventLookup::getAxisByLabel(label); } |