Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efa77d18 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

TouchButtonAccumulator: Miscelaneous cleanup

Bug: 246394583
Test: atest inputflinger_tests
Change-Id: I0d319c650ede4320736932a7be2e5f07eea7eec7
parent a3621859
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -21,10 +21,6 @@

namespace android {

TouchButtonAccumulator::TouchButtonAccumulator() : mHaveBtnTouch(false), mHaveStylus(false) {
    clearButtons();
}

void TouchButtonAccumulator::configure(InputDeviceContext& deviceContext) {
    mHaveBtnTouch = deviceContext.hasScanCode(BTN_TOUCH);
    mHaveStylus = deviceContext.hasScanCode(BTN_TOOL_PEN) ||
@@ -52,23 +48,6 @@ void TouchButtonAccumulator::reset(InputDeviceContext& deviceContext) {
    mBtnToolQuadTap = deviceContext.isKeyPressed(BTN_TOOL_QUADTAP);
}

void TouchButtonAccumulator::clearButtons() {
    mBtnTouch = 0;
    mBtnStylus = 0;
    mBtnStylus2 = 0;
    mBtnToolFinger = 0;
    mBtnToolPen = 0;
    mBtnToolRubber = 0;
    mBtnToolBrush = 0;
    mBtnToolPencil = 0;
    mBtnToolAirbrush = 0;
    mBtnToolMouse = 0;
    mBtnToolLens = 0;
    mBtnToolDoubleTap = 0;
    mBtnToolTripleTap = 0;
    mBtnToolQuadTap = 0;
}

void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
    if (rawEvent->type == EV_KEY) {
        switch (rawEvent->code) {
+19 −21
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

#pragma once

#include <stdint.h>
#include <cstdint>

namespace android {

@@ -26,7 +26,7 @@ struct RawEvent;
/* Keeps track of the state of touch, stylus and tool buttons. */
class TouchButtonAccumulator {
public:
    TouchButtonAccumulator();
    TouchButtonAccumulator() = default;
    void configure(InputDeviceContext& deviceContext);
    void reset(InputDeviceContext& deviceContext);

@@ -39,25 +39,23 @@ public:
    bool hasStylus() const;

private:
    bool mHaveBtnTouch;
    bool mHaveStylus;

    bool mBtnTouch;
    bool mBtnStylus;
    bool mBtnStylus2;
    bool mBtnToolFinger;
    bool mBtnToolPen;
    bool mBtnToolRubber;
    bool mBtnToolBrush;
    bool mBtnToolPencil;
    bool mBtnToolAirbrush;
    bool mBtnToolMouse;
    bool mBtnToolLens;
    bool mBtnToolDoubleTap;
    bool mBtnToolTripleTap;
    bool mBtnToolQuadTap;

    void clearButtons();
    bool mHaveBtnTouch{};
    bool mHaveStylus{};

    bool mBtnTouch{};
    bool mBtnStylus{};
    bool mBtnStylus2{};
    bool mBtnToolFinger{};
    bool mBtnToolPen{};
    bool mBtnToolRubber{};
    bool mBtnToolBrush{};
    bool mBtnToolPencil{};
    bool mBtnToolAirbrush{};
    bool mBtnToolMouse{};
    bool mBtnToolLens{};
    bool mBtnToolDoubleTap{};
    bool mBtnToolTripleTap{};
    bool mBtnToolQuadTap{};
};

} // namespace android