Jump to content

Recommended Posts

Posted

This is what I figured out.

const int INDEX_BUTTON_B = 1;
const int INDEX_BUTTON_A = 2;// also squeeze handle
const int INDEX_BUTTON_DPAD = 32;// also touchpad button
const int INDEX_BUTTON_TRIGGER = 33;

const int INDEX_AXIS_DPAD = 0;// this is also the touchpad
const int INDEX_AXIS_TRIGGER = 1;

const int VIVE_BUTTON_TOUGHPAD = 32;
const int VIVE_BUTTON_TRIGGER = 33;
const int VIVE_BUTTON_MENU = 1;
const int VIVE_BUTTON_GRIP = 2;

const int VIVE_AXIS_TOUCHPAD = 0;
const int VIVE_AXIS_TRIGGER = 1;// x axis only

More info: https://www.vive.com/hk/support/vive-pro-hmd/category_howto/about-the-controllers.html

This is the code I am using to test:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CLIENTCOORDS | WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a world
    auto world = CreateWorld();

    //Get the VR headset
    auto hmd = GetHmd(world);

    //Environment maps
    auto specmap = LoadTexture("https://github.com/UltraEngine/Assets/raw/main/Materials/Environment/footprint_court/specular.dds");
    auto diffmap = LoadTexture("https://github.com/UltraEngine/Assets/raw/main/Materials/Environment/footprint_court/diffuse.dds");
    world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND);
    world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR);
    world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE);

    //Add a floor
    auto floor = CreateBox(world, 5, 1, 5);
    floor->SetPosition(0, -0.5, 0);
    auto mtl = CreateMaterial();
    mtl->SetTexture(LoadTexture("https://github.com/UltraEngine/Documentation/raw/master/Assets/Materials/Developer/griid_gray.dds"));
    floor->SetMaterial(mtl);

    const int INDEX_BUTTON_B = 1;
    const int INDEX_BUTTON_A = 2;// also squeeze handle
    const int INDEX_BUTTON_DPAD = 32;// also touchpad button
    const int INDEX_BUTTON_TRIGGER = 33;

    const int VIVE_BUTTON_TOUGHPAD = 32;
    const int VIVE_BUTTON_TRIGGER = 33;
    const int VIVE_BUTTON_MENU = 1;

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        bool change = false;

        //Test axes
        float tol = 0.01f;
        for (int n = 0; n < 64; ++n)
        {
            for (int k = 0; k < 2; ++k)
            {
                if (hmd->controllers[k])
                {
                    auto v = hmd->controllers[k]->GetAxis(VrControllerAxis(n));
                    if (Abs(v.x) > tol or Abs(v.y) > tol)
                    {
                        window->SetText("Axis " + String(n) + ": " + String(v.x) + ", " + String(v.y));
                        change = true;
                        break;
                    }
                }
            }
        }

        // Check buttons        
        for (int n = 0; n < 64; ++n)
        {
            for (int k = 0; k < 2; ++k)
            {
                if (hmd->controllers[k] and hmd->controllers[k]->ButtonDown(VrControllerButton(n)))
                {
                    window->SetText("Button: " + String(n));
                    change = true;
                }
            }
        }
        
        if (not change) window->SetText("");

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Let's build cool stuff and have fun. :)

Posted

Okay, no big surprises here, but I noted some small details.

It does not appear to be possible to retrieve the Index finger orientations with the original OpenVR interface. I will look into this next.

Let's build cool stuff and have fun. :)

Posted

I don't think there is any way to get finger tracking data from Knuckles controllers without using Valve's horrible action manifest system.

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...