-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.4.2
- Loading branch information
Showing
52 changed files
with
2,155 additions
and
2,053 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
BasedOnStyle: Google | ||
ColumnLimit: 170 | ||
ColumnLimit: 150 | ||
BinPackParameters: false | ||
BinPackArguments: false | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AllowShortFunctionsOnASingleLine: Empty | ||
NamespaceIndentation: All |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
#pragma once | ||
#include <openvr_driver.h> | ||
#include <memory> | ||
|
||
#include "DeviceConfiguration.h" | ||
#include "openvr_driver.h" | ||
|
||
enum class CalibrationMethod { | ||
Hardware, | ||
Ui, | ||
None, | ||
}; | ||
|
||
class Calibration { | ||
public: | ||
Calibration(); | ||
public: | ||
Calibration(); | ||
|
||
void StartCalibration(vr::DriverPose_t maintainPose, CalibrationMethod method); | ||
|
||
void StartCalibration(vr::DriverPose_t maintainPose); | ||
VRPoseConfiguration CompleteCalibration( | ||
vr::TrackedDevicePose_t controllerPose, VRPoseConfiguration poseConfiguration, bool isRightHand, CalibrationMethod method); | ||
|
||
VRPoseConfiguration_t CompleteCalibration(vr::TrackedDevicePose_t controllerPose, VRPoseConfiguration_t poseConfiguration, bool isRightHand); | ||
void CancelCalibration(CalibrationMethod method); | ||
|
||
void CancelCalibration(); | ||
bool IsCalibrating() const; | ||
|
||
bool isCalibrating(); | ||
|
||
vr::DriverPose_t GetMaintainPose(); | ||
vr::DriverPose_t GetMaintainPose() const; | ||
|
||
private: | ||
vr::DriverPose_t m_maintainPose; | ||
bool m_isCalibrating; | ||
private: | ||
vr::DriverPose_t maintainPose_; | ||
bool isCalibrating_; | ||
CalibrationMethod calibratingMethod_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,39 @@ | ||
#pragma once | ||
#include <Winsock2.h> | ||
#include <Ws2bth.h> | ||
|
||
#include <WinSock2.h> | ||
#include <bluetoothapis.h> | ||
#include <windows.h> | ||
|
||
#include <atomic> | ||
#include <chrono> | ||
#include <memory> | ||
#include <mutex> | ||
#include <sstream> | ||
#include <thread> | ||
#include <vector> | ||
#include <string> | ||
|
||
#include "CommunicationManager.h" | ||
#include "Communication/CommunicationManager.h" | ||
#include "DeviceConfiguration.h" | ||
#include "DriverLog.h" | ||
#include "Encode/EncodingManager.h" | ||
|
||
class BTSerialCommunicationManager : public ICommunicationManager { | ||
class BTSerialCommunicationManager : public CommunicationManager { | ||
public: | ||
BTSerialCommunicationManager(const VRBTSerialConfiguration_t& configuration, std::unique_ptr<IEncodingManager> encodingManager); | ||
BTSerialCommunicationManager( | ||
std::unique_ptr<EncodingManager> encodingManager, VRBTSerialConfiguration configuration, const VRDeviceConfiguration& deviceConfiguration); | ||
|
||
// 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(); | ||
bool IsConnected() override; | ||
|
||
void QueueSend(const VRFFBData_t& data); | ||
protected: | ||
bool Connect() override; | ||
bool DisconnectFromDevice() override; | ||
void LogError(const char* message) override; | ||
void LogMessage(const char* message) override; | ||
bool ReceiveNextPacket(std::string& buff) override; | ||
bool SendMessageToDevice() override; | ||
|
||
private: | ||
bool Connect(); | ||
void ListenerThread(const std::function<void(VRCommData_t)>& callback); | ||
bool ReceiveNextPacket(std::string& buff); | ||
bool GetPairedDeviceBtAddress(); | ||
bool ConnectToDevice(const BTH_ADDR& deviceBtAddress); | ||
bool GetPairedDeviceBtAddress(BTH_ADDR* deviceBtAddress); | ||
bool StartupWindowsSocket(); | ||
bool ConnectToDevice(); | ||
bool SendMessageToDevice(); | ||
void WaitAttemptConnection(); | ||
bool DisconnectFromDevice(); | ||
void LogError(const char* message); | ||
void LogMessage(const char* message); | ||
|
||
std::atomic<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; | ||
VRBTSerialConfiguration btSerialConfiguration_; | ||
|
||
std::mutex m_writeMutex; | ||
std::atomic<bool> isConnected_; | ||
|
||
std::string m_writeString = "\n"; | ||
std::atomic<SOCKET> btClientSocket_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
#pragma once | ||
|
||
#include <atomic> | ||
#include <functional> | ||
#include <memory> | ||
#include <mutex> | ||
#include <string> | ||
#include <thread> | ||
|
||
#include "DeviceConfiguration.h" | ||
#include "Encode/EncodingManager.h" | ||
|
||
class ICommunicationManager { | ||
class CommunicationManager { | ||
public: | ||
virtual void BeginListener(const std::function<void(VRCommData_t)>& callback) = 0; | ||
explicit CommunicationManager(const VRDeviceConfiguration& deviceConfiguration); | ||
CommunicationManager(std::unique_ptr<EncodingManager> encodingManager, const VRDeviceConfiguration& deviceConfiguration); | ||
|
||
virtual void BeginListener(const std::function<void(VRInputData)>& callback); | ||
virtual void Disconnect(); | ||
virtual void QueueSend(const VRFFBData& data); | ||
|
||
virtual bool IsConnected() = 0; | ||
virtual void Disconnect() = 0; | ||
|
||
virtual void QueueSend(const VRFFBData_t& data) = 0; | ||
protected: | ||
virtual void ListenerThread(const std::function<void(VRInputData)>& callback); | ||
virtual void WaitAttemptConnection(); | ||
|
||
virtual bool Connect() = 0; | ||
virtual bool DisconnectFromDevice() = 0; | ||
virtual void LogError(const char* message) = 0; | ||
virtual void LogMessage(const char* message) = 0; | ||
virtual bool ReceiveNextPacket(std::string& buff) = 0; | ||
virtual bool SendMessageToDevice() = 0; | ||
|
||
std::unique_ptr<EncodingManager> encodingManager_; | ||
VRDeviceConfiguration deviceConfiguration_; | ||
|
||
std::atomic<bool> threadActive_; | ||
std::thread thread_; | ||
|
||
private: | ||
std::unique_ptr<IEncodingManager> m_encodingManager; | ||
std::mutex writeMutex_; | ||
std::string writeString_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <atomic> | ||
#include <memory> | ||
|
||
#include "Communication/CommunicationManager.h" | ||
#include "DeviceConfiguration.h" | ||
#include "Util/NamedPipeListener.h" | ||
|
||
class NamedPipeCommunicationManager : public CommunicationManager { | ||
public: | ||
NamedPipeCommunicationManager(VRNamedPipeInputConfiguration configuration, const VRDeviceConfiguration& deviceConfiguration); | ||
bool IsConnected() override; | ||
void QueueSend(const VRFFBData& data) override{}; | ||
|
||
protected: | ||
bool Connect() override; | ||
bool DisconnectFromDevice() override; | ||
void LogError(const char* message) override; | ||
void LogMessage(const char* message) override; | ||
|
||
// Functions currently unimplemented | ||
bool SendMessageToDevice() override { | ||
return true; | ||
}; | ||
bool ReceiveNextPacket(std::string& buff) override { | ||
return true; | ||
}; | ||
|
||
void BeginListener(const std::function<void(VRInputData)>& callback) override; | ||
|
||
private: | ||
std::unique_ptr<NamedPipeListener<VRInputData>> namedPipeListener_; | ||
std::atomic<bool> isConnected_; | ||
|
||
std::function<void(VRInputData)> callback_; | ||
|
||
VRNamedPipeInputConfiguration configuration_; | ||
}; |
Oops, something went wrong.