Skip to main content

Hands API

Interface ID 2, version 2.0. Include <ROCK/Hands.h>. Namespace rock::api::hands. Permission: Read (1), required by every function. Read-only copies of ROCK's hand, head and hand-role publications.

const rock::api::hands::Api* hands{};
client.acquire(static_cast<std::uint32_t>(rock::api::hands::Permission::Read), hands);

Entry points​

FunctionPermissionThreadPurpose
getHandFrameReadAnyROCK's control transform for a hand. NotReady until the provider has published that hand.
getPresentedHandFrameReadGameThe rendered wrist of the last completed presentation. NotReady before the first completed capture.
getPresentedHandPoseReadGameThe rendered wrist and 15 finger joints of the last completed presentation. TargetUnavailable when no capture exists for that hand.
getHeadPoseReadAnyHMD transform and forward vector of the control publication.
getRolesReadAnyWhat each physical hand holds of the equipped weapons: weapon slot and grip role.
getSampleReadAnyIdentity of the current publication.

hand must be Hand::Right or Hand::Left; anything else returns InvalidArgument.

Records​

  • HandFrame: hand, flags (HandFrameFlag), transform (world), sample.
    • getHandFrame sets Valid | RootFlattenedAuthority, plus Left for the left hand.
    • getPresentedHandFrame sets Valid | PresentedVisual, plus Left. Its sample takes frame and generations from the presentation, and the publication sequence and collision generation from the control publication frozen with that capture.
  • PresentedHandPose: hand, flags (PresentedHandPoseFlag: Valid, HandWorldValid, FingerLocalsValid, RootFlattenedReadback), handWorld, and fingerLocalTransforms[kFingerLocalTransformCount] (15), each relative to its parent joint, in the order thumb, index, middle, ring, pinky (three joints each). Bit N of fingerLocalTransformMask marks joint N as captured. The pose carries its own frameIndex, presentationSequence and generations.
  • HeadPose: sample, flags (HeadPoseFlag: TransformValid, ForwardValid), transform, forwardWorld.
  • Roles: sample, right, left, each a HandWeaponRole: weaponSlot (kNoWeaponSlot when the hand holds no equipped-weapon grip) and role (HandRole: None, Firing, Support). Firing is the weapon's firing grip; Support is any other grip of that weapon. A hand holds at most one grip of one weapon. Roles follow grip transfers; they are not the player's configured default hand.

Records from the same publication carry the same Sample; compare it before combining two reads.

HandFrameFlag bits 2 and 3 (primary and offhand role) and 4 (scene node) are retired and never reused.

rock::api::hands::HandFrame frame{};
if (hands->getHandFrame(client.owner(), rock::api::Hand::Right, &frame) == rock::api::Status::Ok) {
const float x = frame.transform.translate[0];
}

Declarations​

Complete public declarations: ROCK/Hands.h
ROCK/Hands.h
#pragma once
#include "Abi.h"

#pragma pack(push, 8)
namespace rock::api::hands {
inline constexpr InterfaceId kInterfaceId = InterfaceId::Hands;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;
inline constexpr std::uint32_t kFingerLocalTransformCount = 15;

// Bits 2 (primary role), 3 (offhand role) and 4 (scene node) are retired;
// never reuse them.
enum class HandFrameFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
Left = 1u << 1,
RootFlattenedAuthority = 1u << 5,
PresentedVisual = 1u << 6,
};

enum class PresentedHandPoseFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
HandWorldValid = 1u << 1,
FingerLocalsValid = 1u << 2,
RootFlattenedReadback = 1u << 3,
};

// One hand's world transform. getHandFrame copies ROCK's control
// publication; getPresentedHandFrame copies the last completed
// presentation joined to the control publication captured with it.
struct HandFrame
{
std::uint32_t size{ sizeof(HandFrame) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t flags{ 0 };
Transform transform{};
Sample sample{};
};

// The rendered wrist and the 15 finger joints (thumb, index, middle, ring,
// pinky; three joints each), each local to its parent joint. Bit N of
// fingerLocalTransformMask marks fingerLocalTransforms[N] as captured.
struct PresentedHandPose
{
std::uint32_t size{ sizeof(PresentedHandPose) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t flags{ 0 };
Transform handWorld{};
std::uint32_t fingerLocalTransformMask{ 0 };
Transform fingerLocalTransforms[kFingerLocalTransformCount]{};
std::uint64_t frameIndex{ 0 };
std::uint64_t presentationSequence{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};

enum class HeadPoseFlag : std::uint32_t
{
None = 0,
TransformValid = 1u << 0,
ForwardValid = 1u << 1,
};

struct HeadPose
{
std::uint32_t size{ sizeof(HeadPose) };
std::uint32_t version{ 1 };
Sample sample{};
std::uint32_t flags{ 0 };
Transform transform{};
float forwardWorld[3]{};
};

inline constexpr std::uint32_t kNoWeaponSlot = 0xFFFFFFFFu;

// A hand's grip on an equipped weapon. Firing: that weapon's firing grip.
// Support: any other grip of that weapon (its support grip or another
// part grip). None: no equipped-weapon grip.
enum class HandRole : std::uint32_t
{
None = 0,
Firing = 1,
Support = 2,
};

struct HandWeaponRole
{
// The weapon slot whose grip the hand holds; kNoWeaponSlot for None.
std::uint32_t weaponSlot{ kNoWeaponSlot };
HandRole role{ HandRole::None };
};

// What each physical hand holds of the equipped weapons in this
// publication. A hand holds at most one grip of one weapon. Roles follow
// grip transfers; they are not the player's configured default hand.
struct Roles
{
std::uint32_t size{ sizeof(Roles) };
std::uint32_t version{ 1 };
Sample sample{};
HandWeaponRole right{};
HandWeaponRole left{};
};

// Permission bits are local to this interface major. Discovery grants none.
enum class Permission : std::uint32_t { Read = 1 };
inline constexpr std::uint32_t kSupportedPermissions = 1;

struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
// Any thread. Copied control publication; check flags and sample.
Status(ROCK_CALL* getHandFrame)(OwnerToken owner, Hand hand, HandFrame* outFrame) noexcept;
// Game thread. Last completed presentation with its own frame and
// generations. Early phases may return the preceding frame; before the
// first completed capture the result is NotReady.
Status(ROCK_CALL* getPresentedHandFrame)(OwnerToken owner, Hand hand, HandFrame* outFrame) noexcept;
Status(ROCK_CALL* getPresentedHandPose)(OwnerToken owner, Hand hand, PresentedHandPose* outPose) noexcept;
// Any thread. Copied control publication.
Status(ROCK_CALL* getHeadPose)(OwnerToken owner, HeadPose* outPose) noexcept;
Status(ROCK_CALL* getRoles)(OwnerToken owner, Roles* outRoles) noexcept;
// Any thread. Identity of the current publication; compare it with a
// record's sample before combining readbacks.
Status(ROCK_CALL* getSample)(OwnerToken owner, Sample* outSample) noexcept;
};
}

#pragma pack(pop)