diff options
| author | 2022-09-22 13:35:22 -0700 | |
|---|---|---|
| committer | 2022-10-05 11:33:59 -0700 | |
| commit | 2935db7177bf6ddee879883da5b0a07846f44391 (patch) | |
| tree | 32fc1914c85723666e03fc88f1d59f7c4ed01b69 /services/inputflinger/NotifyArgs.cpp | |
| parent | 6b9a04ce47e24ed0012259e0390eb4ea5a439373 (diff) | |
Return events from mappers and InputDevice
We are changing the way android input events are reported from the
InputReader. Previously, the process was opaque - anywhere in the code
you were allowed to grab the listener and send events to it. Now, the
flow changes - you will have to explicitly return the events back to the
caller.
With the new approach, InputReader will ultimately be the one
dispatching the events to the listener.
Bug: 211379801
Test: atest inputflinger_tests
Change-Id: I2318ad1220fa66b197ca2a49b8625afcfb45103f
Diffstat (limited to 'services/inputflinger/NotifyArgs.cpp')
| -rw-r--r-- | services/inputflinger/NotifyArgs.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/services/inputflinger/NotifyArgs.cpp b/services/inputflinger/NotifyArgs.cpp index 1f37774218..b192ad73c3 100644 --- a/services/inputflinger/NotifyArgs.cpp +++ b/services/inputflinger/NotifyArgs.cpp @@ -225,4 +225,27 @@ NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs( int32_t id, nsecs_t eventTime, const PointerCaptureRequest& request) : id(id), eventTime(eventTime), request(request) {} +// Helper to std::visit with lambdas. +template <typename... V> +struct Visitor : V... {}; +// explicit deduction guide (not needed as of C++20) +template <typename... V> +Visitor(V...) -> Visitor<V...>; + +const char* toString(const NotifyArgs& args) { + Visitor toStringVisitor{ + [&](const NotifyConfigurationChangedArgs&) { return "NotifyConfigurationChangedArgs"; }, + [&](const NotifyKeyArgs&) { return "NotifyKeyArgs"; }, + [&](const NotifyMotionArgs&) { return "NotifyMotionArgs"; }, + [&](const NotifySensorArgs&) { return "NotifySensorArgs"; }, + [&](const NotifySwitchArgs&) { return "NotifySwitchArgs"; }, + [&](const NotifyDeviceResetArgs&) { return "NotifyDeviceResetArgs"; }, + [&](const NotifyPointerCaptureChangedArgs&) { + return "NotifyPointerCaptureChangedArgs"; + }, + [&](const NotifyVibratorStateArgs&) { return "NotifyVibratorStateArgs"; }, + }; + return std::visit(toStringVisitor, args); +} + } // namespace android |