// @file sns_touchslider.proto
//
// @brief Defines the API for touchslider Sensors.
//
// @copyright 
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
// @details Touchslider sensors typically support touch and slider events.
// All Touchslider Sensor drivers are required to comply with this API.
// Any new functionality for Touchslider Sensor may be defined in a
// device specific API file.
//
// ## Attribute Requirements:
// The Touchslider Sensor publishes:
// 1. SNS_STD_SENSOR_ATTRID_TYPE attribute value as "touchslider".
//    Each Touchslider sensor shall be published
//    as an independent sensor with a unique Sensor UID per stream type.
// 2. SNS_STD_SENSOR_ATTRID_API attribute contains "sns_touchslider.proto"
// 3. SNS_STD_SENSOR_ATTRID_RANGES attribute value in cm unit.
// 4. SNS_STD_SENSOR_ATTRID_RESOLUTIONS attribute value in cm unit
// 5. SNS_STD_SENSOR_ATTRID_STREAM_TYPE as SNS_STD_SENSOR_STREAM_TYPE_STREAMING
//    or SNS_STD_SENSOR_STREAM_TYPE_ON_CHANGE
// 6. See sns_std_sensor.proto for other attributes.
//
// ## Processing Stream Requests:
// 1. The touchslider sensor can support both streaming and on-change
//    modes, and the operating mode is configured in the Registry.
// 2. In streaming mode, the touchslider sensor handles the sns_std_sensor_config
//    client requests, for all stream enable/update request types. 
// 3. In on-change mode, the touchslider sensor handles the 
//    SNS_STD_SENSOR_MSGID_SNS_STD_ON_CHANGE_CONFIG client requests,
//    for all on-change enable/update request types.
//    Also for this mode, the touchslider sensor publishes an 
//    initial data event for each new, on-change client request.
//
// ## Publishing Stream Events:
// 1. The touchslider sensor publishes either button events or slider events using a
//    sns_touchslider_events message or sns_touchslider_events_recurrent message.
//  a. If this is a SNS_STD_SENSOR_STREAM_TYPE_STREAMING sensor, it uses the
//     sns_touchslider_events_recurrent message.
//  b. If this is a SNS_STD_SENSOR_STREAM_TYPE_ON_CHANGE sensor, it uses the
//     sns_touchslider_events message.
// 2. The touchslider sensor publishes a configuration event using the
//    sns_std_sensor_physical_config_event message.
//    It publishes this event each time there is change in hardware config of the sensor
//    or when a client sends a new request.
// 3. The touchslider sensor events have factory calibration applied.
//
// ## Processing Self-Test Requests:
// 1. The touchslider sensor implements SNS_PHYSICAL_SENSOR_TEST_TYPE_COM test
//    type using the physical sensor test API.
// 2. The touchslider sensor may implement SNS_PHYSICAL_SENSOR_TEST_TYPE_FACTORY test
//    type to determine factory calibration parameters using the physical
//    sensor test API.
// 3. The touchslider sensor may implement other test types.
//
// ## Publishing Self-Test Events:
// 1. The touchslider sensor uses sns_physical_sensor_test_event message to publish
//    a test completion event.
// 2. The test_passed field in sns_physical_sensor_test_event is used to output the
//    pass/fail result of self-test execution.
// 3. The test_data field in sns_physical_sensor_test_event may be used to output any
//    driver-specific error data.


syntax = "proto2";
import "nanopb.proto";
import "sns_std_sensor.proto";

// @brief Message IDs for touchslider Sensor
enum sns_touchslider_msgid {
  option (nanopb_enumopt).long_names = false;

  // @brief Uses message: sns_touchslider_events
  // Purpose: used to publish touch/slider events
  SNS_TOUCHSLIDER_MSGID_SNS_TOUCHSLIDER_SENSOR_EVENT  = 780;
  
  // @brief Uses message: sns_touch_pad_events_recurrent
  // Purpose: used to publish touch/slider events recurrently
  SNS_TOUCHSLIDER_MSGID_SNS_TOUCHSLIDER_SENSOR_EVENT_RECURRENT  = 1031;
}

// @brief Slider's slide direction type
enum sns_touchslider_slider_direction_type
{
  option (nanopb_enumopt).long_names = false;

  SNS_TOUCHSLIDER_SLIDER_DIRECTION_INVALID = 0;
  SNS_TOUCHSLIDER_SLIDER_DIRECTION_FORWARD = 1;
  SNS_TOUCHSLIDER_SLIDER_DIRECTION_BACKWARD = 2;
}

// @brief Touch's hold start and end marker
enum sns_touchslider_touch_hold_type
{
  option (nanopb_enumopt).long_names = false;

  SNS_TOUCHSLIDER_TOUCH_HOLD_INVALID = 0;
  SNS_TOUCHSLIDER_TOUCH_HOLD_START = 1;
  SNS_TOUCHSLIDER_TOUCH_HOLD_END = 2;
}

// @brief message for gesture type tap
message sns_touchslider_touch_event_tap 
{
  // @brief Number of taps
  optional uint32 tap_count = 1;
}

// @brief message for gesture type hold
message sns_touchslider_touch_event_hold
{
  optional sns_touchslider_touch_hold_type hold_type = 1;
}

// @brief message for touch event
message sns_touchslider_touch_event
{
  message sns_touch_event
  {
    // @brief Unique identifier of the button
    optional uint32 touch_id = 1;

    // @brief gesture related event
    oneof event
    {
      sns_touchslider_touch_event_tap event_tap = 100;
      sns_touchslider_touch_event_hold event_hold = 101;
    }
  }

  // @brief List of button events
  repeated sns_touch_event event = 1;
}

// @brief message for slider event
message sns_touchslider_slider_event
{
  message sns_slider_event
  {
    // @brief Unique identifier
    optional uint32 slider_id = 1;

    // @brief Current position
    optional uint32 slider_position = 2;

    // @brief touch state
    optional bool touch_pressed = 3;

    // @brief Direction
    optional sns_touchslider_slider_direction_type direction = 4;
  }

  // @brief List of slider events
  repeated sns_slider_event event = 1;
}

// @brief Event msg for either button or slider
message sns_touchslider_event
{
  oneof msg
  {
    sns_touchslider_touch_event touch_event = 100;
    sns_touchslider_slider_event slider_event = 101;
  }
}

// @brief Event for Touchslider sensor
message sns_touchslider_sensor_event
{
  optional sns_touchslider_event event = 1;
}

// @brief Recurrent event for Touchslider sensor
message sns_touchslider_sensor_event_recurrent
{
  optional sns_touchslider_event event = 1;
}