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

Commit 0529903d authored by Kevin Schoedel's avatar Kevin Schoedel Committed by Android (Google) Code Review
Browse files

Merge "Interface for multiple virtual touchpads."

parents d86505e9 3002b8a7
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -12,19 +12,20 @@ class VirtualTouchpadClientImpl : public VirtualTouchpadClient {
 public:
  VirtualTouchpadClientImpl(sp<IVirtualTouchpadService> service)
      : service_(service) {}
  ~VirtualTouchpadClientImpl() {}
  ~VirtualTouchpadClientImpl() override {}

  status_t Touch(float x, float y, float pressure) override {
  status_t Touch(int touchpad,
                 float x, float y, float pressure) override {
    if (service_ == nullptr) {
      return NO_INIT;
    }
    return service_->touch(x, y, pressure).transactionError();
    return service_->touch(touchpad, x, y, pressure).transactionError();
  }
  status_t ButtonState(int buttons) override {
  status_t ButtonState(int touchpad, int buttons) override {
    if (service_ == nullptr) {
      return NO_INIT;
    }
    return service_->buttonState(buttons).transactionError();
    return service_->buttonState(touchpad, buttons).transactionError();
  }

 private:
+10 −8
Original line number Diff line number Diff line
@@ -56,15 +56,17 @@ int VirtualTouchpadEvdev::Initialize() {
  return injector_->GetError();
}

int VirtualTouchpadEvdev::Touch(float x, float y, float pressure) {
int VirtualTouchpadEvdev::Touch(int touchpad, float x, float y,
                                float pressure) {
  (void)touchpad; // TODO(b/35992608) Support multiple virtual touchpad devices.
  if ((x < 0.0f) || (x >= 1.0f) || (y < 0.0f) || (y >= 1.0f)) {
    return EINVAL;
  }
  int32_t device_x = x * kWidth;
  int32_t device_y = y * kHeight;
  touches_ = ((touches_ & 1) << 1) | (pressure > 0);
  ALOGV("(%f,%f) %f -> (%" PRId32 ",%" PRId32 ") %d",
        x, y, pressure, device_x, device_y, touches_);
  ALOGV("(%f,%f) %f -> (%" PRId32 ",%" PRId32 ") %d", x, y, pressure, device_x,
        device_y, touches_);

  if (!injector_) {
    return EvdevInjector::ERROR_SEQUENCING;
@@ -101,7 +103,8 @@ int VirtualTouchpadEvdev::Touch(float x, float y, float pressure) {
  return injector_->GetError();
}

int VirtualTouchpadEvdev::ButtonState(int buttons) {
int VirtualTouchpadEvdev::ButtonState(int touchpad, int buttons) {
  (void)touchpad; // TODO(b/35992608) Support multiple virtual touchpad devices.
  const int changes = last_motion_event_buttons_ ^ buttons;
  if (!changes) {
    return 0;
@@ -117,8 +120,7 @@ int VirtualTouchpadEvdev::ButtonState(int buttons) {
  }
  injector_->ResetError();
  if (changes & AMOTION_EVENT_BUTTON_BACK) {
    injector_->SendKey(BTN_BACK,
                       (buttons & AMOTION_EVENT_BUTTON_BACK)
    injector_->SendKey(BTN_BACK, (buttons & AMOTION_EVENT_BUTTON_BACK)
                                     ? EvdevInjector::KEY_PRESS
                                     : EvdevInjector::KEY_RELEASE);
  }
+3 −3
Original line number Diff line number Diff line
@@ -18,12 +18,12 @@ class VirtualTouchpadEvdev : public VirtualTouchpad {
  static sp<VirtualTouchpad> Create();

  // VirtualTouchpad implementation:
  status_t Touch(float x, float y, float pressure) override;
  status_t ButtonState(int buttons) override;
  status_t Touch(int touchpad, float x, float y, float pressure) override;
  status_t ButtonState(int touchpad, int buttons) override;

 protected:
  VirtualTouchpadEvdev() {}
  ~VirtualTouchpadEvdev() {}
  ~VirtualTouchpadEvdev() override {}
  status_t Initialize();

  // Must be called only between construction and Initialize().
+7 −8
Original line number Diff line number Diff line
@@ -8,16 +8,15 @@
namespace android {
namespace dvr {

binder::Status VirtualTouchpadService::touch(float x, float y, float pressure) {
  const status_t error = touchpad_->Touch(x, y, pressure);
  return error ? binder::Status::fromStatusT(error)
               : binder::Status::ok();
binder::Status VirtualTouchpadService::touch(int touchpad,
                                             float x, float y, float pressure) {
  const status_t error = touchpad_->Touch(touchpad, x, y, pressure);
  return error ? binder::Status::fromStatusT(error) : binder::Status::ok();
}

binder::Status VirtualTouchpadService::buttonState(int buttons) {
  const status_t error = touchpad_->ButtonState(buttons);
  return error ? binder::Status::fromStatusT(error)
               : binder::Status::ok();
binder::Status VirtualTouchpadService::buttonState(int touchpad, int buttons) {
  const status_t error = touchpad_->ButtonState(touchpad, buttons);
  return error ? binder::Status::fromStatusT(error) : binder::Status::ok();
}

}  // namespace dvr
+3 −2
Original line number Diff line number Diff line
@@ -15,11 +15,12 @@ class VirtualTouchpadService : public BnVirtualTouchpadService {
 public:
  VirtualTouchpadService(sp<VirtualTouchpad> touchpad)
      : touchpad_(touchpad) {}
  ~VirtualTouchpadService() override {}

 protected:
  // Implements IVirtualTouchpadService.
  binder::Status touch(float x, float y, float pressure) override;
  binder::Status buttonState(int buttons) override;
  binder::Status touch(int touchpad, float x, float y, float pressure) override;
  binder::Status buttonState(int touchpad, int buttons) override;

 private:
  sp<VirtualTouchpad> touchpad_;
Loading