Enumerations

enum class UnitType : uint32_t
Name Value Comments
None 0

This is used when a HID device does not specify units.

Other 1

This is used when a HID device has a set of units not described below.

Distance 2

A measurement of distance in 10^-6 meter units.

Weight 3

A measurement of weight in 10^-3 gram units.

Rotation 4

A measurement of rotation is 10^-3 degree.

AngularVelocity 5

A measurement of angular velocity is 10^-3 deg/s.

LinearVelocity 6

A measurement of linear velocity is 10^-3 m/s

Acceleration 7

A measurement of acceleration is 10^-3 Gs

MagneticFlux 8

A measurement of magnetic_flux is 10^-6 Tesla (kg/(Amp * s^2))

Light 9

A measurement of light is 1 Candela.

Pressure 10

A measurement of pressure is 10^-3 Pascal (kg/(m*s^2))

Lux 11

A measurement of lux is 10^-6 Candela/(m^2)

UnitTypes are the helpful, "default" units in the system.

These should used throughout the system.

Defined at line 16 of file ../../src/ui/input/lib/hid-parser/include/lib/hid-parser/units.h

enum class System : int8_t
Name Value Comments
si_linear 0x1

SI Linear has the following units:
centimeter, gram, seconds, kelvin, ampere, candela.

si_rotation 0x2

SI Rotation has the following units:
radians, gram, seconds, kelvin, ampere, candela.

eng_linear 0x3

English Linear has the following units:
inch, slug, seconds, fahrenheit, ampere, candela.

eng_rotation 0x4

English Rotation has the following units:
degrees, slug, seconds, fahrenheit, ampere, candela.

reserved 0x5

English Rotation has the following units:
degrees, slug, seconds, fahrenheit, ampere, candela.

Each system defines the units for the following measurements:

length, mass, time, temperature, current, luminous intensity.

Defined at line 59 of file ../../src/ui/input/lib/hid-parser/include/lib/hid-parser/units.h

Records

Functions

  • Unit GetUnitFromUnitType (UnitType type)

    Get the exact unit from the UnitType.

    Defined at line 370 of file ../../src/ui/input/lib/hid-parser/units.cc

  • UnitType GetUnitTypeFromUnit (const Unit & unit)

    Get the closest convertible UnitType from the unit.

    If the unit cannot be converted into a UnitType, |Other| will be returned.

    If there are no unit's, |None| will be returned.

    Defined at line 380 of file ../../src/ui/input/lib/hid-parser/units.cc

  • double ConvertValToUnitType (const Unit & unit_in, double val_in)

    Defined at line 392 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetSystem (Unit & unit, hid::unit::System system)

    Sets a Unit's system. A unit can only belong to a single system.

    Calling SetSystem on a Unit that already has a system defined

    will overwrite the current system.

    Defined at line 184 of file ../../src/ui/input/lib/hid-parser/units.cc

  • hid::unit::System GetSystem (const Unit & unit)

    Defined at line 188 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetLengthExp (Unit & unit, int8_t exp)

    The functions below set the exponent for various measurements.

    exp must be within [-8, 7].

    The measurement's unit is defined by the Unit's system.

    Example: Momentum is (mass * distance / time) so it has a mass

    exponent of 1, a distance exponent of 1, and a time

    exponent of -1. Under the SI Linear system this would

    be (gram * centimeter / seconds).

    Defined at line 204 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetMassExp (Unit & unit, int8_t exp)

    Defined at line 206 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetTimeExp (Unit & unit, int8_t exp)

    Defined at line 208 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetTemperatureExp (Unit & unit, int8_t exp)

    Defined at line 210 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetCurrentExp (Unit & unit, int8_t exp)

    Defined at line 214 of file ../../src/ui/input/lib/hid-parser/units.cc

  • void SetLuminousExp (Unit & unit, int8_t exp)

    Defined at line 216 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetLengthExp (const Unit & unit)

    The functions below get the exponent for various measurements.

    The return value will be within [-8, 7].

    Defined at line 218 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetMassExp (const Unit & unit)

    Defined at line 220 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetTimeExp (const Unit & unit)

    Defined at line 222 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetTemperatureExp (const Unit & unit)

    Defined at line 224 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetCurrentExp (const Unit & unit)

    Defined at line 226 of file ../../src/ui/input/lib/hid-parser/units.cc

  • int GetLuminousExp (const Unit & unit)

    Defined at line 228 of file ../../src/ui/input/lib/hid-parser/units.cc

  • bool ConvertUnits (const Unit & unit_in, double val_in, const Unit & unit_out, double * val_out)

    Convert a value from one unit to another.

    Returns False if it is impossible to do the conversion.

    Defined at line 230 of file ../../src/ui/input/lib/hid-parser/units.cc