Input Driver Sample using Fuchsia SDK

This sample input driver implements fuchsia.input.report using the input_reports_reader SDK to send fake mouse reports every 1 second.

Run and test driver

After starting up the emulator

  1. Load the sample driver

    bazel run --config=fuchsia_x64 src/input_sample:pkg.component
    
  2. Read the fake input mouse descriptor

    tools/ffx driver print-input-report descriptor
    

    This should return a list of descriptors. The fake mouse descriptor for this driver is

    Descriptor from file: "class/input-report/002"
    {
       device_info: {
          vendor_id: 305419896
          product_id: 2271560481
          version: 0
       }
       mouse: {
          input: {
             movement_x: {
                range: {
                   min: -127
                   max: 127
                }
                unit: {
                   type: None
                   exponent: 0
                }
             }
             movement_y: {
                range: {
                   min: -127
                   max: 127
                }
                unit: {
                   type: None
                   exponent: 0
                }
             }
             scroll_v: None
             scroll_h: None
             buttons: [1, 2, 3]
             position_x: None
             position_y: None
          }
       }
       sensor: None
       touch: None
       keyboard: None
       consumer_control: None
    }
    

    In particular, it should be the one with

    vendor_id: 305419896     // 0x12345678
    product_id: 2271560481   // 0x87654321
    

    You may exit this with CTRL-C.

  3. Read the fake input mouse reports

    tools/ffx driver print-input-report read
    

    This will produce logs that look like

    {
      event_time: 335266867991
      trace_id: 9
      report_id: None
      mouse: {
         movement_x: 29
         movement_y: 29
         scroll_v: None
         scroll_h: None
         pressed_buttons: [1, 3]
         position_x: None
         position_y: None
      }
      sensor: None
      touch: None
      keyboard: None
      consumer_control: None
    }
    

    once a second. Each second movement_x and movement_y should increment, pressed_buttons should change, and event_time should also change.

    You may exit this with CTRL-C.