/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

// Records an event in the evdev protocol, as used by Linux and some other *nix
// kernels to report events from human interface devices.
//
// Next ID: 3
message EvdevEvent {
  // The device's unique ID number. This need not be the number of its
  // /dev/input/event node.
  optional uint32 device_id = 1;

  oneof event {
    InputEvent input_event = 2;
  }

  // Proto version of Linux's struct input_event. The meaning of types and codes
  // are described in the Linux kernel documentation at
  // https://www.kernel.org/doc/html/latest/input/event-codes.html.
  //
  // Next ID: 5
  message InputEvent {
    // The monotonic timestamp at which the event occurred, as reported by the
    // kernel, in integer nanoseconds. If omitted, assume that it hasn't changed
    // since the previous event.
    optional uint64 kernel_timestamp = 1;

    // The code grouping for this event, used to distinguish signals, absolute
    // and relative axis changes, and other types of event.
    optional uint32 type = 2;
    // The precise type of the event, such as the axis code for absolute and
    // relative events.
    optional uint32 code = 3;
    // The new value of the axis described by type and code.
    optional sint32 value = 4;
  }
}
