Skip to content

Commit

Permalink
トラッカー互換モードの追加、常時互換モードの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
gpsnmeajp committed Feb 2, 2023
1 parent 1f33e1e commit 336155b
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup/vmtsetup_script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Virtual Motion Tracker"
#define MyAppVersion "0.14g"
#define MyAppVersion "0.15"
#define MyAppPublisher "gpsnmeajp"
#define MyAppURL "https://github.com/gpsnmeajp/VirtualMotionTracker"
#define MyAppExeName "vmt_manager.exe"
Expand Down
2 changes: 1 addition & 1 deletion vmt_driver/CommunicationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.

//通信系の処理の管理、OSC情報の送受信を行う
namespace VMTDriver {
const string Version{ "VMT_014g" };
const string Version{ "VMT_015" };

class OSCReceiver : public osc::OscPacketListener {
private:
Expand Down
13 changes: 13 additions & 0 deletions vmt_driver/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ namespace VMTDriver {
{
j["Priority"] = 10;
}
if (!j.contains("AlwaysCompatible"))
{
j["AlwaysCompatible"] = false;
}
return j;
}

Expand Down Expand Up @@ -209,6 +213,10 @@ namespace VMTDriver {
{
m_Priority = j["Priority"];
}
if (j.contains("AlwaysCompatible"))
{
m_AlwaysCompatible = j["AlwaysCompatible"];
}
SaveJson(j);
}
catch (...) {
Expand Down Expand Up @@ -359,4 +367,9 @@ namespace VMTDriver {
{
return m_Priority;
}
//常時互換モードを取得する
bool Config::GetAlwaysCompatible()
{
return m_AlwaysCompatible;
}
}
2 changes: 2 additions & 0 deletions vmt_driver/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace VMTDriver {
bool m_AddCompatibleControllerOnStartup{ false };
bool m_DiagLogOnStartup{ false };
int m_Priority{ 10 };
bool m_AlwaysCompatible{ false };

json LoadJson();
void SaveJson(json j);
Expand Down Expand Up @@ -74,5 +75,6 @@ namespace VMTDriver {
bool GetAddCompatibleControllerOnStartup();
bool GetDiagLogOnStartup();
int GetPriority();
bool GetAlwaysCompatible();
};
}
34 changes: 29 additions & 5 deletions vmt_driver/TrackedDeviceServerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,22 +505,34 @@ namespace VMTDriver {
m_CompatibleMode = false;
break;
case 5://Compatible(Knuckles) Controller Left
LogInfo("RegisterToVRSystem: %s", "ETrackedDeviceClass::TrackedDeviceClass_Controller (Left)");
LogInfo("RegisterToVRSystem: %s", "ETrackedDeviceClass::TrackedDeviceClass_Controller (Left) [Compatible]");
m_controllerRole = ControllerRole::Left;
m_deviceClass = ETrackedDeviceClass::TrackedDeviceClass_Controller;
m_CompatibleMode = true;
break;
case 6://Compatible(Knuckles) Controller Right
LogInfo("RegisterToVRSystem: %s", "ETrackedDeviceClass::TrackedDeviceClass_Controller (Right)");
LogInfo("RegisterToVRSystem: %s", "ETrackedDeviceClass::TrackedDeviceClass_Controller (Right) [Compatible]");
m_controllerRole = ControllerRole::Right;
m_deviceClass = ETrackedDeviceClass::TrackedDeviceClass_Controller;
m_CompatibleMode = true;
break;
case 7://Compatible Tracker
LogInfo("RegisterToVRSystem: %s", "ETrackedDeviceClass::TrackedDeviceClass_GenericTracker [Compatible]");
m_controllerRole = ControllerRole::None;
m_deviceClass = ETrackedDeviceClass::TrackedDeviceClass_GenericTracker;
m_CompatibleMode = true;
break;
default:
LogError("RegisterToVRSystem: %s", "Unknown Type");
m_deviceClass = ETrackedDeviceClass::TrackedDeviceClass_Invalid;
return; //中止
}

if (Config::GetInstance()->GetAlwaysCompatible()) {
LogError("AlwaysCompatible: %s", "true");
m_CompatibleMode = true;
}

m_registrationInProgress = true;
LogIfFalse(VRServerDriverHost()->TrackedDeviceAdded(m_serial.c_str(), m_deviceClass, this));
}
Expand Down Expand Up @@ -1001,9 +1013,12 @@ namespace VMTDriver {
RegisteredDeviceType_String += m_serial.c_str();
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_RegisteredDeviceType_String, RegisteredDeviceType_String.c_str()));

if (m_CompatibleMode) {
if (m_CompatibleMode && (m_deviceClass == ETrackedDeviceClass::TrackedDeviceClass_Controller)) {
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_InputProfilePath_String, "{vmt}/input/vmt_compatible_profile.json")); //Knuckles互換モード
}
else if (m_CompatibleMode && (m_deviceClass == ETrackedDeviceClass::TrackedDeviceClass_GenericTracker)) {
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_InputProfilePath_String, "{htc}/input/vive_tracker_profile.json")); //Tracker互換モード
}
else {
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_InputProfilePath_String, "{vmt}/input/vmt_profile.json")); //VMTモード
}
Expand Down Expand Up @@ -1088,7 +1103,7 @@ namespace VMTDriver {
LogIfEVRInputError(VRDriverInput()->CreateHapticComponent(m_propertyContainer, "/output/haptic", &HapticComponent));

//互換用のコンポーネントミラーリングを登録
if (m_CompatibleMode) {
if (m_CompatibleMode && (m_deviceClass == ETrackedDeviceClass::TrackedDeviceClass_Controller)) {
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/system/click")).c_str(), &ButtonComponent[0]));
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/system/touch")).c_str(), &ButtonTouchComponent[0]));

Expand Down Expand Up @@ -1121,7 +1136,16 @@ namespace VMTDriver {
LogIfEVRInputError(VRDriverInput()->CreateScalarComponent(m_propertyContainer, (std::string("/input/finger/middle/value")).c_str(), &TriggerComponent[4], EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedOneSided));
LogIfEVRInputError(VRDriverInput()->CreateScalarComponent(m_propertyContainer, (std::string("/input/finger/ring/value")).c_str(), &TriggerComponent[5], EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedOneSided));
LogIfEVRInputError(VRDriverInput()->CreateScalarComponent(m_propertyContainer, (std::string("/input/finger/pinky/value")).c_str(), &TriggerComponent[6], EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedOneSided));

}
//互換用のコンポーネントミラーリングを登録
if (m_CompatibleMode && (m_deviceClass == ETrackedDeviceClass::TrackedDeviceClass_GenericTracker)) {
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/power/click")).c_str(), &ButtonComponent[0]));
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/trigger/click")).c_str(), &ButtonComponent[1]));
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/grip/click")).c_str(), &ButtonComponent[2]));
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/application_menu/click")).c_str(), &ButtonComponent[3]));
LogIfEVRInputError(VRDriverInput()->CreateBooleanComponent(m_propertyContainer, (std::string("/input/thumb/click")).c_str(), &ButtonComponent[4]));
}
if (m_CompatibleMode) {
//互換アイコンにする
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_NamedIconPathDeviceSearching_String, "{vmt}/icons/Searching32x32_compatible.png"));
LogIfETrackedPropertyError(VRProperties()->SetStringProperty(m_propertyContainer, Prop_NamedIconPathDeviceSearchingAlert_String, "{vmt}/icons/SearchingAlert32x32_compatible.png"));
Expand Down
16 changes: 12 additions & 4 deletions vmt_manager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:vmt_manager"
Width="550"
Width="650"
Height="800"
mc:Ignorable="d"
Title="VMT Manager" Loaded="Window_Loaded" Closed="Window_Closed" ResizeMode="NoResize">
<DockPanel LastChildFill="True" Name="AllDockPanel">
<StatusBar DockPanel.Dock="Bottom" Name="StatusBar">
<StatusBarItem>
<DockPanel Width="550">
<DockPanel Width="650">
<TextBlock Padding="2,0,0,0" Name="StatusBarTextBlock" Text="Virtual Motion Tracker" FontWeight="Bold" DockPanel.Dock="Top" />
<TextBlock Padding="2,0,0,0" Name="StatusBarDashboardAlertTextBlock" Text="Steam VR Dashboard is opening. Button, Finger does not working.&#xA;SteamVR ダッシュボードが開いています。ボタン操作・指姿勢は無効です。" Background="Red" Foreground="White" FontWeight="Bold" DockPanel.Dock="Top" />
</DockPanel>
Expand Down Expand Up @@ -200,6 +200,7 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Optout Tracking Role" Grid.Row="0" Grid.Column="0"/>
<Button Content="ON" Click="EnableOptoutTrackingRoleButton" Grid.Row="0" Grid.Column="1" Margin="1"/>
Expand Down Expand Up @@ -228,6 +229,10 @@
<TextBlock Text="Diag Log On Startup" Grid.Row="6" Grid.Column="0"/>
<Button Content="ON" Click="EnableDiagLogOnStartupButton" Grid.Row="6" Grid.Column="1" Margin="1"/>
<Button Content="OFF" Click="DisableDiagLogOnStartupButton" Grid.Row="6" Grid.Column="2" Margin="1"/>

<TextBlock Text="Always Compatible" Grid.Row="7" Grid.Column="0"/>
<Button Content="ON" Click="EnableAlwaysCompatibleButton" Grid.Row="7" Grid.Column="1" Margin="1"/>
<Button Content="OFF" Click="DisableAlwaysCompatibleButton" Grid.Row="7" Grid.Column="2" Margin="1"/>
</Grid>
</GroupBox>
<GroupBox Header="Tracking Overrides" DockPanel.Dock="Top" Margin="0,10,0,0">
Expand Down Expand Up @@ -263,7 +268,7 @@ If you want to override button, axis, fingers by VMT, Please set "Target device"
<DockPanel>
<GroupBox Header="Device registration (Only once each devices in one VR Session.)" DockPanel.Dock="Top">
<StackPanel>
<UniformGrid Columns="7" Rows="1">
<UniformGrid Columns="8" Rows="1">
<Button Margin="1" Click="DisableButton">
<TextBlock Text="[0]&#xa;Disable" TextAlignment="Center"/>
</Button>
Expand All @@ -285,8 +290,11 @@ If you want to override button, axis, fingers by VMT, Please set "Target device"
<Button Margin="1" Click="RightHandCompatibleButton">
<TextBlock Text="[6] Right&#xa;Compatible" TextAlignment="Center"/>
</Button>
<Button Margin="1" Click="TrackerCompatibleButton">
<TextBlock Text="[7] Tracker&#xa;Compatible" TextAlignment="Center"/>
</Button>
</UniformGrid>
<UniformGrid Columns="7" Rows="1">
<UniformGrid Columns="8" Rows="1">
<TextBlock Text=""/>
<TextBlock Text=""/>
<TextBlock Text="VMT"/>
Expand Down
23 changes: 22 additions & 1 deletion vmt_manager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace vmt_manager
/// </summary>
public partial class MainWindow : Window
{
const string Version = "VMT_014g";
const string Version = "VMT_015";
private DispatcherTimer dispatcherTimer;
Random rnd;
string title = "";
Expand Down Expand Up @@ -1510,6 +1510,17 @@ private void RightHandCompatibleButton(object sender, RoutedEventArgs e)

}
}
private void TrackerCompatibleButton(object sender, RoutedEventArgs e)
{
var index = GetInputIndex();
if (index.ok)
{
osc.Send(new OscMessage("/VMT/Room/Unity",
index.i, 7, 0f,
0f, 0f, 0f,
0f, 0f, 0f, 1f));
}
}

private void LeftHandButton(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -1651,6 +1662,16 @@ private void DisableDiagLogOnStartupButton(object sender, RoutedEventArgs e)
osc.Send(new OscMessage("/VMT/Config", "DiagLogOnStartup", "false"));
System.Media.SystemSounds.Beep.Play();
}
private void EnableAlwaysCompatibleButton(object sender, RoutedEventArgs e)
{
osc.Send(new OscMessage("/VMT/Config", "AlwaysCompatible", "true"));
System.Media.SystemSounds.Beep.Play();
}
private void DisableAlwaysCompatibleButton(object sender, RoutedEventArgs e)
{
osc.Send(new OscMessage("/VMT/Config", "AlwaysCompatible", "false"));
System.Media.SystemSounds.Beep.Play();
}

private void DeviceReloadButton(object sender, RoutedEventArgs e)
{
Expand Down

0 comments on commit 336155b

Please sign in to comment.