Skip to content

Commit

Permalink
Merge pull request #108 from LucidVR/develop
Browse files Browse the repository at this point in the history
Release v0.4

Additions:
* Force Feedback Haptics
* Automatic Pose Calibration
* Alphabetic Encoding Manager
* Menu Button

Changes and Fixes:
* Controller discovery done through overlay
  - More reliable Vive wand discovery
* Settings will now not reset between updates
* Fix issues with bluetooth not working on some machines due to missing library
* Fix bug with pose settings caused by unit conversions
* Fix bug with playspace calibrator caused by lighthouse tracking name
  • Loading branch information
lucas-vrtech committed Aug 7, 2021
2 parents 47ec20b + 8de56c0 commit a572644
Show file tree
Hide file tree
Showing 42 changed files with 2,330 additions and 1,485 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BasedOnStyle: Google
ColumnLimit: 170
69 changes: 0 additions & 69 deletions .editorconfig

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Build/
*.vcxproj.*

CMakeCache.txt
cmake_install.cmake
cmake_install.cmake
clion_build/
26 changes: 16 additions & 10 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ Binaries are (or will) be provided in the Releases in this Repository, but if yo

This should generate Visual Studio project files in the `build/` folder, which you can then compile.

# Building with Visual Studio IDE
* Open the Visual Studio project (.sln file) in the `build/` folder
* You should already have the ability to build the driver by pressing `Ctrl + Shift + B`
* The artifacts of the build will be outputted to `build/Debug/`, or `build/Release/` depending on build configuration

# Building with Visual Studio Build Tools
* run a cmake build in the `build/` folder
* `cmake --build . --config Release`
* The artifacts of the build will be outputted to `build/Debug/`, or `build/Release/` depending on build configuration

# Building with Visual Studio IDE
* Open the Visual Studio project (.sln file) in the `build/` folder
* You should already have the ability to build the driver by pressing `Ctrl + Shift + B`
* The artifacts of the build will be outputted to `build/Debug/`, or `build/Release/` depending on build configuration

# Adding driver to Steam
**Note:** For a more streamlined debugging environment, refer to [Debugging with Visual Studio](https://github.com/LucidVR/opengloves-driver/blob/develop/BUILDING.md#debugging-with-visual-studio).
This step is for people who may not necessarily want to setup a debugging environment, or are testing release builds.
* Copy the `openglove` folder into the steamvr drivers folder
* Usually located `C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers`
* Running SteamVR you should see the driver activate two new controllers
Expand Down Expand Up @@ -73,16 +75,20 @@ If you want to make changes to the code and would like to use a debugger/not hav
* On the first row (with the process name `<All other processes>`, make sure that the `Action` is set to `Do not debug`.
* Add a new row (double click on the empty `Process name` underneath `<All other processes>`.
* Add `vrserver.exe` as the process name
* Ensure that `Action` is set to `Attach Debugger`.
* Ensure that `Action` is set to `Attach Debugger`.

## Launch SteamVR when building through Visual Studio
It's usually quite useful to build then automatically launch SteamVR for debugging purposes.
## Launch SteamVR/Overlay when building through Visual Studio
It's usually quite useful to build then automatically launch SteamVR/Overlay for debugging purposes.
The project includes both a SteamVR Driver & Overlay (found in `overlay/`). Running the overlay exe automatically launches SteamVR.
The overlay is used for utilising methods that are not found in the OpenVR Driver API, such as discovering controllers. If you do not need this functionality, you can simply launch SteamVR.
To launch SteamVR for debugging:
* Click on the arrow next to `Local Windows Debugger`
* Select `ALL_BUILD Debug Properties`
* Navigate to the `Debugger` Property (under Configuration Properties)
* Set `Command` to the location of `vrstartup.exe`
* This is usually located `C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrstartup.exe`
* Set `Command` to the location of `vrstartup.exe` (to start just SteamVR) or the Overlay exe (to start the Ovlerlay and SteamVR).
* SteamVR's entry point (`vrstartup.exe`) is usually located `C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrstartup.exe`
* OpenGlove's Overlay is usually found in the build folder, `overlay\Debug\openglove_overlay.exe`
* Provide the full or relative path to the executable, such as `E:\opengloves-driver\build\overlay\Debug\openglove_overlay.exe`, or `$(solutionDir)overlay\Debug\openglove_overlay.exe`

![Debug Properties](https://cdn.discordapp.com/attachments/790676300552994826/840985376679002172/unknown.png)
![Debugging Configuration Properties](https://cdn.discordapp.com/attachments/790676300552994826/840985404202549318/unknown.png)
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ endif()

find_library(OPENVR_LIB openvr_api HINTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/openvr/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}/" NO_DEFAULT_PATH )

add_subdirectory("overlay")

set(DRIVER_NAME "openglove")
set(OPENGLOVE_PROJECT "driver_${DRIVER_NAME}")

Expand All @@ -36,12 +38,13 @@ add_library("${OPENGLOVE_PROJECT}" SHARED "${HEADERS}" "${SOURCES}")
target_include_directories("${OPENGLOVE_PROJECT}" PUBLIC "${OPENVR_INCLUDE_DIR}")

target_include_directories("${OPENGLOVE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/")
target_link_libraries("${OPENGLOVE_PROJECT}" PUBLIC "${OPENVR_LIB}")
target_link_libraries("${OPENGLOVE_PROJECT}" PUBLIC "${OPENVR_LIB}" setupapi wsock32 ws2_32 bthprops)

source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include" PREFIX "Header Files" FILES ${HEADERS})
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src" PREFIX "Source Files" FILES ${SOURCES})
set_property(TARGET "${OPENGLOVE_PROJECT}" PROPERTY CXX_STANDARD 17)


# Copy driver assets to output folder
add_custom_command(
TARGET ${OPENGLOVE_PROJECT}
Expand All @@ -58,4 +61,12 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${OPENGLOVE_PROJECT}>
$<TARGET_FILE_DIR:${OPENGLOVE_PROJECT}>/${DRIVER_NAME}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}/$<TARGET_FILE_NAME:${OPENGLOVE_PROJECT}>
)

add_custom_command(
TARGET ${OPENGLOVE_PROJECT}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
$<TARGET_FILE_DIR:openglove_overlay>
$<TARGET_FILE_DIR:${OPENGLOVE_PROJECT}>/${DRIVER_NAME}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}
)
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# OpenGlove Driver
# OpenGloves Driver

OpenGlove is an OpenVR driver for DIY Virtual Reality Gloves. Using OpenVR's driver interface we are able to provide support for many SteamVR/OpenVR games.
OpenGloves is an OpenVR driver for DIY Virtual Reality Gloves. Using OpenVR's driver interface we are able to provide support for many SteamVR/OpenVR games.

## Installation and Usage

**Download the latest on GitHub:**
* https://github.com/LucidVR/opengloves-driver/releases

**Release on Steam (Not yet available):**
* https://store.steampowered.com/app/1574050/OpenGloves
* The driver will be available on the Steam store soon. Feel free to wishlist.
### Download on Steam:
[![Steam Release](https://cdn.discordapp.com/attachments/790676300552994826/845412304219537439/openglovessteam.png)](https://store.steampowered.com/app/1574050/OpenGloves)
* We strongly recommend downloading the driver from Steam, to recieve automatic updates and UI settings.

*Or download the latest on GitHub:*
* https://github.com/LucidVR/opengloves-driver/releases

**Follow the wiki guide for configuring the driver**
* https://github.com/LucidVR/opengloves-driver/wiki/Configuring-the-Driver
* The driver will not work correctly unless you configure it properly.

**Problems?**
* Check [Troubleshooting](https://github.com/LucidVR/opengloves-driver/wiki/Troubleshooting)
* Didn't help? Contact us on the [Discord Server](https://discord.com/invite/Y6XTvnHDUC)
* Didn't help? Contact us on the [Community Discord Server](https://discord.gg/lucidvr)
## Building
If you want to use the driver as-is, refer to [Installation and Usage](#Installation-and-Usage).
If you are planning on modifying source files, refer to [BUILDING.md](https://github.com/LucidVR/opengloves-driver/blob/develop/BUILDING.md).
Expand All @@ -34,16 +35,18 @@ If you are planning on modifying source files, refer to [BUILDING.md](https://gi

### Current features included in the driver
* Finger flexion tracking
* Force feedback haptics
* Positioning from controllers + trackers
* Automatic Calibration
* Button/Joystick inputs
* A/B/Menu buttons, Joystick X/Y/Click
* Communication Protocols:
* Serial USB
* Serial over Bluetooth

### Planned features
* BLE Communication
* Finger splay tracking
* Force feedback haptics
* Vibration haptics


Expand All @@ -56,4 +59,4 @@ Pull requests are very welcome. For major changes, please open an issue first to
* Lucas VRTech (`LucidVR#0001`)

## Discord
https://discord.gg/RjV9T8jN2G
https://discord.gg/lucidvr
23 changes: 23 additions & 0 deletions include/Calibration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include <openvr_driver.h>
#include <memory>
#include "DeviceConfiguration.h"

class Calibration {
public:
Calibration();

void StartCalibration(vr::DriverPose_t maintainPose);

VRPoseConfiguration_t FinishCalibration(vr::TrackedDevicePose_t controllerPose, VRPoseConfiguration_t poseConfiguration, bool isRightHand);

void CancelCalibration();

bool isCalibrating();

vr::DriverPose_t GetMaintainPose();

private:
vr::DriverPose_t m_maintainPose;
bool m_isCalibrating = false;
};
94 changes: 47 additions & 47 deletions include/Communication/BTSerialCommunicationManager.h
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
#pragma once
#include <Winsock2.h>

#include "CommunicationManager.h"
#include "DeviceConfiguration.h"
#include <memory>
#include <thread>
#include <atomic>
#include <chrono>
#include <vector>
#include <memory>
#include <sstream>
#include <thread>
#include <vector>
#include <mutex>

#include "CommunicationManager.h"
#include "DeviceConfiguration.h"
#include "DriverLog.h"
#include <stdlib.h>
#include <stdio.h>
#include <Winsock2.h>

#include <windows.h>
#include <bluetoothapis.h>
#include <Ws2bth.h>
#include <BluetoothAPIs.h>

#ifdef _WIN32
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Bthprops.lib")
#endif

#define ARDUINO_WAIT_TIME 1000

class BTSerialCommunicationManager : public ICommunicationManager {
public:
BTSerialCommunicationManager(const VRBTSerialConfiguration_t& configuration, std::unique_ptr<IEncodingManager> encodingManager);
//connect to the device using serial
void Connect();
//start a thread that listens for updates from the device and calls the callback with data
void BeginListener(const std::function<void(VRCommData_t)>& callback);
//returns if connected or not
bool IsConnected();
//close the serial port
void Disconnect();
private:
void ListenerThread(const std::function<void(VRCommData_t)>& callback);
bool ReceiveNextPacket(std::string &buff);
bool PurgeBuffer();
bool getPairedEsp32BtAddress();
bool startupWindowsSocket();
bool connectToEsp32();
bool sendMessageToEsp32();

bool m_isConnected;
std::atomic<bool> m_threadActive;
std::thread m_serialThread;

std::unique_ptr<IEncodingManager> m_encodingManager;

VRBTSerialConfiguration_t m_btSerialConfiguration;

BTH_ADDR m_esp32BtAddress;
SOCKADDR_BTH m_btSocketAddress;
SOCKET m_btClientSocket;
WCHAR* m_wcDeviceName;
//std::unique_ptr<WCHAR*> m_wcDeviceName;

public:
BTSerialCommunicationManager(const VRBTSerialConfiguration_t& configuration, std::unique_ptr<IEncodingManager> encodingManager);
// connect to the device using serial
void Connect();
// start a thread that listens for updates from the device and calls the callback with data
void BeginListener(const std::function<void(VRCommData_t)>& callback);
// returns if connected or not
bool IsConnected();
// close the serial port
void Disconnect();

void QueueSend(const VRFFBData_t& data);

private:
void ListenerThread(const std::function<void(VRCommData_t)>& callback);
bool ReceiveNextPacket(std::string& buff);
bool getPairedDeviceBtAddress();
bool startupWindowsSocket();
bool connectToDevice();
bool sendMessageToDevice();
bool m_isConnected;
std::atomic<bool> m_threadActive;
std::thread m_serialThread;

std::unique_ptr<IEncodingManager> m_encodingManager;

VRBTSerialConfiguration_t m_btSerialConfiguration;

BTH_ADDR m_deviceBtAddress;
SOCKADDR_BTH m_btSocketAddress;
SOCKET m_btClientSocket;
WCHAR* m_wcDeviceName;

std::mutex m_writeMutex;

std::string m_writeString = "\n";
};
18 changes: 11 additions & 7 deletions include/Communication/CommunicationManager.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#pragma once
#include <functional>
#include <memory>

#include "Encode/EncodingManager.h"

class ICommunicationManager {
public:
virtual void Connect() = 0;
virtual void BeginListener(const std::function<void(VRCommData_t)>& callback) = 0;
virtual bool IsConnected() = 0;
virtual void Disconnect() = 0;
private:
std::unique_ptr<IEncodingManager> m_encodingManager;
public:
virtual void Connect() = 0;
virtual void BeginListener(const std::function<void(VRCommData_t)>& callback) = 0;
virtual bool IsConnected() = 0;
virtual void Disconnect() = 0;

virtual void QueueSend(const VRFFBData_t& data) = 0;

private:
std::unique_ptr<IEncodingManager> m_encodingManager;
};
Loading

0 comments on commit a572644

Please sign in to comment.