Giter Site home page Giter Site logo

auto_oculus_touch's Introduction

AutoOculusTouch - Helper library to provide AutoHotKey with Oculus Touch state.
Copyright (C) 2021 Kojack ([email protected])

AutoOculusTouch is released under the MIT License  
https://opensource.org/licenses/MIT


AutoOculusTouch is a library and script for AutoHotKey. It allows you to read the state of oculus controller devices (Touch, Remote or XBox controller) from within an AutoHotKey script.

Prerequisites
You must have AutoHotKey installed. It is available from https://autohotkey.com
(AutoOculusTouch is tested against AutoHotKey version 1.1.33.02)
If you want vJoy support, you must have it installed. It is available from http://vjoystick.sourceforge.net/site/index.php/download-a-install
(AutoOculusTouch is tested against vJoy version 2.1.8)


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.
v0.1.4 - Added vibration. Added orientation tracking (yaw, pitch, roll) for touch. More example scripts. Built against Oculus SDK 1.26
v0.1.5 - Added vJoy integration. You can now output gamepad/joystick values for axes and buttons.
v0.1.6 - The vJoy installer has a slightly higher version than the latest vJoy sdk, which breaks compatibility. I've updated it so it should work again. I've added in the Oculus and vJoy sdk files needed to compile, some people had issues setting things up. It should be fairly self contained now. Built against Oculus SDK 1.41. I've improved the vJoy script to have all buttons.
v0.1.7 - Added new functions to get axis and button values. Added position tracking for controllers and headset. Added headset rotation. Added tracking origin control (floor or eye). Changed vibration to take a length to play an effect for (replaces oneShot parameter). Updated the example scripts. Changed main auto_oculus_touch.ahk script to use faster DLLCall system. Added error messageboxes for init of oculus and vjoy. Added raw mouse movement and buttons, for games made with Unity that ignore normal AHK mouse. Updated Oculus SDK to v23.

Installation
AutoOculusTouch can be placed anywhere. No explicit installation is required.
There are several files included in the AutoOculusTouch binary release:
- auto_oculus_touch.dll      (A library that wraps around the Oculus SDK.
- vJoyInterface.dll			 (Interface to the vJoy drivers)
- auto_oculus_touch.ahk      (An AutoHotKey script that defines various Oculus related functions. This is needed by the other scripts)
- oculus_remote_mouse.ahk    (Lets you use the remote as a mouse. Up/Down/Left/Right move. The centre button is left mouse. The back button is right mouse)
- oculus_remote_spotify.ahk  (Send media keys with the remote. Up is previous track, Down is next track, centre button is play/pause. Not just for spotify, works with any media key compatible program)
- oculus_touch_mouse.ahk     (Move the mouse with the right touch controller. Index trigger is left mouse. A is right mouse. Thumbstick is mouse move. Press B to reset yaw centre point to your current heading)
- oculus_touch_air_mouse.ahk (Move the mouse using pitch and yaw, like an LG TV remote, when you are holding the right hand trigger. Index trigger is left mouse.
- oculus_touch_test.ahk      (Display a GUI of all touch values)
- oculus_touch_vjoy.ahk      (Turn the Touch controllers into a virtual gamepad for DirectInput games)

You should keep these files together. The auto_oculus_touch.dll should be in the same location as any scripts you want to run.


Running
To start AutoOculusTouch, double click on one of the scripts (not auto_oculus_touch.ahk, it doesn't do anything on it's own). A green icon with a white H should appear in your system tray. AutoOculusTouch is now running.


Customising
The provided scripts has some example behaviour already defined. You can change any of this, or make your own.

AutoOculusTouch can give you:
- index and hand triggers of a Touch, as floats from 0.0 to 1.0.
- thumbstick axes as floats from -1.0 to 1.0.
- all Touch, Remote and XBox buttons (except the Oculus Home button and remote volume buttons).
- all Touch capacitive sensors.
- all Touch capacitive gestures (index pointing and thumbs up for either hand).
- Pitch, Roll and Yaw of both touch controllers and headset in degrees.
- Position of both touch controllers and headset in metres.
- Set continuous or limited time vibration effects of different frequencies and amplitudes on either touch controller.

Vibration Use
Vibration has 3 properties: frequency, amplitude and oneshot.
Frequency: 1==320Hz, 2==160Hz, 3==106.7Hz, 4=80Hz  (this is the frequency of vibration)
Amplitude: 0-255 (0 stops vibration, 1-255 are the strength)

Orientation Use
Yaw: clockwise is positive
Pitch: aiming up is positive
Roll: tilting clockwise is positive
Yaw works a little different to the other two angles. Pitch and roll have definite zero angles that make sense (holding the controller level). But yaw is based on where the controller is aiming when powered on. To fix this, you can call ResetFacing(controllerNumber) to record the current direction as a Yaw of 0 degrees.
Each controller may have a different Yaw origin.

vJoy Support
Normally AutoHotKey can only generate keyboard and mouse events.
vJoy is a driver that emulates one or more virtual joysticks with configurable features. AutoOculusTouch can now send analog axis and digital button values to vJoy. This lets you use Touch (or the remote) as a gamepad in games that support DirectInput.
Note: while most of the controls match an XBox controller, it technically isn't one. Any game that uses XInput directly can't see vJoy. Only DirectInput games will work here.

To use vJoy support, you need to install the vJoy drivers. You can download them from here: http://vjoystick.sourceforge.net/site/index.php/download-a-install
If you don't want vJoy support, you don't need to install the drivers, this is an optional feature, AutoOculusTouch works like v0.1.4 without it.

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.

(v0.1.7 and above)
New ways to access buttons and triggers have been added. You no longer need to grab the full buttons state and do boolean maths on them. You also no longer need to store previous trigger values to check of crossing over a value, there's a function for that.
The old way is still available existing scripts should work the same.

Different Headset Behaviour
Different Oculus headsets behave differently when not being worn (having the face sensor triggered). This is the Oculus SDK's behaviour, not Auto Oculus Touch.
Rift CV1 - When not worn for around 18 seconds, position tracking is disabled. Rotation tracking continues, but is purely IMU based (instead of the cameras) so the yaw can drift over time.
Rift-S - When not worn for around 18 seconds, position tracking, rotation tracking and vibration is disabled. Buttons, triggers and thumbsticks keep working.
Quest 1/2 Link - When not worn for around 16 seconds, everything stops. No tracking, buttons, etc. The controllers are completely shut down.

You can trick the headset into running by placing something (like a cloth) over the face sensor (just above the lenses, in the middle). But be warned, when it is triggered, all controls will be picked up by the Home app. You may be accidentally clicking on things (like the store!). I have plans to fix this, but it means adding rendering to AOT.

Function Reference

InitOculus()
- Initialise Auto Oculus Touch, start the Oculus runtime.

InitvJoy(device)
- Start the vJoy input feeder. Device is the number of the vJoy virtual gamepad. The first gamepad is 1. Only a single vJoy controller can be used by an AOT script, but you can have multiple scripts runnings at once, each using a different vJoy controller.

Poll()
- Update the tracking state and all inputs. Poll() should be called regularly (such as 90+ times a second), otherwise all inputs stop updating.

Wearing()
- Check if the headset is being worn (face sensor).
- Returns: 0 if not worn, 1 if worn.

IsDown(button), IsPressed(button), IsReleased(button)
- Check if a button is active. Down means held down, Pressed means changed from up to down since the last Poll(), Released means changed from down to up since the last Poll().
- button: one of the button enums from auto_oculus_touch.ahk, such as ovrA.
- Returns: 1 if pressed/released/down, otherwise 0.

IsTouchDown(button), IsTouchPressed(button), IsTouchReleased(button)
- Check if a capacitive touch sensor is active. Down means held down, Pressed means changed from up to down since the last Poll(), Released means changed from down to up since the last Poll().
- button: one of the capacitive sensor enums from auto_oculus_touch.ahk, such as ovrTouch_A.
- Returns: 1 if pressed/released/down, otherwise 0.

GetButtonsDown(), GetButtonsPressed(), GetButtonsReleased()
- Gets the state of every button as a bit field (one bit per button). Down means held down, Pressed means changed from up to down since the last Poll(), Released means changed from down to up since the last Poll().
- Returns: bit field. You can check a button by masking it with a button enum.
Example:
if GetButtonsDown() & ovrA

GetTouchDown(), GetTouchPressed(), GetTouchReleased()
- Gets the state of every button as a bit field (one bit per button). Down means held down, Pressed means changed from up to down since the last Poll(), Released means changed from down to up since the last Poll().
- Returns: bit field. You can check a button by masking it with a button enum.
Example:
if GetTouchDown() & ovrTouch_A

GetAxis(axis)
- Gets the current value of an analog axis, such as a trigger ot thumbstick.
- axis: one of the axis enums from auto_oculus_touch.ahk, such as AxisIndexTriggerLeft.
- Returns: triggers give 0.0 to 1.0 range. Thumbstick axes give -1.0 to 1.0 range.

Reached(axis, threshold)
-Check if an analog axis has crossed over a threshold value since the last Poll().
-axis: one of the axis enums from auto_oculus_touch.ahk, such as AxisIndexTriggerLeft.
-threshold: value that triggers an activation. 
-Returns: If the axis went from below threshold to equal or greater, returns 1.
          If the axis went from greater or equal to the threshold to below, returns -1.
		  If the threshold wasn't crossed since the last Poll(), returns 0.

GetTrigger(hand, trigger)
- Gets the current value of a trigger.
- hand: LeftHand or RightHand enums (0 or 1)
- trigger: IndexTrigger or HandTrigger enums
- Returns: 0.0 to 1.0

GetThumbStick(hand, axis)
- Gets the current value of a thumbstick axis.
- hand: LeftHand or RightHand enums (0 or 1)
- axis: XAxis or YAxis enums
- Returns: -1.0 to 1.0

GetPitch(controller)
- Get the Pitch in degrees of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: angle in degrees in -90.0 to 90.0 range.

GetYaw(controller)
- Get the Yaw in degrees of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: angle in degrees in -180.0 to 180.0 range.

GetRoll(controller)
- Get the Roll in degrees of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: angle in degrees in -180.0 to 180.0 range.

GetPositionX(controller)
- Get the X position in metres of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: position.

GetPositionY(controller)
- Get the Y position in metres of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: position.

GetPositionZ(controller)
- Get the Z position in metres of a touch controller or headset.
- controller: LeftHand, RightHand or Head enums.
- Returns: position.

SetTrackingOrigin(origin)
- Set the origin type used by the tracking system. Floor origin places (0,0,0) at the room calibrated origin at floor level. Eye origin places (0,0,0) where the headset is when started.
- origin: OriginEye or OriginFloor enums.

ResetFacing(controller)
- Reset the current Yaw to 0.
- controller: LeftHand, RightHand or Head enums.

SetvJoyAxis(axis, value)
- Send an axis value to vJoy.
- axis: one of the vJoy HID enums such as HID_USAGE_X.
- value: 0.0 to 1.0 range

SetvJoyAxisU(axis, value)
- Send an axis value to vJoy, expanding it's range from (0.0 to 1.0) to (-1.0 to 1.0).
- axis: one of the vJoy HID enums such as HID_USAGE_X.
- value: 0.0 to 1.0 range

SetvJoyButton(button, value)
- Send a button state to vJoy.
- button: the number of a button, starting at 1.
- value: 0 for up, 1 for down.

SendRawMouseMove(x, y, z)
- Some games ignore AutoHotKey mouse movement. This attempts to fix that.
- x: x axis movement offset.
- y: y axis movement offset.
- z: mouse wheel movement offset.

SendRawMouseButtonDown(button), SendRawMouseButtonUp(button)
- Some games ignore AutoHotKey mouse buttons. This attempts to fix that.
- button: LeftMouse, RightMouse or MiddleMouse enums

Vibrate(controller, frequency, amplitude, length)
- Turn on or off vibration of a controller.
- controller: LeftHand or RightHand enum.
- frequency: 1==320Hz, 2==160Hz, 3==106.7Hz, 4=80Hz
- amplitude: 0 to 255 for vibration strength.
- length: If 0, the vibration is infinite, otherwise it is the length in seconds before the vibration stops.


Simple Starting Script
	#include auto_oculus_touch.ahk
	InitOculus()
	Loop {
		Poll()
		; Do your stuff here.
		Sleep, 10
	}


auto_oculus_touch's People

Contributors

rajetic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto_oculus_touch's Issues

Positional X,Y,Z, are unable to reorient

I made a script for War Thunder who use vJoy to map touch movement to move stick and thottle , similar to ultrawings.
I was succeffully able to use gyro rotations: roll pitch and yaw, but my attemp to use X,Y,Z positional movement is stuck to a problem.
I can't find a way to reorient this axis If I reset my view direction in game.
It seems the orientation is always the one of the original guradian setup.

ResetFacing(controller) only affects the yaw zero value not the X,Y,Z axis orientation.

BTW, like your work, thanks!

OCULUS Rift Touch 1.4.3

Hello,
I just tested yesterday, using latest Oculus and AutoHotKey SW releases. It looks like Oculus Touch controllers commands are not being intercepted, there is no activity using the testing script: "oculus_touch_test.ahk". Oculus SW and the "H" are properly launched once I double click on the .ahk file.
NOTE: I have also steam and steam VR installed.

Am I missing something?

Thanks,
HH

Steam link

Hi, is there any chance to use Auto oculus touch with Steam link?

Touch Controller Motion

Hello! Really nice API here! The only thing I notice missing is detecting when, if, and how the touch controllers move. Would there be a way to implement it? I tried looking at it, but I'm unfamiliar with the OculusSDK.

Not an issue, just wanted to get in touch

Hi,
I write remapping applications in AHK (My best known being UJR and UCR) and I have people requesting support for oculus touch controllers.
I currently have a user who is trying to get auto_oculus_touch working with UCR.
I have no intention of getting a Rift (Gonna get a Vive) so I was wondering if you would at all be interested in helping us out?
If we could get your library to send fake input (eg take input from a joystick or something and report it as oculus touch input) then I could maybe code in support for the touch (Or at least your wrapper around the touch) without actually needing to own one.
Please feel free to email me at [email protected]

vJoy axis not going all the way to 100%

Hello,

I used this mod to implement custom joysticks into Flight Simulator. Re-writing one of the scripts, I was able to effectively create a "slider" that goes from -1 to 1 to work as throttle.

However, I noticed that my throttle was only going to 95% (or 90% on the slider, since it's -100% to 100%).

Here's a screenshot showing the slider and its max state:
image

Even manually setting the vJoy to 1 or a value higher than 1 (SetvJoyAxis(HID_USAGE_SL0, 1.1)), it only goes to 90%.

I noticed that it also does this for all the other axis. Basically any axis is limited to 90%. I believe this is an issue with the vJoyInterface.dll, but I am not sure. Is there something else I am missing or need to check?

thumbstick press not registering

I'm using the vJoy script and it's working great for the most part, but I can't seem to register pressing in either thumbstick. Is this not mapped to a button?

Not working with Oculus 1.38.0.261476 (1.38.0.261476)

Hi, great project.
With Oculus 1.38.0.261476 (1.38.0.261476) the AutoHotKey scripts do not working.

oculus_touch_test.ahk does not receive any input

In the README you mention the auto_oculus_touch.dll (A library that wraps around the Oculus SDK).
Where is it?

Oculus

auto_oculus_touch.dll not included in latest download - no error message

Took me a while to figure out the problem. On closer inspection the file seems to be no longer in the project?

This should really be described in the readme. I currently have the dll file from the 0.1.5 version of this project. should I be getting this file from somewhere specific? the latest version?

should the script be able to find this file somewhere on my computer?

Thanks for your help, great project, I'm excited to finish my configuration and play with the reults

thumbstick as joystick

Hi I want to use oculus thumbstick as joystick in DCS (Digital Combat Sim), can I use auto_oculus_touch for that? Do I need vjoy? What would be the steps for that, sorry if this is the wrong place.

Thanks a lot!

Oculus remote, not all buttons working?

First, thanks for this great library.

I'm using it with the oculus remote and noticed that not all buttons seem to be working.
The four directional buttons work fine, but the following enums don't seem to work with the pressed state:

;ovrA := 0x00000001 ; Touch-A Remote-Select Xbox-A
;ovrB := 0x00000002 ; Touch-B Remote-Back Xbox-B
;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

for instance, this works:

if pressed & ovrRight
    Send, {WheelUp}

But this doesn't:

if pressed & ovrB
    Send, {WheelDown}

Am I using it wrong?

Doesn't work?

I have autohotkey, other scripts work for it. I open oculus and check my controllers are connected and they are, and when i run scripts they are in system tray but nothing happens, no inputs or anything. im not sure whats going wrong or what to fix?

auto_oculus_touch Windows 11 support?

Has anyone got this working on Windows 11?

I have traced the issue to invoking vJoy. The original developer of vJoy is not maintaining it but there is a fork to a vJoy that supports Windows 11 here: https://github.com/njz3/vJoy which installed and worked under Windows 11.

From the auto_oculus_touch.dll any call-out to the vJoyInterface.dll causes the auto_oculus_touch.dll to fail to load.

Any thoughts?

vJoy is required instead of being optional

I have been getting an error "The auto_oculus_touch.dll file is missing from the search path" even though the DLL was in the same folder.
I did some digging and found out that A_LastError had an error code 126 and one of the reasons for it is loading a .dll without required dependencies, so I looked at the events in Process Monitor and indeed the auto_oculus_touch.dll had been found but failed after trying to load vJoy DLL.
After installing vJoy and adding its DLL into the $Path the script started working.

Rajetic read this

@rajetic you need to fix your code I spent an hour learning C++ then SEVERAL hours debugging your code to figure out what was wrong and when I tell you the problem you do not respond. Could you implement the fix I discovered or add me as collaborator since I am an active developer. The problem in the code was the drivermatch function which is unnecessary and broken. I would also continue to develop AOT if I was a contributor.

Vibration support through vjoy

It looks like it should be possible to hook into vjoy's vibration support, via e.g. HID_USAGE_CONST and use a callback function in order to get the oculus touch controllers to vibrate. My limited googling pointed me at FfbRegisterGenCB but haven't dug that much deeper than that. I would love the ability to take advantage of rumble in games, and this seems doable (but I'm not 100% sure where to start with implementing it).

Oculous touch

Hi. Is there a code I could write to change the oculous touch controller to xbox one controller?

Vibration issue

The oculus_touch_test.ahk shows all the events from the Touch controllers exactly as it should but the Vibration test buttons don't seem to work and i'm not able to make the controllers vibrate with even the simplest script. There was a Oculus software update just couple of days ago. Could this have changed the way vibration is handled?

Does auto_oculus_touch still work with the latest Oculus software/drivers?

Your project seems amazing to me. I suffer from RSI like issues and want to use the Oculus Touch Controller as a one hand controller for my left hand to navigate around a scene in Unity and placing objects, instead of pressing the ctrl, shift and alt buttons which hurt my fingers.

I downloaded all files and installed autohotkey but when I open oculus_touch_test.ahk , I don't see any input being monitored. The headset is connected and activated and the controller is active (I can see it works when I put on the headset).

Anything I'm doing wrong or doesn't it work with latest version of Oculus software?

I'm using AutoHotkey version 1.1.30.03 and Oculus App Version 1.37.0.245188 (1.37.0.245188)

Vjoy does not work

Hello, im using this with the RIFT-S Touch Controllers and the test.IHK works fine (I press buttons or move axis and it shows input). Though your application does not work with VJOY. It is not sending any input to the VJOY at all.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.