gusmanb / PSVRFramework

GNU Affero General Public License v3.0
195 stars 37 forks source link

Feature request - Double Tap Recenter #38

Open mungewell opened 7 years ago

mungewell commented 7 years ago

While in Cinematic mode, finding the key/using the mouse to re-center the screen is a pain.

Can the toolbox sense a double tap on the accelerometers to recenter the screen? Simon

dproldan commented 7 years ago

I have done exactly that. Works really wel.

I'll post details when i get home.

El 19 nov. 2016 7:00 p. m., "mungewell" notifications@github.com escribió:

While in Cinematic mode, finding the key/using the mouse to re-center the screen is a pain.

Can the toolbox sense a double tap on the accelerometers to recenter the screen? Simon

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gusmanb/PSVRFramework/issues/38, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhEzpOz-9BnB_WE9ISCQqvjCinpop-Zks5q_zlWgaJpZM4K3UeH .

gusmanb commented 7 years ago

@dproldan Nice!, any help is welcome.

@mungewell Was thinking about it these days, not only to detect a tap but "clicks", with the correct algorithms, from the sensor readings in theory these can be detected, I've used in the past acceleromters with this functionality integrated and they detect it based on the force curve, so this must be achievable in code. We can use these clicks to different functions, I was thinking on the mouse emulator, single-click left mouse button, double-click right mouse button.

We can start with a simple tamp detect based on the @dproldan code (or maybe the code already detects clicks, that would be wonderful) and with time advance to a more complex click detection.

dproldan commented 7 years ago

This is what I've been using to recenter the mouse, I'm not a sw developer, so this is probably too crude, but maybe you can use it as a proof of concept. // Used both axis so the knock has to be on the chamfered edge of the headset.

device.on("data", function(data) {
          acc.yaw = -data.yaw * 0.00080;
          acc.pitch = -data.pitch * 0.00080;
          knock= data.yAccel1+data.xAccel1;
          doThings();
          });
var doThings = function() {
    mouse.Place(ptX, ptY);
    ptX = 720+acc.yaw;
    ptY = 450+acc.pitch;
    if (ptX>1960) {ptX=1960};
    if (ptY>1080) { ptY=1080};
    if (knock>=30000) {device.resetYaw();device.resetPitch()}
                           };
    resetYaw() {
    this._yaw = 0;
  }
    resetPitch() {
        this._pitch = 0;
    }
gusmanb commented 7 years ago

I've tested the code and was too unreliable, some taps were detected when moving the head fast in diagonal.

So, I rolled my own tap detector and seems to work quite well.

It detects a double tap in any direction as I'm using the force vector magnitude, it must be a fast double tap, I use two fingers to do it and nearly 100% of the taps are correctly detected, and unless you remove the hmd it does not detect false taps.

Some important thig is when the toolbox boots if the hmd is powered on it must be stable, else if it's powered on after the toolbox it must remain in that time stable, in that interval the gravity magnitude is computed. If the tests are good I will do as the PS4 does, wait until the helmet is worn and stabilizes to measure the gravity to avoid false calibrations.

Test and share results.

test_tap.zip