32 #include <scolPlugin.h> 33 #include <scolMemoryHelper.hpp> 47 int SCOL_Openvr_QUIT_CB = 0;
50 int SCOL_Openvr_IPD_CB = 1;
73 int destroyOpenvrObj(mmachine m, SCOL_PTR_TYPE handsys,
int handscol)
76 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(handscol));
77 SAFE_DELETE(openvrObj);
79 MMsetPointer<sOpenvr*>(m, MTOP(handscol), 0);
82 MMechostr(MSKDEBUG,
"ObjOpenvr destroyed.\n");
102 MMechostr(0,
"_CRopenvrDevice\n");
107 int pUserIpd = MMpull(m);
108 int pCbkIpd = MMpull(m);
109 int pUserQuit = MMpull(m);
110 int pCbkQuit = MMpull(m);
113 int channel = MMget(m, 0);
118 MMechostr(MSKDEBUG,
"_CRopenvrDevice : Channel NIL\n");
123 if (!vr::VR_IsRuntimeInstalled())
125 MMechostr(MSKRUNTIME,
"_CRopenvrDevice : Steam VR not found, please install Steam VR first.\n");
130 if (!vr::VR_IsHmdPresent())
132 MMechostr(MSKRUNTIME,
"_CRopenvrDevice : No VR headset found on the system!\n");
137 std::string inputPath =
"scol_VR_input.json";
138 packdir mypack = (packdir)SCgetExtra(
"FirstPack");
140 std::vector<std::string> partitions;
144 pathStd = mypack->path;
145 for (
unsigned int i = 0; i < pathStd.length(); i++)
147 if (pathStd.substr(i, 1) ==
"\\")
148 pathStd.replace(i, 1,
"/");
150 partitions.push_back(pathStd);
151 mypack = mypack->next;
154 sOpenvr* openvrObj =
new sOpenvr((partitions[0] + inputPath).c_str());
155 if (openvrObj == NULL)
157 MMechostr(MSKDEBUG,
"_CRopenvrDevice : openvrObj failed\n");
162 if (!openvrObj->Connect())
164 MMechostr(MSKDEBUG,
"_CRopenvrDevice : device not found\n");
165 SAFE_DELETE(openvrObj);
171 if ((MMpushPointer(m, openvrObj) != 0))
173 SAFE_DELETE(openvrObj);
179 k = OBJcreate(m, OBJ_Openvr_SCOL, SCOL_PTR openvrObj, NIL, NULL);
181 if ((k = MMpush(m, pCbkQuit)))
return k;
182 if ((k = MMpush(m, pUserQuit)))
return k;
183 if ((k = OBJaddreflex(m, OBJ_Openvr_SCOL, SCOL_Openvr_QUIT_CB)))
return k;
185 if ((k = MMpush(m, pCbkIpd)))
return k;
186 if ((k = MMpush(m, pUserIpd)))
return k;
187 if ((k = OBJaddreflex(m, OBJ_Openvr_SCOL, SCOL_Openvr_IPD_CB)))
return k;
206 MMechostr(MSKDEBUG,
"_DSopenvrDevice\n");
209 int openvrTab = MMget(m, 0);
210 if (openvrTab == NIL)
216 OBJdelTM(m, OBJ_Openvr_SCOL, openvrTab);
217 MMset(m, 0, ITOM(0));
220 MMechostr(MSKDEBUG,
"ok\n");
235 MMechostr(MSKDEBUG,
"_GetOpenvrVisibility\n");
238 int openvrTab = MMget(m, 0);
239 if (openvrTab == NIL)
245 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
252 int visible = openvrObj->IsVisible() ? 1 : 0;
253 MMset(m, 0, ITOM(visible));
256 MMechostr(MSKDEBUG,
"ok\n");
271 MMechostr(MSKDEBUG,
"_GetOpenvrOrientation\n");
274 int openvrTab = MMget(m, 0);
275 if (openvrTab == NIL)
281 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
282 if (!openvrObj || !openvrObj->IsConnected())
289 if (openvrObj->GetHmdOrientation(quat))
291 int tuple = MMmalloc(m, 4, TYPETAB);
297 MMstore(m, tuple, 0, FTOM(quat.x));
298 MMstore(m, tuple, 1, FTOM(quat.y));
299 MMstore(m, tuple, 2, FTOM(quat.z));
300 MMstore(m, tuple, 3, FTOM(quat.w));
301 MMset(m, 0, PTOM(tuple));
309 MMechostr(MSKDEBUG,
"ok\n");
324 MMechostr(MSKDEBUG,
"_GetOpenvrPosition\n");
327 int openvrTab = MMget(m, 0);
328 if (openvrTab == NIL)
334 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
335 if (!openvrObj || !openvrObj->IsConnected())
342 if (openvrObj->GetHmdPosition(pos))
344 int tuple = MMmalloc(m, 3, TYPETAB);
350 MMstore(m, tuple, 0, FTOM(pos.x));
351 MMstore(m, tuple, 1, FTOM(pos.y));
352 MMstore(m, tuple, 2, FTOM(pos.z));
353 MMset(m, 0, PTOM(tuple));
361 MMechostr(MSKDEBUG,
"ok\n");
376 MMechostr(MSKDEBUG,
"_GetOpenvrAspectRatio\n");
379 int openvrTab = MMget(m, 0);
380 if (openvrTab == NIL)
386 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
387 if (!openvrObj || !openvrObj->IsConnected())
393 MMset(m, 0, FTOM(openvrObj->GetStereoConfigAspect()));
396 MMechostr(MSKDEBUG,
"ok\n");
411 MMechostr(MSKDEBUG,
"_GetOpenvrIPD\n");
414 int openvrTab = MMget(m, 0);
415 if (openvrTab == NIL)
421 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
428 MMset(m, 0, FTOM(openvrObj->GetStereoIPD()));
431 MMechostr(MSKDEBUG,
"ok\n");
446 MMechostr(MSKDEBUG,
"_GetOpenvrFovY\n");
449 int openvrTab = MMget(m, 0);
450 if (openvrTab == NIL)
456 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
463 MMset(m, 0, FTOM(openvrObj->GetStereoConfigFovY()));
466 MMechostr(MSKDEBUG,
"ok\n");
481 MMechostr(MSKDEBUG,
"_ResetOpenvrDevice\n");
484 int openvrTab = MMget(m, 0);
485 if (openvrTab == NIL)
491 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
498 openvrObj->ResetHmd();
500 MMset(m, 0, ITOM(0));
503 MMechostr(MSKDEBUG,
"ok\n");
518 MMechostr(MSKDEBUG,
"_UpdateOpenvr\n");
521 int openvrTab = MMget(m, 0);
522 if (openvrTab == NIL)
528 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
529 if (!openvrObj || !openvrObj->IsConnected())
534 bool ret = openvrObj->Update();
536 MMset(m, 0, ITOM((ret) ? 1 : 0));
553 MMechostr(MSKDEBUG,
"_UpdateOpenvrTextures\n");
556 int iType = MMpull(m);
557 int iRightTex = MMpull(m);
558 int iLeftTex = MMpull(m);
560 int openvrTab = MMget(m, 0);
561 if (openvrTab == NIL || iRightTex == NIL || iLeftTex == NIL)
567 vr::ETextureType texType = vr::TextureType_OpenGL;
568 if (MTOI(iType) == 1)
569 texType = vr::TextureType_DirectX;
571 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
572 if (!openvrObj || !openvrObj->IsConnected())
577 void* lptr = MMgetPointer<void*>(m, MMfetch(m, MTOP(iLeftTex), 0));
578 void* rptr = MMgetPointer<void*>(m, MMfetch(m, MTOP(iRightTex), 0));
585 openvrObj->UpdateTextures(lptr, rptr, texType);
587 MMset(m, 0, ITOM(1));
601 MMechostr(MSKDEBUG,
"_GetOpenvrDeviceName\n");
604 int openvrTab = MMget(m, 0);
605 if (openvrTab == NIL)
611 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
612 if (!openvrObj || !openvrObj->IsConnected())
619 Mpushstrbloc(m, openvrObj->GetHmdName().c_str());
635 MMechostr(MSKDEBUG,
"_GetOpenvrProjectionMatrix\n");
638 int ifclip = MMpull(m);
639 int inclip = MMpull(m);
640 int openvrTab = MMget(m, 0);
641 if (openvrTab == NIL)
647 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
648 if (!openvrObj || !openvrObj->IsConnected())
654 float nearclip = 0.01f;
656 nearclip = MTOF(inclip);
658 float farclip = 10000.0f;
660 farclip = MTOF(ifclip);
665 openvrObj->GetProjectionMatrix(vr::Eye_Left, nearclip, farclip, lmat);
666 openvrObj->GetProjectionMatrix(vr::Eye_Right, nearclip, farclip, rmat);
668 int tuple = MMmalloc(m, 2, TYPETAB);
669 int ltmat = MMmalloc(m, 4, TYPETAB);
670 int ltmat1 = MMmalloc(m, 4, TYPETAB);
671 int ltmat2 = MMmalloc(m, 4, TYPETAB);
672 int ltmat3 = MMmalloc(m, 4, TYPETAB);
673 int ltmat4 = MMmalloc(m, 4, TYPETAB);
675 int rtmat = MMmalloc(m, 4, TYPETAB);
676 int rtmat1 = MMmalloc(m, 4, TYPETAB);
677 int rtmat2 = MMmalloc(m, 4, TYPETAB);
678 int rtmat3 = MMmalloc(m, 4, TYPETAB);
679 int rtmat4 = MMmalloc(m, 4, TYPETAB);
681 if ((tuple == NIL) || (ltmat == NIL) || (ltmat1 == NIL) || (ltmat2 == NIL) || (ltmat3 == NIL) || (ltmat4 == NIL) || (rtmat == NIL) || (rtmat1 == NIL) || (rtmat2 == NIL) || (rtmat3 == NIL) || (rtmat4 == NIL))
687 MMstore(m, ltmat1, 0, FTOM(lmat[0][0]));
688 MMstore(m, ltmat1, 1, FTOM(lmat[0][1]));
689 MMstore(m, ltmat1, 2, FTOM(lmat[0][2]));
690 MMstore(m, ltmat1, 3, FTOM(lmat[0][3]));
692 MMstore(m, ltmat2, 0, FTOM(lmat[1][0]));
693 MMstore(m, ltmat2, 1, FTOM(lmat[1][1]));
694 MMstore(m, ltmat2, 2, FTOM(lmat[1][2]));
695 MMstore(m, ltmat2, 3, FTOM(lmat[1][3]));
697 MMstore(m, ltmat3, 0, FTOM(lmat[2][0]));
698 MMstore(m, ltmat3, 1, FTOM(lmat[2][1]));
699 MMstore(m, ltmat3, 2, FTOM(lmat[2][2]));
700 MMstore(m, ltmat3, 3, FTOM(lmat[2][3]));
702 MMstore(m, ltmat4, 0, FTOM(lmat[3][0]));
703 MMstore(m, ltmat4, 1, FTOM(lmat[3][1]));
704 MMstore(m, ltmat4, 2, FTOM(lmat[3][2]));
705 MMstore(m, ltmat4, 3, FTOM(lmat[3][3]));
707 MMstore(m, ltmat, 0, PTOM(ltmat1));
708 MMstore(m, ltmat, 1, PTOM(ltmat2));
709 MMstore(m, ltmat, 2, PTOM(ltmat3));
710 MMstore(m, ltmat, 3, PTOM(ltmat4));
712 MMstore(m, rtmat1, 0, FTOM(rmat[0][0]));
713 MMstore(m, rtmat1, 1, FTOM(rmat[0][1]));
714 MMstore(m, rtmat1, 2, FTOM(rmat[0][2]));
715 MMstore(m, rtmat1, 3, FTOM(rmat[0][3]));
717 MMstore(m, rtmat2, 0, FTOM(rmat[1][0]));
718 MMstore(m, rtmat2, 1, FTOM(rmat[1][1]));
719 MMstore(m, rtmat2, 2, FTOM(rmat[1][2]));
720 MMstore(m, rtmat2, 3, FTOM(rmat[1][3]));
722 MMstore(m, rtmat3, 0, FTOM(rmat[2][0]));
723 MMstore(m, rtmat3, 1, FTOM(rmat[2][1]));
724 MMstore(m, rtmat3, 2, FTOM(rmat[2][2]));
725 MMstore(m, rtmat3, 3, FTOM(rmat[2][3]));
727 MMstore(m, rtmat4, 0, FTOM(rmat[3][0]));
728 MMstore(m, rtmat4, 1, FTOM(rmat[3][1]));
729 MMstore(m, rtmat4, 2, FTOM(rmat[3][2]));
730 MMstore(m, rtmat4, 3, FTOM(rmat[3][3]));
732 MMstore(m, rtmat, 0, PTOM(rtmat1));
733 MMstore(m, rtmat, 1, PTOM(rtmat2));
734 MMstore(m, rtmat, 2, PTOM(rtmat3));
735 MMstore(m, rtmat, 3, PTOM(rtmat4));
737 MMstore(m, tuple, 0, PTOM(ltmat));
738 MMstore(m, tuple, 1, PTOM(rtmat));
739 MMset(m, 0, PTOM(tuple));
742 MMechostr(MSKDEBUG,
"ok\n");
757 MMechostr(MSKDEBUG,
"_GetOpenvrTextureSize\n");
760 int openvrTab = MMget(m, 0);
761 if (openvrTab == NIL)
767 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
768 if (!openvrObj || !openvrObj->IsConnected())
776 openvrObj->GetStereoTextureSize(w, h);
778 int tuple = MMmalloc(m, 2, TYPETAB);
785 MMstore(m, tuple, 0, ITOM(w));
786 MMstore(m, tuple, 1, ITOM(h));
787 MMset(m, 0, PTOM(tuple));
790 MMechostr(MSKDEBUG,
"ok\n");
806 MMechostr(MSKDEBUG,
"_GetOpenvrControllerVisibility\n");
809 int iSide = MMpull(m);
810 int openvrTab = MMget(m, 0);
811 if (openvrTab == NIL)
817 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
818 if (!openvrObj || !openvrObj->IsConnected())
825 if (iSide != NIL && MTOI(iSide) > 0)
835 int visible = (controller->IsVisible()) ? 1 : 0;
836 MMset(m, 0, ITOM(visible));
839 MMechostr(MSKDEBUG,
"ok\n");
855 MMechostr(MSKDEBUG,
"_GetOpenvrControllerPosition\n");
858 int iSide = MMpull(m);
859 int openvrTab = MMget(m, 0);
860 if (openvrTab == NIL)
866 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
867 if (!openvrObj || !openvrObj->IsConnected())
874 if (iSide != NIL && MTOI(iSide) > 0)
884 Vector3 pos = controller->GetPosition();
885 int tuple = MMmalloc(m, 3, TYPETAB);
891 MMstore(m, tuple, 0, FTOM(pos.x));
892 MMstore(m, tuple, 1, FTOM(pos.y));
893 MMstore(m, tuple, 2, FTOM(pos.z));
894 MMset(m, 0, PTOM(tuple));
897 MMechostr(MSKDEBUG,
"ok\n");
913 MMechostr(MSKDEBUG,
"_GetOpenvrControllerOrientation\n");
916 int iSide = MMpull(m);
917 int openvrTab = MMget(m, 0);
918 if (openvrTab == NIL)
924 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
925 if (!openvrObj || !openvrObj->IsConnected())
932 if (iSide != NIL && MTOI(iSide) > 0)
942 Quaternion quat = controller->GetOrientation();
943 int tuple = MMmalloc(m, 4, TYPETAB);
949 MMstore(m, tuple, 0, FTOM(quat.x));
950 MMstore(m, tuple, 1, FTOM(quat.y));
951 MMstore(m, tuple, 2, FTOM(quat.z));
952 MMstore(m, tuple, 3, FTOM(quat.w));
953 MMset(m, 0, PTOM(tuple));
956 MMechostr(MSKDEBUG,
"ok\n");
972 MMechostr(MSKDEBUG,
"_GetOpenvrControllerVelocity\n");
975 int iSide = MMpull(m);
976 int openvrTab = MMget(m, 0);
977 if (openvrTab == NIL)
983 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
984 if (!openvrObj || !openvrObj->IsConnected())
991 if (iSide != NIL && MTOI(iSide) > 0)
1001 Vector3 vel = controller->GetVelocity();
1002 int tuple = MMmalloc(m, 3, TYPETAB);
1008 MMstore(m, tuple, 0, FTOM(vel.x));
1009 MMstore(m, tuple, 1, FTOM(vel.y));
1010 MMstore(m, tuple, 2, FTOM(vel.z));
1011 MMset(m, 0, PTOM(tuple));
1014 MMechostr(MSKDEBUG,
"ok\n");
1030 MMechostr(MSKDEBUG,
"_GetOpenvrControllerAngularVelocity\n");
1033 int iSide = MMpull(m);
1034 int openvrTab = MMget(m, 0);
1035 if (openvrTab == NIL)
1041 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1042 if (!openvrObj || !openvrObj->IsConnected())
1048 unsigned int id = 0;
1049 if (iSide != NIL && MTOI(iSide) > 0)
1059 Vector3 avel = controller->GetVelocity();
1060 int tuple = MMmalloc(m, 3, TYPETAB);
1066 MMstore(m, tuple, 0, FTOM(avel.x));
1067 MMstore(m, tuple, 1, FTOM(avel.y));
1068 MMstore(m, tuple, 2, FTOM(avel.z));
1069 MMset(m, 0, PTOM(tuple));
1072 MMechostr(MSKDEBUG,
"ok\n");
1089 MMechostr(MSKDEBUG,
"_GetOpenvrControllerButtons\n");
1092 int iSide = MMpull(m);
1093 int openvrTab = MMget(m, 0);
1094 if (openvrTab == NIL)
1100 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1101 if (!openvrObj || !openvrObj->IsConnected())
1107 unsigned int id = 0;
1108 if (iSide != NIL && MTOI(iSide) > 0)
1118 std::vector<bool> buttons = controller->GetButtonsState();
1123 for (
unsigned int i = 0; i < buttons.size(); i++)
1125 MMpush(m, ITOM(buttons[i]));
1129 for (
unsigned int i = 0; i < buttons.size(); i++)
1136 MMechostr(MSKDEBUG,
"ok\n");
1153 MMechostr(MSKDEBUG,
"_GetOpenvrControllerAxis\n");
1156 int iSide = MMpull(m);
1157 int openvrTab = MMget(m, 0);
1158 if (openvrTab == NIL)
1164 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1165 if (!openvrObj || !openvrObj->IsConnected())
1171 unsigned int id = 0;
1172 if (iSide != NIL && MTOI(iSide) > 0)
1182 Vector3 pos = controller->GetAxisValues();
1183 int tuple = MMmalloc(m, 3, TYPETAB);
1189 MMstore(m, tuple, 0, FTOM(pos.x));
1190 MMstore(m, tuple, 1, FTOM(pos.y));
1191 MMstore(m, tuple, 2, FTOM(pos.z));
1192 MMset(m, 0, PTOM(tuple));
1195 MMechostr(MSKDEBUG,
"ok\n");
1212 MMechostr(MSKDEBUG,
"_SetOpenvrControllerRumble\n");
1215 int iRumble = MMpull(m);
1216 int iSide = MMpull(m);
1217 int openvrTab = MMget(m, 0);
1218 if (openvrTab == NIL)
1224 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1225 if (!openvrObj || !openvrObj->IsConnected())
1231 unsigned int id = 0;
1232 if (iSide != NIL && MTOI(iSide) > 0)
1242 float rumble = 0.0f;
1244 rumble = MTOF(iRumble);
1246 controller->Rumble(rumble);
1247 MMset(m, 0, ITOM(1));
1250 MMechostr(MSKDEBUG,
"ok\n");
1265 MMechostr(MSKDEBUG,
"_IsOpenvrCameraAvailable\n");
1268 int openvrTab = MMget(m, 0);
1269 if (openvrTab == NIL)
1275 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1276 if (!openvrObj || !openvrObj->IsConnected())
1282 int state = (openvrObj->IsCameraEnable()) ? 1 : 0;
1283 MMset(m, 0, ITOM(state));
1286 MMechostr(MSKDEBUG,
"ok\n");
1301 MMechostr(MSKDEBUG,
"_OpenOpenvrCamera\n");
1304 int openvrTab = MMget(m, 0);
1305 if (openvrTab == NIL)
1311 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1312 if (!openvrObj || !openvrObj->IsConnected())
1318 int state = (openvrObj->StartCamera()) ? 1 : 0;
1319 MMset(m, 0, ITOM(state));
1322 MMechostr(MSKDEBUG,
"ok\n");
1337 MMechostr(MSKDEBUG,
"_CloseOpenvrCamera\n");
1340 int openvrTab = MMget(m, 0);
1341 if (openvrTab == NIL)
1347 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1348 if (!openvrObj || !openvrObj->IsConnected())
1354 openvrObj->StopCamera();
1355 MMset(m, 0, ITOM(1));
1358 MMechostr(MSKDEBUG,
"ok\n");
1373 MMechostr(MSKDEBUG,
"_GetOpenvrCameraSize\n");
1376 int openvrTab = MMget(m, 0);
1377 if (openvrTab == NIL)
1383 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1384 if (!openvrObj || !openvrObj->IsConnected() || !openvrObj->IsCameraEnable())
1393 openvrObj->GetCameraSize(w, h);
1395 int tuple = MMmalloc(m, 2, TYPETAB);
1401 MMstore(m, tuple, 0, ITOM(w));
1402 MMstore(m, tuple, 1, ITOM(h));
1403 MMset(m, 0, PTOM(tuple));
1406 MMechostr(MSKDEBUG,
"ok\n");
1423 MMechostr(MSKDEBUG,
"_GetOpenvrCameraFrame\n");
1426 int bitmap = MMpull(m);
1427 int openvrTab = MMget(m, 0);
1428 if ((openvrTab == NIL) || (bitmap == NIL))
1434 sOpenvr* openvrObj = MMgetPointer<sOpenvr*>(m, MTOP(openvrTab));
1435 if (!openvrObj || !openvrObj->IsConnected() || !openvrObj->IsCameraEnable())
1441 PtrObjVoid OB = (PtrObjVoid)MMstart(m, MTOP(bitmap));
1442 PtrObjBitmap B = (PtrObjBitmap)MMstart(m, MTOP(OB->Buffer));
1443 if (openvrObj->GetCameraFrame(B))
1444 MMset(m, 0, bitmap);
1449 MMechostr(MSKDEBUG,
"ok\n");
1455 int getOpenvrIpdCb(mmachine m, SCOL_PTR_TYPE
id, SCOL_PTR_TYPE param)
1464 if (OBJbeginreflex(m, OBJ_Openvr_SCOL, SCOL_PTR openvrObj, SCOL_Openvr_IPD_CB))
1467 MMpush(m, FTOM(openvrObj->GetStereoIPD()));
1468 k = OBJcallreflex(m, 1);
1472 int getOpenvrQuitCb(mmachine m, SCOL_PTR_TYPE
id, SCOL_PTR_TYPE param)
1481 if (OBJbeginreflex(m, OBJ_Openvr_SCOL, SCOL_PTR openvrObj, SCOL_Openvr_QUIT_CB))
1484 k = OBJcallreflex(m, 0);
1491 char* mOpenvrname[] =
1494 "OPENVR_CONTROLLER_LEFT",
1495 "OPENVR_CONTROLLER_RIGHT",
1499 "_GetOpenvrVisibility",
1500 "_GetOpenvrOrientation",
1501 "_GetOpenvrPosition",
1502 "_GetOpenvrAspectRatio",
1505 "_GetOpenvrProjectionMatrix",
1506 "_GetOpenvrTextureSize",
1507 "_ResetOpenvrDevice",
1509 "_UpdateOpenvrTextures",
1510 "_GetOpenvrDeviceName",
1511 "_GetOpenvrControllerVisibility",
1512 "_GetOpenvrControllerPosition",
1513 "_GetOpenvrControllerOrientation",
1514 "_GetOpenvrControllerVelocity",
1515 "_GetOpenvrControllerAngularVelocity",
1516 "_GetOpenvrControllerButtons",
1517 "_GetOpenvrControllerAxis",
1518 "_SetOpenvrControllerRumble",
1519 "_IsOpenvrCameraAvailable",
1520 "_OpenOpenvrCamera",
1521 "_CloseOpenvrCamera",
1522 "_GetOpenvrCameraSize",
1523 "_GetOpenvrCameraFrame" 1529 #define NOpenvrPKG (sizeof(mOpenvrname)/sizeof(char*)) 1534 int(*mOpenvrfun[NOpenvrPKG])(mmachine m) =
1537 SCOL_TYPTYPE(VrControllerSide::Left),
1538 SCOL_TYPTYPE(VrControllerSide::Right),
1572 int mOpenvrnarg[NOpenvrPKG] =
1611 char* mOpenvrtype[NOpenvrPKG] =
1617 "fun [Chn fun [ObjOpenvr u0] u1 u0 fun [ObjOpenvr u2 F] u3 u2] ObjOpenvr",
1618 "fun [ObjOpenvr] I",
1619 "fun [ObjOpenvr] I",
1620 "fun [ObjOpenvr] [F F F F]",
1621 "fun [ObjOpenvr] [F F F]",
1622 "fun [ObjOpenvr] F",
1623 "fun [ObjOpenvr] F",
1624 "fun [ObjOpenvr] F",
1625 "fun [ObjOpenvr F F] [[[F F F F] [F F F F] [F F F F] [F F F F]] [[F F F F] [F F F F] [F F F F] [F F F F]]]",
1626 "fun [ObjOpenvr] [I I]",
1627 "fun [ObjOpenvr] I",
1628 "fun [ObjOpenvr] I",
1629 "fun [ObjOpenvr ObjPtr ObjPtr I] I",
1630 "fun [ObjOpenvr] S",
1631 "fun [ObjOpenvr I] I",
1632 "fun [ObjOpenvr I] [F F F]",
1633 "fun [ObjOpenvr I] [F F F F]",
1634 "fun [ObjOpenvr I] [F F F]",
1635 "fun [ObjOpenvr I] [F F F]",
1636 "fun [ObjOpenvr I] [I r1]",
1637 "fun [ObjOpenvr I] [F F F]",
1638 "fun [ObjOpenvr I F] I",
1639 "fun [ObjOpenvr] I",
1640 "fun [ObjOpenvr] I",
1641 "fun [ObjOpenvr] I",
1642 "fun [ObjOpenvr] [I I]",
1643 "fun [ObjOpenvr ObjBitmap] ObjBitmap" 1654 int LoadOpenvr(mmachine m)
1658 MMechostr(MSKDEBUG,
"\n");
1659 MMechostr(MSKDEBUG,
" > Loading Openvr Support\n");
1662 OBJ_Openvr_SCOL = OBJregister(2 , 0, destroyOpenvrObj,
"OBJ_Openvr_SCOL");
1663 k = PKhardpak(m,
"mOpenvr.pkg-1.0", NOpenvrPKG, mOpenvrname, mOpenvrfun, mOpenvrnarg, mOpenvrtype);
1665 Openvr_QUIT_CB = OBJgetUserEvent();
1666 OBJdefEvent(Openvr_QUIT_CB, getOpenvrQuitCb);
1668 Openvr_IPD_CB = OBJgetUserEvent();
1669 OBJdefEvent(Openvr_IPD_CB, getOpenvrIpdCb);
1671 MMechostr(MSKDEBUG,
" > Successfully Loaded\n\n");
1677 MMechostr(MSKDEBUG,
"\n");
1678 MMechostr(MSKDEBUG,
" > Unloading Openvr Support\n");
1680 MMechostr(MSKDEBUG,
" > Successfully unloaded\n\n");
1691 extern "C" SCOL_EXPORT
int ScolLoadPlugin(mmachine m, cbmachine w)
1695 return LoadOpenvr(m);
1702 extern "C" SCOL_EXPORT
int ScolUnloadPlugin()
1704 return CloseOpenvr();
1711 extern "C" SCOL_EXPORT
int ScolOpenvrLoadPlugin(mmachine m, cbmachine w)
1715 return LoadOpenvr(m);
1722 extern "C" SCOL_EXPORT
int ScolOpenvrUnloadPlugin()
1724 return CloseOpenvr();
1726 #endif //SCOL_STATIC int _GetOpenvrControllerVisibility(mmachine m)
_GetOpenvrControllerVisibility : Get the Openvr controller visibility state
int _ResetOpenvrDevice(mmachine m)
_ResetOpenvrDevice : Reset Openvr sensor
int _GetOpenvrControllerOrientation(mmachine m)
_GetOpenvrControllerOrientation : Get the Openvr controller orientation
int _GetOpenvrTextureSize(mmachine m)
_GetOpenvrTextureSize : Get the Openvr texture size for RTT
int _UpdateOpenvr(mmachine m)
_UpdateOpenvr : start Openvr update you should call this on each render frame
int _CRopenvrDevice(mmachine m)
_CRopenvrDevice : This function create a Openvr object
int _GetOpenvrOrientation(mmachine m)
_GetOpenvrOrientation : Get the Openvr sensor orientation
int _GetOpenvrControllerPosition(mmachine m)
_GetOpenvrControllerPosition : Get the Openvr controller position
int _IsOpenvrCameraAvailable(mmachine m)
_IsOpenvrCameraAvailable : Get the Openvr camera availability
int _GetOpenvrVisibility(mmachine m)
_GetOpenvrVisibility : Get the Openvr HMD visibility state
int _GetOpenvrControllerButtons(mmachine m)
_GetOpenvrControllerButtons : Get the Openvr controller buttons state button order in list is applica...
int _GetOpenvrFovY(mmachine m)
_GetOpenvrFovY : Get the Openvr eye spacing
int _GetOpenvrCameraSize(mmachine m)
_GetOpenvrCameraSize : Get the Openvr camera frame size, the camera must be openned first ...
int _CloseOpenvrCamera(mmachine m)
_CloseOpenvrCamera : Close the Openvr camera
int _GetOpenvrProjectionMatrix(mmachine m)
_GetOpenvrProjectionMatrix : Get the Openvr camera projection matrix
int _GetOpenvrIPD(mmachine m)
_GetOpenvrIPD : Get the Openvr eye spacing
int _DSopenvrDevice(mmachine m)
_DSopenvrDevice : Destroy Openvr object
int _GetOpenvrControllerAxis(mmachine m)
_GetOpenvrControllerAxis : Get the Openvr controller axis values Axis order is touch pad X...
int _GetOpenvrPosition(mmachine m)
_GetOpenvrPosition : Get the Openvr position from the IR camera
int _GetOpenvrDeviceName(mmachine m)
_GetOpenvrDeviceName : Get the openvr device type
int _GetOpenvrAspectRatio(mmachine m)
_GetOpenvrAspectRatio : Get the Openvr camera aspect ratio
int _GetOpenvrControllerAngularVelocity(mmachine m)
_GetOpenvrControllerAngularVelocity : Get the Openvr controller velocity
int _OpenOpenvrCamera(mmachine m)
_OpenOpenvrCamera : Open the Openvr camera to get size and frames later
int _GetOpenvrCameraFrame(mmachine m)
_GetOpenvrCameraFrame : Get the Openvr camera frame into an existing bitmap the bitmap must have the ...
int _UpdateOpenvrTextures(mmachine m)
_UpdateOpenvrTextures : Update the HMD textures pointer
int _GetOpenvrControllerVelocity(mmachine m)
_GetOpenvrControllerVelocity : Get the Openvr controller velocity
int _SetOpenvrControllerRumble(mmachine m)
_SetOpenvrControllerRumble : Set the Openvr controller rumble value