Loading include/input/DisplayViewport.h +13 −14 Original line number Diff line number Diff line Loading @@ -17,12 +17,12 @@ #ifndef _LIBINPUT_DISPLAY_VIEWPORT_H #define _LIBINPUT_DISPLAY_VIEWPORT_H #include <cinttypes> #include <optional> #include <android-base/stringprintf.h> #include <input/Input.h> #include <cinttypes> #include <optional> using android::base::StringPrintf; namespace android { Loading @@ -39,22 +39,21 @@ enum { * Keep in sync with values in InputManagerService.java. */ enum class ViewportType : int32_t { VIEWPORT_INTERNAL = 1, VIEWPORT_EXTERNAL = 2, VIEWPORT_VIRTUAL = 3, INTERNAL = 1, EXTERNAL = 2, VIRTUAL = 3, }; static const char* viewportTypeToString(ViewportType type) { switch (type) { case ViewportType::VIEWPORT_INTERNAL: case ViewportType::INTERNAL: return "INTERNAL"; case ViewportType::VIEWPORT_EXTERNAL: case ViewportType::EXTERNAL: return "EXTERNAL"; case ViewportType::VIEWPORT_VIRTUAL: case ViewportType::VIRTUAL: return "VIRTUAL"; default: return "UNKNOWN"; } return "UNKNOWN"; } /* Loading Loading @@ -97,7 +96,7 @@ struct DisplayViewport { isActive(false), uniqueId(), physicalPort(std::nullopt), type(ViewportType::VIEWPORT_INTERNAL) {} type(ViewportType::INTERNAL) {} bool operator==(const DisplayViewport& other) const { return displayId == other.displayId && orientation == other.orientation && Loading Loading @@ -134,7 +133,7 @@ struct DisplayViewport { isActive = false; uniqueId.clear(); physicalPort = std::nullopt; type = ViewportType::VIEWPORT_INTERNAL; type = ViewportType::INTERNAL; } std::string toString() const { Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "CursorInputMapper.h" Loading Loading @@ -184,7 +186,7 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* mOrientation = DISPLAY_ORIENTATION_0; if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { std::optional<DisplayViewport> internalViewport = config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); config->getDisplayViewportByType(ViewportType::INTERNAL); if (internalViewport) { mOrientation = internalViewport->orientation; } Loading services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "KeyboardInputMapper.h" Loading Loading @@ -138,7 +140,7 @@ std::optional<DisplayViewport> KeyboardInputMapper::findViewport( // No associated display defined, try to find default display if orientationAware. if (mParameters.orientationAware) { return config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); return config->getDisplayViewportByType(ViewportType::INTERNAL); } return std::nullopt; Loading services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "RotaryEncoderInputMapper.h" Loading Loading @@ -66,7 +68,7 @@ void RotaryEncoderInputMapper::configure(nsecs_t when, const InputReaderConfigur } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { std::optional<DisplayViewport> internalViewport = config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); config->getDisplayViewportByType(ViewportType::INTERNAL); if (internalViewport) { mOrientation = internalViewport->orientation; } else { Loading services/inputflinger/reader/mapper/TouchInputMapper.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -585,18 +585,18 @@ std::optional<DisplayViewport> TouchInputMapper::findViewport() { ViewportType viewportTypeToUse; if (mParameters.associatedDisplayIsExternal) { viewportTypeToUse = ViewportType::VIEWPORT_EXTERNAL; viewportTypeToUse = ViewportType::EXTERNAL; } else { viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; viewportTypeToUse = ViewportType::INTERNAL; } std::optional<DisplayViewport> viewport = mConfig.getDisplayViewportByType(viewportTypeToUse); if (!viewport && viewportTypeToUse == ViewportType::VIEWPORT_EXTERNAL) { if (!viewport && viewportTypeToUse == ViewportType::EXTERNAL) { ALOGW("Input device %s should be associated with external display, " "fallback to internal one for the external viewport is not found.", getDeviceName().c_str()); viewport = mConfig.getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); viewport = mConfig.getDisplayViewportByType(ViewportType::INTERNAL); } return viewport; Loading Loading
include/input/DisplayViewport.h +13 −14 Original line number Diff line number Diff line Loading @@ -17,12 +17,12 @@ #ifndef _LIBINPUT_DISPLAY_VIEWPORT_H #define _LIBINPUT_DISPLAY_VIEWPORT_H #include <cinttypes> #include <optional> #include <android-base/stringprintf.h> #include <input/Input.h> #include <cinttypes> #include <optional> using android::base::StringPrintf; namespace android { Loading @@ -39,22 +39,21 @@ enum { * Keep in sync with values in InputManagerService.java. */ enum class ViewportType : int32_t { VIEWPORT_INTERNAL = 1, VIEWPORT_EXTERNAL = 2, VIEWPORT_VIRTUAL = 3, INTERNAL = 1, EXTERNAL = 2, VIRTUAL = 3, }; static const char* viewportTypeToString(ViewportType type) { switch (type) { case ViewportType::VIEWPORT_INTERNAL: case ViewportType::INTERNAL: return "INTERNAL"; case ViewportType::VIEWPORT_EXTERNAL: case ViewportType::EXTERNAL: return "EXTERNAL"; case ViewportType::VIEWPORT_VIRTUAL: case ViewportType::VIRTUAL: return "VIRTUAL"; default: return "UNKNOWN"; } return "UNKNOWN"; } /* Loading Loading @@ -97,7 +96,7 @@ struct DisplayViewport { isActive(false), uniqueId(), physicalPort(std::nullopt), type(ViewportType::VIEWPORT_INTERNAL) {} type(ViewportType::INTERNAL) {} bool operator==(const DisplayViewport& other) const { return displayId == other.displayId && orientation == other.orientation && Loading Loading @@ -134,7 +133,7 @@ struct DisplayViewport { isActive = false; uniqueId.clear(); physicalPort = std::nullopt; type = ViewportType::VIEWPORT_INTERNAL; type = ViewportType::INTERNAL; } std::string toString() const { Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "CursorInputMapper.h" Loading Loading @@ -184,7 +186,7 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration* mOrientation = DISPLAY_ORIENTATION_0; if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { std::optional<DisplayViewport> internalViewport = config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); config->getDisplayViewportByType(ViewportType::INTERNAL); if (internalViewport) { mOrientation = internalViewport->orientation; } Loading
services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "KeyboardInputMapper.h" Loading Loading @@ -138,7 +140,7 @@ std::optional<DisplayViewport> KeyboardInputMapper::findViewport( // No associated display defined, try to find default display if orientationAware. if (mParameters.orientationAware) { return config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); return config->getDisplayViewportByType(ViewportType::INTERNAL); } return std::nullopt; Loading
services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ * limitations under the License. */ // clang-format off #include "../Macros.h" // clang-format on #include "RotaryEncoderInputMapper.h" Loading Loading @@ -66,7 +68,7 @@ void RotaryEncoderInputMapper::configure(nsecs_t when, const InputReaderConfigur } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { std::optional<DisplayViewport> internalViewport = config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); config->getDisplayViewportByType(ViewportType::INTERNAL); if (internalViewport) { mOrientation = internalViewport->orientation; } else { Loading
services/inputflinger/reader/mapper/TouchInputMapper.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -585,18 +585,18 @@ std::optional<DisplayViewport> TouchInputMapper::findViewport() { ViewportType viewportTypeToUse; if (mParameters.associatedDisplayIsExternal) { viewportTypeToUse = ViewportType::VIEWPORT_EXTERNAL; viewportTypeToUse = ViewportType::EXTERNAL; } else { viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; viewportTypeToUse = ViewportType::INTERNAL; } std::optional<DisplayViewport> viewport = mConfig.getDisplayViewportByType(viewportTypeToUse); if (!viewport && viewportTypeToUse == ViewportType::VIEWPORT_EXTERNAL) { if (!viewport && viewportTypeToUse == ViewportType::EXTERNAL) { ALOGW("Input device %s should be associated with external display, " "fallback to internal one for the external viewport is not found.", getDeviceName().c_str()); viewport = mConfig.getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL); viewport = mConfig.getDisplayViewportByType(ViewportType::INTERNAL); } return viewport; Loading