@@ -54,7 +54,6 @@ TMain = class(TForm)
5454 procedure FormCreate (Sender: TObject);
5555 procedure Button1Click (Sender: TObject);
5656 procedure Button2Click (Sender: TObject);
57- procedure FormClose (Sender: TObject; var Action: TCloseAction);
5857 private
5958 { Private declarations }
6059 public
@@ -99,7 +98,7 @@ _Controller = record
9998
10099var
101100 Main: TMain;
102- DriverPath : string;
101+ LibPath : string;
103102 DllHandle: HMODULE;
104103 GetHMDData: function(out myHMD: THMD): DWORD; stdcall;
105104 GetControllersData: function(out myController, myController2: TController): DWORD; stdcall;
@@ -110,15 +109,16 @@ implementation
110109
111110{ $R *.dfm}
112111
113- procedure GetDriverPath ;
112+ procedure GetLibPath ;
114113var
115114 Reg: TRegistry;
116115begin
116+ LibPath:=' ' ;
117117 Reg:=TRegistry.Create;
118118 Reg.RootKey:=HKEY_CURRENT_USER;
119119 if Reg.OpenKey(' \Software\TrueOpenVR' , false) = false then Exit;
120- if FileExists( Reg.ReadString(' Drivers ' ) + Reg.ReadString( ' Driver ' )) = false then Exit ;
121- DriverPath:=Reg.ReadString( ' Drivers ' ) + Reg.ReadString( ' Driver ' ) ;
120+ LibPath:= Reg.ReadString(' Library ' ) ;
121+ if FileExists(LibPath) = false then LibPath:= ' ' ;
122122 Reg.CloseKey;
123123 Reg.Free;
124124end ;
@@ -214,6 +214,8 @@ procedure TMain.GetBtnClick(Sender: TObject);
214214
215215procedure TMain.CloseBtnClick (Sender: TObject);
216216begin
217+ if DllHandle <> 0 then
218+ FreeLibrary(DllHandle);
217219 Close;
218220end ;
219221
@@ -222,9 +224,9 @@ procedure TMain.FormCreate(Sender: TObject);
222224 Label32.Caption:=' TOVR - Open Source Virtual Reality' + #13 #10 + ' standard for all devices' ;
223225 Application.Title:=Caption;
224226
225- GetDriverPath ;
226- if FileExists(DriverPath) then begin
227- DllHandle:=LoadLibrary(PChar(DriverPath ));
227+ GetLibPath ;
228+ if LibPath <> ' ' then begin
229+ DllHandle:=LoadLibrary(PChar(LibPath ));
228230 @GetHMDData:=GetProcAddress(DllHandle, ' GetHMDData' );
229231 @GetControllersData:=GetProcAddress(DllHandle, ' GetControllersData' );
230232 @SetControllerData:=GetProcAddress(DllHandle, ' SetControllerData' );
@@ -240,6 +242,7 @@ procedure TMain.Button1Click(Sender: TObject);
240242 iResult: integer;
241243begin
242244 iResult:=SetCentering(IDHMD);
245+ if iResult = 1 then ShowMessage(' Centering success' );
243246end ;
244247
245248procedure TMain.Button2Click (Sender: TObject);
@@ -248,9 +251,4 @@ procedure TMain.Button2Click(Sender: TObject);
248251 SetControllerData(IDController2, 42517 );
249252end ;
250253
251- procedure TMain.FormClose (Sender: TObject; var Action: TCloseAction);
252- begin
253- FreeLibrary(DllHandle);
254- end ;
255-
256254end .
0 commit comments