#[non_exhaustive]pub enum KnownUnit {
Show 23 variants
None = 0,
Centimeter = 17,
Radian = 18,
Inch = 19,
Degree = 20,
Gram = 257,
Seconds = 4_097,
Hertz = 61_441,
SiVelocity = 61_457,
SiMomentum = 61_713,
SiAcceleration = 57_361,
SiForce = 57_617,
SiEnergy = 57_633,
SiAngularVelocity = 61_458,
DegAngularVelocity = 61_460,
SiAngularAcceleration = 57_362,
DegAngularAcceleration = 57_364,
Kelvin = 65_537,
DegreesFahrenheit = 65_539,
Current = 1_048_577,
AmpSeconds = 1_052_673,
Voltage = 15_782_177,
SiPower = 53_537,
}Expand description
Identifiers for some known Unit values.
Due to the complexity of the HID unit system, this enum does not attempt to represent all the possible unit values.
Unit values are 32 bits long, split into 8 nibbles (4-bit fields).
The lowest nibble (bits 3..0) specify a unit system:
1: SI Linear2: SI Rotation3: English Linear4: English Rotation
The other 5 nibbles are dedicated to individual unit categories:
- nibble 1 (bits 7..4): Length (Centimeter, Radian, Inch, or Degree)
- nibble 2 (bits 11..8): Mass (Gram or Slug)
- nibble 3 (bits ..12): Time (Seconds in all systems)
- nibble 4 (bits ..16): Temperature (Kelvin or Fahrenheit)
- nibble 5 (bits ..20): Current (Ampere in all systems)
- nibble 6 (bits ..24): Luminous Intensity (Candela in all systems)
- nibble 7 (bits 31..28): reserved
The value in each nibble is a signed integer from -8 to +7, and that integer is the exponent attached to each unit. For example:
0x23is Length^2 in the English Linear system, or Inch^2.0x101is Mass^1 in the SI Linear system, or Gram.0xF011is Time^-1 * Length^1, or Centimeters/Second.
See Device Class Definition for Human Interface Devices, section 6.2.2.7 for more details.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None = 0
No unit.
Centimeter = 17
SI unit of length.
Radian = 18
SI unit of rotation.
Inch = 19
English unit of length.
Degree = 20
English unit of rotation.
Gram = 257
SI unit of mass.
Seconds = 4_097
SI unit of time.
Hertz = 61_441
SI unit of frequency, Hertz aka second⁻¹)
SiVelocity = 61_457
SI unit of velocity (centimeters/second).
SiMomentum = 61_713
SI unit of momentum (gram·centimeter/second).
SiAcceleration = 57_361
SI unit of acceleration (centimeters/second²).
SiForce = 57_617
SI unit of force (gram·centimeter/second²).
Divide by 10⁵ to get Newtons (kg·m/s²).
SiEnergy = 57_633
SI unit of energy (gram·centimeter²/second²).
Divide by 10⁷ to get Joules (kg·m²/s²).
SiAngularVelocity = 61_458
SI unit of Angular Velocity (radians/second).
DegAngularVelocity = 61_460
English unit of Angular Acceleration (degrees/second).
SiAngularAcceleration = 57_362
SI unit of Angular Acceleration (radians/second²).
DegAngularAcceleration = 57_364
English unit of Angular Acceleration (degrees/second²).
Kelvin = 65_537
SI unit of temperature.
DegreesFahrenheit = 65_539
English unit of temperature.
Current = 1_048_577
SI unit of current (amperes).
AmpSeconds = 1_052_673
SI unit for amp·seconds.
This unit can be used as “battery capacity”. See Usage Tables for HID Power Devices.
Voltage = 15_782_177
SI unit of Voltage (gram·centimeter²/amp·seconds³).
Divide by 10⁷ to get Volts (kg·m²/amp·seconds³).
SiPower = 53_537
SI unit of power (gram-centimeter²/seconds³).
Divide by 10⁷ to get Watts or Volt-Amps (kg·m²/s³).