naiveproxy/services/device/public/mojom/hid.mojom

187 lines
6.8 KiB
Plaintext
Raw Normal View History

2018-12-10 05:59:24 +03:00
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module device.mojom;
enum HidBusType {
kHIDBusTypeUSB = 0,
kHIDBusTypeBluetooth = 1,
};
// Usage pages.
const uint16 kPageUndefined = 0x00;
const uint16 kPageGenericDesktop = 0x01;
const uint16 kPageSimulation = 0x02;
const uint16 kPageVirtualReality = 0x03;
const uint16 kPageSport = 0x04;
const uint16 kPageGame = 0x05;
const uint16 kPageKeyboard = 0x07;
const uint16 kPageLed = 0x08;
const uint16 kPageButton = 0x09;
const uint16 kPageOrdinal = 0x0A;
const uint16 kPageTelephony = 0x0B;
const uint16 kPageConsumer = 0x0C;
const uint16 kPageDigitizer = 0x0D;
const uint16 kPagePidPage = 0x0F;
const uint16 kPageUnicode = 0x10;
const uint16 kPageAlphanumericDisplay = 0x14;
const uint16 kPageMedicalInstruments = 0x40;
const uint16 kPageMonitor0 = 0x80;
const uint16 kPageMonitor1 = 0x81;
const uint16 kPageMonitor2 = 0x82;
const uint16 kPageMonitor3 = 0x83;
const uint16 kPagePower0 = 0x84;
const uint16 kPagePower1 = 0x85;
const uint16 kPagePower2 = 0x86;
const uint16 kPagePower3 = 0x87;
const uint16 kPageBarCodeScanner = 0x8C;
const uint16 kPageScale = 0x8D;
const uint16 kPageMagneticStripeReader = 0x8E;
const uint16 kPageReservedPointOfSale = 0x8F;
const uint16 kPageCameraControl = 0x90;
const uint16 kPageArcade = 0x91;
const uint16 kPageVendor = 0xFF00;
const uint16 kPageMediaCenter = 0xFFBC;
// These usage enumerations are derived from the HID Usage Tables v1.11 spec.
const uint16 kGenericDesktopUndefined = 0x00;
const uint16 kGenericDesktopPointer = 0x01;
const uint16 kGenericDesktopMouse = 0x02;
const uint16 kGenericDesktopJoystick = 0x04;
const uint16 kGenericDesktopGamePad = 0x05;
const uint16 kGenericDesktopKeyboard = 0x06;
const uint16 kGenericDesktopKeypad = 0x07;
const uint16 kGenericDesktopMultiAxisController = 0x08;
const uint16 kGenericDesktopX = 0x30;
const uint16 kGenericDesktopY = 0x31;
const uint16 kGenericDesktopZ = 0x32;
const uint16 kGenericDesktopRx = 0x33;
const uint16 kGenericDesktopRy = 0x34;
const uint16 kGenericDesktopRz = 0x35;
const uint16 kGenericDesktopSlider = 0x36;
const uint16 kGenericDesktopDial = 0x37;
const uint16 kGenericDesktopWheel = 0x38;
const uint16 kGenericDesktopHatSwitch = 0x39;
const uint16 kGenericDesktopCountedBuffer = 0x3a;
const uint16 kGenericDesktopByteCount = 0x3b;
const uint16 kGenericDesktopMotionWakeup = 0x3c;
const uint16 kGenericDesktopStart = 0x3d;
const uint16 kGenericDesktopSelect = 0x3e;
const uint16 kGenericDesktopVx = 0x40;
const uint16 kGenericDesktopVy = 0x41;
const uint16 kGenericDesktopVz = 0x42;
const uint16 kGenericDesktopVbrx = 0x43;
const uint16 kGenericDesktopVbry = 0x44;
const uint16 kGenericDesktopVbrz = 0x45;
const uint16 kGenericDesktopVno = 0x46;
const uint16 kGenericDesktopSystemControl = 0x80;
const uint16 kGenericDesktopSystemPowerDown = 0x81;
const uint16 kGenericDesktopSystemSleep = 0x82;
const uint16 kGenericDesktopSystemWakeUp = 0x83;
const uint16 kGenericDesktopSystemContextMenu = 0x84;
const uint16 kGenericDesktopSystemMainMenu = 0x85;
const uint16 kGenericDesktopSystemAppMenu = 0x86;
const uint16 kGenericDesktopSystemMenuHelp = 0x87;
const uint16 kGenericDesktopSystemMenuExit = 0x88;
const uint16 kGenericDesktopSystemMenuSelect = 0x89;
const uint16 kGenericDesktopSystemMenuRight = 0x8a;
const uint16 kGenericDesktopSystemMenuLeft = 0x8b;
const uint16 kGenericDesktopSystemMenuUp = 0x8c;
const uint16 kGenericDesktopSystemMenuDown = 0x8d;
const uint16 kGenericDesktopSystemColdRestart = 0x8e;
const uint16 kGenericDesktopSystemWarmRestart = 0x8f;
const uint16 kGenericDesktopDPadUp = 0x90;
const uint16 kGenericDesktopDPadDown = 0x91;
const uint16 kGenericDesktopDPadLeft = 0x92;
const uint16 kGenericDesktopDPadRight = 0x93;
const uint16 kGenericDesktopSystemDock = 0xa0;
const uint16 kGenericDesktopSystemUndock = 0xa1;
const uint16 kGenericDesktopSystemSetup = 0xa2;
const uint16 kGenericDesktopSystemBreak = 0xa3;
const uint16 kGenericDesktopSystemDebuggerBreak = 0xa4;
const uint16 kGenericDesktopApplicationBreak = 0xa5;
const uint16 kGenericDesktopApplicationDebuggerBreak = 0xa6;
const uint16 kGenericDesktopSystemSpeakerMute = 0xa7;
const uint16 kGenericDesktopSystemHibernate = 0xa8;
const uint16 kGenericDesktopSystemDisplayInvert = 0xb0;
const uint16 kGenericDesktopSystemDisplayInternal = 0xb1;
const uint16 kGenericDesktopSystemDisplayExternal = 0xb2;
const uint16 kGenericDesktopSystemDisplayBoth = 0xb3;
const uint16 kGenericDesktopSystemDisplayDual = 0xb4;
const uint16 kGenericDesktopSystemDisplayToggle = 0xb5;
const uint16 kGenericDesktopSystemDisplaySwap = 0xb6;
struct HidUsageAndPage {
uint16 usage;
uint16 usage_page;
};
struct HidCollectionInfo {
// Collection's usage ID.
HidUsageAndPage usage;
// HID report IDs which belong to this collection or to its
// embedded collections.
array<int32> report_ids;
};
struct HidDeviceInfo {
string guid;
uint16 vendor_id;
uint16 product_id;
string product_name;
string serial_number;
HidBusType bus_type;
array<uint8> report_descriptor;
array<HidCollectionInfo> collections;
bool has_report_id;
uint64 max_input_report_size;
uint64 max_output_report_size;
uint64 max_feature_report_size;
string device_node;
};
interface HidManagerClient {
// Notifies the client that a device is added.
DeviceAdded(HidDeviceInfo device_info);
// Notifies the client that a device is being removed; called before
// removing the device from HidService.
DeviceRemoved(HidDeviceInfo device_info);
};
interface HidManager {
// Enumerates available devices and set as a client of HidManager.
// The implementation of HidManager guarantees that the returned callback
// will always be posted earlier than DeviceAdded() and DeviceRemoved().
GetDevicesAndSetClient(associated HidManagerClient client) =>
(array<HidDeviceInfo> devices);
// Enumerates available devices only.
GetDevices() => (array<HidDeviceInfo> devices);
// Opens a connection to a device by given guid. The callback will be run
// with null on failure.
Connect(string device_guid) => (HidConnection? connection);
};
interface HidConnection {
// The report_id is returned as 0 if not supported by the device.
Read() => (bool success, uint8 report_id, array<uint8>? buffer);
// Pass the report_id as 0 if not supported by the device.
Write(uint8 report_id, array<uint8> buffer) => (bool success);
// The buffer will contain whatever report data was received from the device.
// This may include the report ID. The report ID is not stripped because a
// device may respond with other data in place of the report ID.
GetFeatureReport(uint8 report_id) => (bool success, array<uint8>? buffer);
// Pass the report_id as 0 if not supported by the device.
SendFeatureReport(uint8 report_id, array<uint8> buffer) => (bool success);
};