chromium/remoting/proto/event.proto

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Protocol for event messages.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package remoting.protocol;

// Defines a keyboard event.
message KeyEvent {

  // The keyboard (Caps/Num) lock states.
  enum LockStates {
    LOCK_STATES_CAPSLOCK = 1;
    LOCK_STATES_NUMLOCK = 2;
  }

  // True for key press events, and false for key release.
  optional bool pressed = 2;

  // The USB key code.
  // The upper 16-bits are the USB Page (0x07 for key events).
  // The lower 16-bits are the USB Usage ID (which identifies the actual key).
  optional uint32 usb_keycode = 3;

  // Legacy keyboard lock states. Prefer the discrete entries below.
  optional uint32 lock_states = 4 [default = 0];

  // Keyboard lock states. The field should be specified only if the state can
  // be reliably determined by the client. E.g., OS X does not have num lock, so
  // only caps_lock should be provided by a client running on OS X.
  optional bool caps_lock_state = 5;
  optional bool num_lock_state = 6;
}

// Text input event for input method different from physical keyboards,
// including software keyboard, gesture typing, voice input, etc.
message TextEvent {
  // Unicode sequence for the event in UTF-8.
  optional string text = 1;
}

// Fractional coordinate information. Fractional coordinates define a location
// as a number in the range [0, 1], interpreted relative to the bounds of a
// monitor identified by |stream_id| in the most recent VideoLayout message sent
// by the host.
message FractionalCoordinate {
  optional float x = 1;
  optional float y = 2;
  optional int64 screen_id = 3;
}

// Defines a mouse event message on the event channel.
message MouseEvent {

  enum MouseButton {
    BUTTON_UNDEFINED = 0;
    BUTTON_LEFT = 1;
    BUTTON_MIDDLE = 2;
    BUTTON_RIGHT = 3;
    BUTTON_BACK = 4;
    BUTTON_FORWARD = 5;
    BUTTON_MAX = 6;
  }

  // Mouse absolute position information. When using WebRTC-based protocol the
  // coordinates are in DIPs. Otherwise they are in host's physical pixels. In
  // both coordinates systems, the top-left monitor on the system always starts
  // from (0, 0).
  optional int32 x = 1;
  optional int32 y = 2;

  // Mouse button event.
  optional MouseButton button = 5;
  optional bool button_down = 6;

  // Mouse wheel information.
  // These values encode the number of pixels and 'ticks' of movement that
  // would result from the wheel event on the client system.
  optional float wheel_delta_x = 7;
  optional float wheel_delta_y = 8;
  optional float wheel_ticks_x = 9;
  optional float wheel_ticks_y = 10;

  // Mouse movement information. Provided only for relative mouse events (i.e.
  // when mouse lock is engaged).
  optional int32 delta_x = 11;
  optional int32 delta_y = 12;

  // Fractional coordinate information. Provided only for absolute mouse events
  // (i.e. when mouse lock is *not* engaged).
  optional FractionalCoordinate fractional_coordinate = 13;
}

// Defines an event that sends clipboard data between peers.
message ClipboardEvent {

  // The MIME type of the data being sent.
  optional string mime_type = 1;

  // The data being sent.
  optional bytes data = 2;
}

message TouchEventPoint {
  // The ID for the touch point.
  optional uint32 id = 1;

  // The absolute position of the touch point. These values on-the-wire are host
  // physical pixel coordinates: the top-left monitor on the system always
  // starts from (0, 0).
  optional float x = 2;
  optional float y = 3;

  // The size of the touch point, used to aid hit-testing.
  // Scaled to match the size on host.
  optional float radius_x = 4;
  optional float radius_y = 5;

  // Angle in degrees from the y-axis of the touch point.
  optional float angle = 6;

  // The pressure of the touch point.
  // The value should be in [0.0, 1.0].
  optional float pressure = 7;

  optional FractionalCoordinate fractional_coordinate = 8;
}

message TouchEvent {
  // A START event means that this event reports all the touch points that were
  // just added, e.g. a finger started touching the display.
  // A MOVE event means that the touch points that have been STARTed moved,
  // e.g. multiple fingers on the screen moved.
  // An END event means that the touch points that have been STARTed ended.
  // e.g. a finger went off the screen.
  // A CANCEL event means that the touch points that have been STARTed were
  // canceled, e.g. a finger went off the screen.
  // Cancel event is simlar to END but slighly different. For example, Android
  // MotionEvent's ACTION_CANCEL documentation mentions that a cancel should be
  // treated as an ACTION_UP (END) event but might not perform the exact same
  // actions as a normal ACTION_UP event.
  enum TouchEventType {
    TOUCH_POINT_UNDEFINED = 0;
    TOUCH_POINT_START = 1;
    TOUCH_POINT_MOVE = 2;
    TOUCH_POINT_END = 3;
    TOUCH_POINT_CANCEL = 4;
  };

  optional TouchEventType event_type = 1;

  // Only the changed touch points are added to this field.
  // Given the existing touch point APIs (e.g. Android and PPAPI)
  // for START, END, and CANCEL events the size of this field will typically be
  // 1, but for MOVE events it is likely to have multiple points.
  repeated TouchEventPoint touch_points = 2;
}