From 884bd83f299bb1e9bddb07113a6062e81729f23f Mon Sep 17 00:00:00 2001 From: Kojack Date: Sun, 21 Jan 2018 08:43:04 +1000 Subject: [PATCH] Changed initialisation to use Invisible mode. Added button comments to example script. --- auto_oculus_touch/dllmain.cpp | 2 +- bin/oculus_touch.ahk | 144 +++++++++++++++++----------------- readme.txt | 5 +- 3 files changed, 77 insertions(+), 74 deletions(-) diff --git a/auto_oculus_touch/dllmain.cpp b/auto_oculus_touch/dllmain.cpp index 2ef5574..0ac7b1c 100644 --- a/auto_oculus_touch/dllmain.cpp +++ b/auto_oculus_touch/dllmain.cpp @@ -24,7 +24,7 @@ extern "C" ovrGraphicsLuid g_luid; ovrInitParams params; - params.Flags = 0; + params.Flags = ovrInit_Invisible; params.ConnectionTimeoutMS = 0; params.RequestedMinorVersion = 8; params.UserData = 0; diff --git a/bin/oculus_touch.ahk b/bin/oculus_touch.ahk index 9d8c689..8967cbf 100644 --- a/bin/oculus_touch.ahk +++ b/bin/oculus_touch.ahk @@ -7,23 +7,23 @@ ;/////////////////////////////////////////////////////////////////////////////// ; Button enums -ovrA := 0x00000001 -ovrB := 0x00000002 -ovrRThumb := 0x00000004 -ovrRShoulder := 0x00000008 -ovrX := 0x00000100 -ovrY := 0x00000200 -ovrLThumb := 0x00000400 -ovrLShoulder := 0x00000800 -ovrUp := 0x00010000 -ovrDown := 0x00020000 -ovrLeft := 0x00040000 -ovrRight := 0x00080000 -ovrEnter := 0x00100000 -ovrBack := 0x00200000 -ovrVolUp := 0x00400000 -ovrVolDown := 0x00800000 -ovrHome := 0x01000000 +ovrA := 0x00000001 ; Touch-A Remote-Select Xbox-A +ovrB := 0x00000002 ; Touch-B Remote-Back Xbox-B +ovrRThumb := 0x00000004 ; Touch-Right Stick Remote-None Xbox-Right Thumbstick +ovrRShoulder := 0x00000008 ; Touch-None Remote-None Xbox-Right Shoulder +ovrX := 0x00000100 ; Touch-X Remote-None Xbox-X +ovrY := 0x00000200 ; Touch-Y Remote-None Xbox-Y +ovrLThumb := 0x00000400 ; Touch-Left Stick Remote-None Xbox-Left Thumbstick +ovrLShoulder := 0x00000800 ; Touch-None Remote-None Xbox-Left Shoulder +ovrUp := 0x00010000 ; Touch-None Remote-Up Xbox-Up +ovrDown := 0x00020000 ; Touch-None Remote-Down Xbox-Down +ovrLeft := 0x00040000 ; Touch-None Remote-Left Xbox-Left +ovrRight := 0x00080000 ; Touch-None Remote-Right Xbox-Right +ovrEnter := 0x00100000 ; Touch-Left Menu Remote-None Xbox-Start +ovrBack := 0x00200000 ; Touch-None Remote-None Xbox-Back +ovrVolUp := 0x00400000 ; Touch-None Remote-Volume Up Xbox-None +ovrVolDown := 0x00800000 ; Touch-None Remote-Volume Down Xbox-None +ovrHome := 0x01000000 ; Touch-Oculus Remote-Oculus Xbox-Home ; Capacitive touch sensors ovrTouch_A := 0x00000001 @@ -59,20 +59,20 @@ YAxis := 1 GetTrigger(hand, trigger) { - return DllCall("auto_oculus_touch\getTrigger", "Int", hand, "Int", trigger, "Float") + return DllCall("auto_oculus_touch\getTrigger", "Int", hand, "Int", trigger, "Float") } GetThumbStick(hand, axis) { - return DllCall("auto_oculus_touch\getThumbStick", "Int", hand, "Int", axis, "Float") + return DllCall("auto_oculus_touch\getThumbStick", "Int", hand, "Int", axis, "Float") } Vibrate(controller, frequency, amplitude) { - DllCall("auto_oculus_touch\setVibration", "UInt", controller, "Float", frequency, "Float", amplitude) + DllCall("auto_oculus_touch\setVibration", "UInt", controller, "Float", frequency, "Float", amplitude) } -; Grab the library. +; Grab the library. hModule := DllCall("LoadLibrary", "Str", "auto_oculus_touch.dll", "Ptr") ; Start the Oculus sdk. @@ -83,56 +83,56 @@ oldTrigger:=0 ; Main polling loop. Loop { - ; Grab the latest Oculus input state (Touch, Remote and Xbox One). - DllCall("auto_oculus_touch\poll") - - ; Get the various analog values. Triggers are 0.0-1.0, thumbsticks are -1.0-1.0 - leftIndexTrigger := GetTrigger(LeftHand, IndexTrigger) - leftHandTrigger := GetTrigger(LeftHand, HandTrigger) - rightIndexTrigger := GetTrigger(RightHand, IndexTrigger) - rightHandTrigger := GetTrigger(RightHand, HandTrigger) - leftX := GetThumbStick(LeftHand, XAxis) - leftY := GetThumbStick(LeftHand, YAxis) - rightX := GetThumbStick(RightHand, XAxis) - rightY := GetThumbStick(RightHand, YAxis) - - ; Get button states. - ; Down is the current state. If you test with this, you get a key every poll it is down. Repeating. - ; Pressed is set if transitioned to down in the last poll. Non repeating. - ; Released is set if transitioned to up in the last poll. Non repeating. - down := DllCall("auto_oculus_touch\getButtonsDown") - pressed := DllCall("auto_oculus_touch\getButtonsPressed") - released := DllCall("auto_oculus_touch\getButtonsReleased") - touchDown := DllCall("auto_oculus_touch\getTouchDown") - touchPressed := DllCall("auto_oculus_touch\getTouchPressed") - touchReleased := DllCall("auto_oculus_touch\getTouchReleased") - - ; Now to do something with them. - - ; Move the mouse using the right thumb stick. - if (rightX>0.1) or (rightX<-0.1) or (rightY>0.1) or (rightY<-0.1) - MouseMove, rightX*10,rightY*-10,0,R - - ; Use the X button as a left mouse button - if pressed & ovrX - Send, {LButton down} - if released & ovrX - Send, {LButton up} - - ; Use the right index trigger as the left mouse button - if (rightIndexTrigger > 0.8) and (oldTrigger<=0.8) - Send, {LButton down} - if (rightIndexTrigger <= 0.8) and (oldTrigger>0.8) - Send, {LButton up} - - ; Use the up/down on the Oculus remote to cycle media tracks. - if released & ovrDown - Send, {Media_Next} - if released & ovrUp - Send, {Media_Prev} - - oldTrigger := rightIndexTrigger - - Sleep, 10 + ; Grab the latest Oculus input state (Touch, Remote and Xbox One). + DllCall("auto_oculus_touch\poll") + + ; Get the various analog values. Triggers are 0.0-1.0, thumbsticks are -1.0-1.0 + leftIndexTrigger := GetTrigger(LeftHand, IndexTrigger) + leftHandTrigger := GetTrigger(LeftHand, HandTrigger) + rightIndexTrigger := GetTrigger(RightHand, IndexTrigger) + rightHandTrigger := GetTrigger(RightHand, HandTrigger) + leftX := GetThumbStick(LeftHand, XAxis) + leftY := GetThumbStick(LeftHand, YAxis) + rightX := GetThumbStick(RightHand, XAxis) + rightY := GetThumbStick(RightHand, YAxis) + + ; Get button states. + ; Down is the current state. If you test with this, you get a key every poll it is down. Repeating. + ; Pressed is set if transitioned to down in the last poll. Non repeating. + ; Released is set if transitioned to up in the last poll. Non repeating. + down := DllCall("auto_oculus_touch\getButtonsDown") + pressed := DllCall("auto_oculus_touch\getButtonsPressed") + released := DllCall("auto_oculus_touch\getButtonsReleased") + touchDown := DllCall("auto_oculus_touch\getTouchDown") + touchPressed := DllCall("auto_oculus_touch\getTouchPressed") + touchReleased := DllCall("auto_oculus_touch\getTouchReleased") + + ; Now to do something with them. + + ; Move the mouse using the right thumb stick. + if (rightX>0.1) or (rightX<-0.1) or (rightY>0.1) or (rightY<-0.1) + MouseMove, rightX*10,rightY*-10,0,R + + ; Use the X button as a left mouse button + if pressed & ovrX + Send, {LButton down} + if released & ovrX + Send, {LButton up} + + ; Use the right index trigger as the left mouse button + if (rightIndexTrigger > 0.8) and (oldTrigger<=0.8) + Send, {LButton down} + if (rightIndexTrigger <= 0.8) and (oldTrigger>0.8) + Send, {LButton up} + + ; Use the up/down on the Oculus remote to cycle media tracks. + if released & ovrDown + Send, {Media_Next} + if released & ovrUp + Send, {Media_Prev} + + oldTrigger := rightIndexTrigger + + Sleep, 10 } diff --git a/readme.txt b/readme.txt index f38aa12..1cd67c4 100644 --- a/readme.txt +++ b/readme.txt @@ -15,7 +15,7 @@ You must have AutoHotKey installed. It is available from https://autohotkey.com Change History v0.1.1 - Initial release. Built against Oculus SDK 1.10 v0.1.2 - Added capacitive sensor support. Built against Oculus SDK 1.20 - +v0.1.3 - Changed initialisation to use Invisible mode. Added button comments to example script. Installation AutoOculusTouch can be placed anywhere. No explicit installation is required. @@ -46,8 +46,11 @@ AutoOculusTouch can give you: Important Notes +(v0.1.2 and below) Due to the way the Oculus SDK works, running AutoOculusTouch will make Oculus Home or Dash think that a VR application is running that isn't rendering. The original intent was for AutoOculusTouch to run when no headset is being worn, such as using the Oculus Remote for controlling a PC for media playback, so this didn't matter. Running both AutoOculusTouch and another VR application at the same time probably shouldn't work, but it currently seems to. What does this mean? Well, Oculus Home and Dash refuse to run a VR app while another is already running. But you can still run multiple apps at once if you start them using a means besides Home or Dash (such as explorer). +(v0.1.3 and above) +The note above is no longer valid in these versions. By setting the Invisible flag when calling the oculus sdk, AutoOculusTouch no longer appears to Dash as a VR app. This means it won't make the headset show a never ending loading screen and other VR apps can be run from Dash without an error.