33#include <scolMemoryHelper.hpp>
67int destroyOpenXrObj(mmachine m, SCOL_PTR_TYPE handsys,
int handscol)
70 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(handscol));
71 openxrObj->Disconnect();
73 MMsetPointer<sOpenXr*>(m, MTOP(handscol), 0);
76 MMechostr(MSKDEBUG,
"ObjOpenXr destroyed.\n");
94 MMechostr(0,
"_CRopenXrDevice\n");
100 int iratio = MMpull(m);
101 int itype = MMpull(m);
102 int channel = MMget(m, 0);
107 MMechostr(MSKRUNTIME,
"_CRopenXrDevice : Channel NIL\n");
114 fratio = MTOF(iratio);
116 int renderer = (itype == NIL) ? XR_OPENGL_RENDERER : MTOI(itype);
117 if ((renderer > XR_MAX_RENDERER) || (renderer == XR_NONE_RENDER_SYSTEM))
118 renderer = XR_OPENGL_RENDERER;
120 if ((renderer != XR_OPENGL_RENDERER) && (renderer != XR_DIRECTX11_RENDERER))
122 MMechostr(MSKRUNTIME,
"_CRopenXrDevice : renderer not supported\n");
127 sOpenXr* openxrObj = sOpenXr::CreateInstance((RenderSystem)renderer, fratio);
129 if (!openxrObj->IsConnected() && !openxrObj->Connect())
131 MMechostr(MSKRUNTIME,
"_CRopenXrDevice : device not found\n");
137 if ((MMpushPointer(m, openxrObj) != 0))
139 sOpenXr::GetInstance()->Disconnect();
145 k = OBJcreate(m, OBJ_OPENXR_SCOL, SCOL_PTR openxrObj, NIL, NULL);
164 MMechostr(MSKDEBUG,
"_DSopenXrDevice\n");
167 int openxrTab = MMget(m, 0);
168 if (openxrTab == NIL)
174 OBJdelTM(m, OBJ_OPENXR_SCOL, openxrTab);
175 MMset(m, 0, ITOM(0));
178 MMechostr(MSKDEBUG,
"ok\n");
193 MMechostr(MSKDEBUG,
"_GetOpenXrVisibility\n");
196 int openxrTab = MMget(m, 0);
197 if (openxrTab == NIL)
203 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
210 int visible = openxrObj->IsVisible() ? 1 : 0;
211 MMset(m, 0, ITOM(visible));
214 MMechostr(MSKDEBUG,
"ok\n");
229 MMechostr(MSKDEBUG,
"_GetOpenXrOrientation\n");
232 int openxrTab = MMget(m, 0);
233 if (openxrTab == NIL)
239 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
240 if (!openxrObj || !openxrObj->IsConnected())
247 if (openxrObj->GetHmdOrientation(quat))
249 int tuple = MMmalloc(m, 4, TYPETAB);
255 MMstore(m, tuple, 0, FTOM(quat.x));
256 MMstore(m, tuple, 1, FTOM(quat.y));
257 MMstore(m, tuple, 2, FTOM(quat.z));
258 MMstore(m, tuple, 3, FTOM(quat.w));
259 MMset(m, 0, PTOM(tuple));
267 MMechostr(MSKDEBUG,
"ok\n");
282 MMechostr(MSKDEBUG,
"_GetOpenXrPosition\n");
285 int openxrTab = MMget(m, 0);
286 if (openxrTab == NIL)
292 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
293 if (!openxrObj || !openxrObj->IsConnected())
300 if (openxrObj->GetHmdPosition(pos))
302 int tuple = MMmalloc(m, 3, TYPETAB);
308 MMstore(m, tuple, 0, FTOM(pos.x));
309 MMstore(m, tuple, 1, FTOM(pos.y));
310 MMstore(m, tuple, 2, FTOM(pos.z));
311 MMset(m, 0, PTOM(tuple));
319 MMechostr(MSKDEBUG,
"ok\n");
334 MMechostr(MSKDEBUG,
"_GetOpenXrFovY\n");
337 int openxrTab = MMget(m, 0);
338 if (openxrTab == NIL)
344 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
351 MMset(m, 0, FTOM(openxrObj->GetStereoConfigFovY()));
354 MMechostr(MSKDEBUG,
"ok\n");
369 MMechostr(MSKDEBUG,
"_GetOpenXrIPD\n");
372 int openxrTab = MMget(m, 0);
373 if (openxrTab == NIL)
379 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
387 MMset(m, 0, FTOM(openxrObj->GetStereoConfigIPD()));
390 MMechostr(MSKDEBUG,
"ok\n");
405 MMechostr(MSKDEBUG,
"_UpdateOpenXr\n");
408 int openxrTab = MMget(m, 0);
409 if (openxrTab == NIL)
415 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
416 if (!openxrObj || !openxrObj->IsConnected())
421 bool ret = openxrObj->Update();
423 MMset(m, 0, ITOM((ret) ? 1 : 0));
440 MMechostr(MSKDEBUG,
"_UpdateOpenXrTextures\n");
443 int iRightTex = MMpull(m);
444 int iLeftTex = MMpull(m);
446 int openxrTab = MMget(m, 0);
447 if (openxrTab == NIL || iRightTex == NIL || iLeftTex == NIL)
453 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
454 if (!openxrObj || !openxrObj->IsConnected())
459 SCOL_PTR_TYPE lptr = MMgetPointer<SCOL_PTR_TYPE>(m, MMfetch(m, MTOP(iLeftTex), 0));
460 SCOL_PTR_TYPE rptr = MMgetPointer<SCOL_PTR_TYPE>(m, MMfetch(m, MTOP(iRightTex), 0));
462 openxrObj->UpdateTextures(lptr, rptr);
464 MMset(m, 0, ITOM(1));
467 MMechostr(MSKDEBUG,
"ok\n");
482 MMechostr(MSKDEBUG,
"_GetOpenXrDeviceName\n");
485 int openxrTab = MMget(m, 0);
486 if (openxrTab == NIL)
492 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
493 if (!openxrObj || !openxrObj->IsConnected())
500 Mpushstrbloc(m, openxrObj->GetHmdName().c_str());
503 MMechostr(MSKDEBUG,
"ok\n");
520 MMechostr(MSKDEBUG,
"_GetOpenXrProjectionMatrix\n");
523 int ifclip = MMpull(m);
524 int inclip = MMpull(m);
526 int openxrTab = MMget(m, 0);
527 if (openxrTab == NIL)
533 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
534 if (!openxrObj || !openxrObj->IsConnected())
540 float nearclip = 0.01f;
542 nearclip = MTOF(inclip);
544 float farclip = 10000.0f;
546 farclip = MTOF(ifclip);
551 if (!openxrObj->GetProjectionMatrix(VrEye::LeftEye, nearclip, farclip, lmat) ||
552 !openxrObj->GetProjectionMatrix(VrEye::RightEye, nearclip, farclip, rmat))
558 int tuple = MMmalloc(m, 2, TYPETAB);
560 int ltmat = MMmalloc(m, 4, TYPETAB);
561 int ltmat1 = MMmalloc(m, 4, TYPETAB);
562 int ltmat2 = MMmalloc(m, 4, TYPETAB);
563 int ltmat3 = MMmalloc(m, 4, TYPETAB);
564 int ltmat4 = MMmalloc(m, 4, TYPETAB);
566 int rtmat = MMmalloc(m, 4, TYPETAB);
567 int rtmat1 = MMmalloc(m, 4, TYPETAB);
568 int rtmat2 = MMmalloc(m, 4, TYPETAB);
569 int rtmat3 = MMmalloc(m, 4, TYPETAB);
570 int rtmat4 = MMmalloc(m, 4, TYPETAB);
572 if ((tuple == NIL) || (ltmat == NIL) || (ltmat1 == NIL) || (ltmat2 == NIL) || (ltmat3 == NIL) || (ltmat4 == NIL) || (rtmat == NIL) || (rtmat1 == NIL) || (rtmat2 == NIL) || (rtmat3 == NIL) || (rtmat4 == NIL))
578 MMstore(m, ltmat1, 0, FTOM(lmat[0][0]));
579 MMstore(m, ltmat1, 1, FTOM(lmat[0][1]));
580 MMstore(m, ltmat1, 2, FTOM(lmat[0][2]));
581 MMstore(m, ltmat1, 3, FTOM(lmat[0][3]));
583 MMstore(m, ltmat2, 0, FTOM(lmat[1][0]));
584 MMstore(m, ltmat2, 1, FTOM(lmat[1][1]));
585 MMstore(m, ltmat2, 2, FTOM(lmat[1][2]));
586 MMstore(m, ltmat2, 3, FTOM(lmat[1][3]));
588 MMstore(m, ltmat3, 0, FTOM(lmat[2][0]));
589 MMstore(m, ltmat3, 1, FTOM(lmat[2][1]));
590 MMstore(m, ltmat3, 2, FTOM(lmat[2][2]));
591 MMstore(m, ltmat3, 3, FTOM(lmat[2][3]));
593 MMstore(m, ltmat4, 0, FTOM(lmat[3][0]));
594 MMstore(m, ltmat4, 1, FTOM(lmat[3][1]));
595 MMstore(m, ltmat4, 2, FTOM(lmat[3][2]));
596 MMstore(m, ltmat4, 3, FTOM(lmat[3][3]));
598 MMstore(m, ltmat, 0, PTOM(ltmat1));
599 MMstore(m, ltmat, 1, PTOM(ltmat2));
600 MMstore(m, ltmat, 2, PTOM(ltmat3));
601 MMstore(m, ltmat, 3, PTOM(ltmat4));
603 MMstore(m, rtmat1, 0, FTOM(rmat[0][0]));
604 MMstore(m, rtmat1, 1, FTOM(rmat[0][1]));
605 MMstore(m, rtmat1, 2, FTOM(rmat[0][2]));
606 MMstore(m, rtmat1, 3, FTOM(rmat[0][3]));
608 MMstore(m, rtmat2, 0, FTOM(rmat[1][0]));
609 MMstore(m, rtmat2, 1, FTOM(rmat[1][1]));
610 MMstore(m, rtmat2, 2, FTOM(rmat[1][2]));
611 MMstore(m, rtmat2, 3, FTOM(rmat[1][3]));
613 MMstore(m, rtmat3, 0, FTOM(rmat[2][0]));
614 MMstore(m, rtmat3, 1, FTOM(rmat[2][1]));
615 MMstore(m, rtmat3, 2, FTOM(rmat[2][2]));
616 MMstore(m, rtmat3, 3, FTOM(rmat[2][3]));
618 MMstore(m, rtmat4, 0, FTOM(rmat[3][0]));
619 MMstore(m, rtmat4, 1, FTOM(rmat[3][1]));
620 MMstore(m, rtmat4, 2, FTOM(rmat[3][2]));
621 MMstore(m, rtmat4, 3, FTOM(rmat[3][3]));
623 MMstore(m, rtmat, 0, PTOM(rtmat1));
624 MMstore(m, rtmat, 1, PTOM(rtmat2));
625 MMstore(m, rtmat, 2, PTOM(rtmat3));
626 MMstore(m, rtmat, 3, PTOM(rtmat4));
628 MMstore(m, tuple, 0, PTOM(ltmat));
629 MMstore(m, tuple, 1, PTOM(rtmat));
630 MMset(m, 0, PTOM(tuple));
633 MMechostr(MSKDEBUG,
"ok\n");
648 MMechostr(MSKDEBUG,
"_GetOpenXrTextureSize\n");
651 int openxrTab = MMget(m, 0);
652 if (openxrTab == NIL)
658 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
659 if (!openxrObj || !openxrObj->IsConnected())
667 openxrObj->GetStereoTextureSize(w, h);
669 int tuple = MMmalloc(m, 2, TYPETAB);
676 MMstore(m, tuple, 0, ITOM(w));
677 MMstore(m, tuple, 1, ITOM(h));
678 MMset(m, 0, PTOM(tuple));
681 MMechostr(MSKDEBUG,
"ok\n");
697 MMechostr(MSKDEBUG,
"_GetOpenXrControllerVisibility\n");
700 int iSide = MMpull(m);
702 int openxrTab = MMget(m, 0);
703 if (openxrTab == NIL)
709 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
710 if (!openxrObj || !openxrObj->IsConnected())
717 if (iSide != NIL && MTOI(iSide) > 0)
720 int visible = (openxrObj->GetControllerVisibility(
id)) ? 1 : 0;
721 MMset(m, 0, ITOM(visible));
724 MMechostr(MSKDEBUG,
"ok\n");
740 MMechostr(MSKDEBUG,
"_GetOpenXrControllerPosition\n");
743 int iSide = MMpull(m);
745 int openxrTab = MMget(m, 0);
746 if (openxrTab == NIL)
752 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
753 if (!openxrObj || !openxrObj->IsConnected())
760 if (iSide != NIL && MTOI(iSide) > 0)
763 Vector3 pos = openxrObj->GetControllerPosition(
id);
764 int tuple = MMmalloc(m, 3, TYPETAB);
770 MMstore(m, tuple, 0, FTOM(pos.x));
771 MMstore(m, tuple, 1, FTOM(pos.y));
772 MMstore(m, tuple, 2, FTOM(pos.z));
773 MMset(m, 0, PTOM(tuple));
776 MMechostr(MSKDEBUG,
"ok\n");
792 MMechostr(MSKDEBUG,
"_GetOpenXrControllerOrientation\n");
795 int iSide = MMpull(m);
797 int openxrTab = MMget(m, 0);
798 if (openxrTab == NIL)
804 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
805 if (!openxrObj || !openxrObj->IsConnected())
812 if (iSide != NIL && MTOI(iSide) > 0)
815 Quaternion quat = openxrObj->GetControllerOrientation(
id);
816 int tuple = MMmalloc(m, 4, TYPETAB);
822 MMstore(m, tuple, 0, FTOM(quat.x));
823 MMstore(m, tuple, 1, FTOM(quat.y));
824 MMstore(m, tuple, 2, FTOM(quat.z));
825 MMstore(m, tuple, 3, FTOM(quat.w));
826 MMset(m, 0, PTOM(tuple));
829 MMechostr(MSKDEBUG,
"ok\n");
845 MMechostr(MSKDEBUG,
"_GetOpenXrControllerVelocity\n");
848 int iSide = MMpull(m);
850 int openxrTab = MMget(m, 0);
851 if (openxrTab == NIL)
857 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
858 if (!openxrObj || !openxrObj->IsConnected())
865 if (iSide != NIL && MTOI(iSide) > 0)
868 Vector3 vel = openxrObj->GetControllerVelocity(
id);
869 int tuple = MMmalloc(m, 3, TYPETAB);
875 MMstore(m, tuple, 0, FTOM(vel.x));
876 MMstore(m, tuple, 1, FTOM(vel.y));
877 MMstore(m, tuple, 2, FTOM(vel.z));
878 MMset(m, 0, PTOM(tuple));
881 MMechostr(MSKDEBUG,
"ok\n");
897 MMechostr(MSKDEBUG,
"_GetOpenXrControllerAngularVelocity\n");
900 int iSide = MMpull(m);
902 int openxrTab = MMget(m, 0);
903 if (openxrTab == NIL)
909 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
910 if (!openxrObj || !openxrObj->IsConnected())
917 if (iSide != NIL && MTOI(iSide) > 0)
920 Vector3 avel = openxrObj->GetControllerAngularVelocity(
id);
921 int tuple = MMmalloc(m, 3, TYPETAB);
927 MMstore(m, tuple, 0, FTOM(avel.x));
928 MMstore(m, tuple, 1, FTOM(avel.y));
929 MMstore(m, tuple, 2, FTOM(avel.z));
930 MMset(m, 0, PTOM(tuple));
933 MMechostr(MSKDEBUG,
"ok\n");
950 MMechostr(MSKDEBUG,
"_GetOpenXrControllerButtons\n");
953 int iSide = MMpull(m);
955 int openxrTab = MMget(m, 0);
956 if (openxrTab == NIL)
962 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
963 if (!openxrObj || !openxrObj->IsConnected())
970 if (iSide != NIL && MTOI(iSide) > 0)
973 std::vector<bool> buttons = openxrObj->GetControllerButtonsState(
id);
978 for (
unsigned int i = 0; i < buttons.size(); i++)
980 MMpush(m, ITOM(buttons[i]));
984 for (
unsigned int i = 0; i < buttons.size(); i++)
991 MMechostr(MSKDEBUG,
"ok\n");
1008 MMechostr(MSKDEBUG,
"_GetOpenXrControllerButtons\n");
1011 int iSide = MMpull(m);
1013 int openxrTab = MMget(m, 0);
1014 if (openxrTab == NIL)
1020 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1021 if (!openxrObj || !openxrObj->IsConnected())
1027 unsigned int id = 0;
1028 if (iSide != NIL && MTOI(iSide) > 0)
1031 std::vector<bool> touches = openxrObj->GetControllerTouchesState(
id);
1036 for (
unsigned int i = 0; i < touches.size(); i++)
1038 MMpush(m, ITOM(touches[i]));
1042 for (
unsigned int i = 0; i < touches.size(); i++)
1049 MMechostr(MSKDEBUG,
"ok\n");
1066 MMechostr(MSKDEBUG,
"_GetOpenXrControllerAxis\n");
1069 int iSide = MMpull(m);
1071 int openxrTab = MMget(m, 0);
1072 if (openxrTab == NIL)
1078 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1079 if (!openxrObj || !openxrObj->IsConnected())
1085 unsigned int id = 0;
1086 if (iSide != NIL && MTOI(iSide) > 0)
1090 std::vector<float> axisvalue = openxrObj->GetControllerAnalogState(
id);
1091 if (axisvalue.size() < 4)
1097 int tuple = MMmalloc(m, 4, TYPETAB);
1103 MMstore(m, tuple, 0, FTOM(axisvalue[0]));
1104 MMstore(m, tuple, 1, FTOM(axisvalue[1]));
1105 MMstore(m, tuple, 2, FTOM(axisvalue[2]));
1106 MMstore(m, tuple, 3, FTOM(axisvalue[3]));
1107 MMset(m, 0, PTOM(tuple));
1110 MMechostr(MSKDEBUG,
"ok\n");
1126 MMechostr(MSKDEBUG,
"_GetOpenXrControllerType\n");
1129 int iSide = MMpull(m);
1131 int openxrTab = MMget(m, 0);
1132 if (openxrTab == NIL)
1138 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1139 if (!openxrObj || !openxrObj->IsConnected())
1145 unsigned int id = 0;
1146 if (iSide != NIL && MTOI(iSide) > 0)
1149 MMset(m, 0, ITOM(openxrObj->GetControllerType(
id)));
1152 MMechostr(MSKDEBUG,
"ok\n");
1168 MMechostr(MSKDEBUG,
"_GetOpenXrControllerBonesRotation\n");
1171 int iSide = MMpull(m);
1173 int openxrTab = MMget(m, 0);
1174 if (openxrTab == NIL)
1180 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1181 if (!openxrObj || !openxrObj->IsConnected())
1187 unsigned int id = 0;
1188 if (iSide != NIL && MTOI(iSide) > 0)
1192 std::array<Position, MAX_HAND_JOINTS> bones = openxrObj->GetControllerBones(
id, valid);
1205 for (
unsigned int i = 0; i < MAX_HAND_JOINTS; i++)
1207 tuple = MMmalloc(m, 4, TYPETAB);
1213 quat = bones[i].rotation;
1214 MMstore(m, tuple, 0, FTOM(quat.x));
1215 MMstore(m, tuple, 1, FTOM(quat.y));
1216 MMstore(m, tuple, 2, FTOM(quat.z));
1217 MMstore(m, tuple, 3, FTOM(quat.w));
1218 MMpush(m, PTOM(tuple));
1227 for (
unsigned int i = 0; i < bones.size(); i++)
1234 MMechostr(MSKDEBUG,
"ok\n");
1251 MMechostr(MSKDEBUG,
"_SetOpenXrControllerRumble\n");
1254 int iRumble = MMpull(m);
1255 int iSide = MMpull(m);
1257 int openxrTab = MMget(m, 0);
1258 if (openxrTab == NIL)
1264 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1265 if (!openxrObj || !openxrObj->IsConnected())
1271 unsigned int id = 0;
1272 if (iSide != NIL && MTOI(iSide) > 0)
1275 float rumble = 0.0f;
1277 rumble = MTOF(iRumble);
1279 openxrObj->SetControllerVibration(
id, rumble);
1280 MMset(m, 0, ITOM(1));
1283 MMechostr(MSKDEBUG,
"ok\n");
1298 MMechostr(MSKDEBUG,
"_SetOpenXrAppName\n");
1301 int iName = MMget(m, 0);
1303 std::string name =
"Scol OpenXR plugin";
1305 name = MMstartstr(m, MTOP(iName));
1307 sOpenXr::GetInstance()->SetAppName(name);
1309 MMset(m, 0, ITOM(0));
1312 MMechostr(MSKDEBUG,
"ok\n");
1327 MMechostr(MSKDEBUG,
"_SetOpenXrExtensions\n");
1330 int iExtension = MMget(m, 0);
1333 if (iExtension != NIL)
1334 extension = MTOI(iExtension);
1336 sOpenXr::GetInstance()->SetExtensions(extension);
1338 MMset(m, 0, ITOM(0));
1341 MMechostr(MSKDEBUG,
"ok\n");
1355 MMechostr(MSKDEBUG,
"_GetOpenXrExtensions\n");
1358 MMpush(m, ITOM(sOpenXr::GetInstance()->GetExtensions()));
1361 MMechostr(MSKDEBUG,
"ok\n");
1377 MMechostr(MSKDEBUG,
"_SetOpenXrControllerRumble\n");
1380 int iState = MMpull(m);
1381 int openxrTab = MMget(m, 0);
1382 if (openxrTab == NIL)
1388 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1389 if (!openxrObj || !openxrObj->IsConnected())
1397 state = (MTOI(iState) <= 0) ?
false :
true;
1399 bool support = openxrObj->SetPassthroughState(state);
1400 MMset(m, 0, ITOM(support ? 1 : 0));
1403 MMechostr(MSKDEBUG,
"ok\n");
1418 MMechostr(MSKDEBUG,
"_SetOpenXrControllerRumble\n");
1421 int openxrTab = MMget(m, 0);
1422 if (openxrTab == NIL)
1428 sOpenXr* openxrObj = MMgetPointer<sOpenXr*>(m, MTOP(openxrTab));
1429 if (!openxrObj || !openxrObj->IsConnected())
1435 bool support = openxrObj->IsPassthroughSupported();
1436 MMset(m, 0, ITOM(support ? 1 : 0));
1439 MMechostr(MSKDEBUG,
"ok\n");
1444NativeDefinition mOpenXrEngine[] =
1446 {
"ObjOpenXr", TYPTYPE, NULL, NULL },
1447 {
"OPENXR_CONTROLLER_LEFT", TYPVAR,
"I", SCOL_TYPTYPE(VrController::Left) },
1448 {
"OPENXR_CONTROLLER_RIGHT", TYPVAR,
"I", SCOL_TYPTYPE(VrController::Right) },
1450 {
"OPENXR_NO_EXTENSION", TYPVAR,
"I", SCOL_TYPTYPE(ExtensionType::EXTENSION_NONE) },
1451 {
"OPENXR_HAND_TRACKING_EXTENSION", TYPVAR,
"I", SCOL_TYPTYPE(ExtensionType::EXTENSION_HAND_TRACKING) },
1452 {
"OPENXR_PASSTHROUGH_EXTENSION", TYPVAR,
"I", SCOL_TYPTYPE(ExtensionType::EXTENSION_PASSTHROUGH) },
1454 {
"OPENXR_HAND_JOINT_PALM", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_PALM_EXT) },
1455 {
"OPENXR_HAND_JOINT_WRIST", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_WRIST_EXT) },
1456 {
"OPENXR_HAND_JOINT_THUMB_METACARPAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_THUMB_METACARPAL_EXT) },
1457 {
"OPENXR_HAND_JOINT_THUMB_PROXIMAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_THUMB_PROXIMAL_EXT) },
1458 {
"OPENXR_HAND_JOINT_THUMB_DISTAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_THUMB_DISTAL_EXT) },
1459 {
"OPENXR_HAND_JOINT_THUMB_TIP", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_THUMB_TIP_EXT) },
1460 {
"OPENXR_HAND_JOINT_INDEX_METACARPAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_INDEX_METACARPAL_EXT) },
1461 {
"OPENXR_HAND_JOINT_INDEX_PROXIMAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_INDEX_PROXIMAL_EXT) },
1462 {
"OPENXR_HAND_JOINT_INDEX_INTERMEDIATE", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_INDEX_INTERMEDIATE_EXT) },
1463 {
"OPENXR_HAND_JOINT_INDEX_DISTAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_INDEX_DISTAL_EXT) },
1464 {
"OPENXR_HAND_JOINT_INDEX_TIP", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_INDEX_TIP_EXT) },
1465 {
"OPENXR_HAND_JOINT_MIDDLE_METACARPAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_MIDDLE_METACARPAL_EXT) },
1466 {
"OPENXR_HAND_JOINT_MIDDLE_PROXIMAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_MIDDLE_PROXIMAL_EXT) },
1467 {
"OPENXR_HAND_JOINT_MIDDLE_INTERMEDIATE", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_MIDDLE_INTERMEDIATE_EXT) },
1468 {
"OPENXR_HAND_JOINT_MIDDLE_DISTAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_MIDDLE_DISTAL_EXT) },
1469 {
"OPENXR_HAND_JOINT_MIDDLE_TIP", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_MIDDLE_TIP_EXT) },
1470 {
"OPENXR_HAND_JOINT_RING_METACARPAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_RING_METACARPAL_EXT) },
1471 {
"OPENXR_HAND_JOINT_RING_PROXIMAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_RING_PROXIMAL_EXT) },
1472 {
"OPENXR_HAND_JOINT_RING_INTERMEDIATE", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_RING_INTERMEDIATE_EXT) },
1473 {
"OPENXR_HAND_JOINT_RING_DISTAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_RING_DISTAL_EXT) },
1474 {
"OPENXR_HAND_JOINT_RING_TIP", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_RING_TIP_EXT) },
1475 {
"OPENXR_HAND_JOINT_LITTLE_METACARPAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_LITTLE_METACARPAL_EXT) },
1476 {
"OPENXR_HAND_JOINT_LITTLE_PROXIMAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_LITTLE_PROXIMAL_EXT) },
1477 {
"OPENXR_HAND_JOINT_LITTLE_INTERMEDIATE", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_LITTLE_INTERMEDIATE_EXT) },
1478 {
"OPENXR_HAND_JOINT_LITTLE_DISTAL", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_LITTLE_DISTAL_EXT) },
1479 {
"OPENXR_HAND_JOINT_LITTLE_TIP", TYPVAR,
"I", SCOL_TYPTYPE(XR_HAND_JOINT_LITTLE_TIP_EXT) },
1488 {
"_GetOpenXrProjectionMatrix", 3,
"fun [ObjOpenXr 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]]]",
_GetOpenXrProjectionMatrix },
1518extern "C" SCOL_EXPORT
void ScolPauseWindowPlugin(mmachine m)
1520extern "C" SCOL_EXPORT
void ScolOpenXrPauseWindowPlugin(mmachine m)
1523 MMechostr(MSKDEBUG,
">> _ScolPauseWindowPlugin : call Pause OpenXR\n");
1524 sOpenXr::GetInstance()->SetState(
false);
1531extern "C" SCOL_EXPORT
void ScolResumeWindowPlugin(mmachine m)
1533extern "C" SCOL_EXPORT
void ScolOpenXrResumeWindowPlugin(mmachine m)
1536 MMechostr(MSKDEBUG,
">> ScolResumeWindowPlugin : call Resume OpenXR\n");
1537 sOpenXr::GetInstance()->SetState(
true);
1544int LoadOpenXr(mmachine m)
1548 MMechostr(MSKDEBUG,
"\n");
1549 MMechostr(MSKDEBUG,
" > Loading OpenXr Support\n");
1552 OBJ_OPENXR_SCOL = OBJregister(0 , 0, destroyOpenXrObj,
"OBJ_OPENXR_SCOL");
1553 k = PKhardpak2(m,
"mOpenXr.pkg",
sizeof(mOpenXrEngine) /
sizeof(mOpenXrEngine[0]), mOpenXrEngine);
1555 sOpenXr::GetInstance();
1557 MMechostr(MSKDEBUG,
" > Successfully Loaded\n\n");
1563 MMechostr(MSKDEBUG,
"\n");
1564 MMechostr(MSKDEBUG,
" > Unloading OpenXr Support\n");
1566 sOpenXr::GetInstance()->Kill();
1568 MMechostr(MSKDEBUG,
" > Successfully unloaded\n\n");
1579extern "C" SCOL_EXPORT
int ScolLoadPlugin(mmachine m, cbmachine w)
1583 return LoadOpenXr(m);
1590extern "C" SCOL_EXPORT
int ScolUnloadPlugin()
1592 return CloseOpenXr();
1600extern "C" SCOL_EXPORT
int ScolOpenXrLoadPlugin(mmachine m, cbmachine w)
1604 return LoadOpenXr(m);
1611extern "C" SCOL_EXPORT
int ScolOpenXrUnloadPlugin()
1613 return CloseOpenXr();
int _UpdateOpenXr(mmachine m)
_UpdateOpenXr : start OpenXr update you should call this on each render frame
int _GetOpenXrPassthroughSupported(mmachine m)
_GetOpenXrPassthroughSupported : Get the OpenXr passthrough support
int _GetOpenXrControllerButtons(mmachine m)
_GetOpenXrControllerButtons : Get the OpenXr controller buttons state button order in list is A,...
int _GetOpenXrPosition(mmachine m)
_GetOpenXrPosition : Get the OpenXr position from the IR camera
int _GetOpenXrControllerVelocity(mmachine m)
_GetOpenXrControllerVelocity : Get the OpenXr controller velocity
int _SetOpenXrPassthroughEnable(mmachine m)
_SetOpenXrPassthroughEnable : Set the OpenXr passthrough enable state
int _DSopenXrDevice(mmachine m)
_DSopenXrDevice : Destroy OpenXr object
int _GetOpenXrControllerPosition(mmachine m)
_GetOpenXrControllerPosition : Get the OpenXr controller position
int _GetOpenXrControllerType(mmachine m)
_GetOpenXrControllerType : Get the OpenXr controller type, controller or hand
int _GetOpenXrExtensions(mmachine m)
_GetOpenXrExtensions : Get the OpenXr extensions that are set to enable
int _GetOpenXrProjectionMatrix(mmachine m)
_GetOpenXrProjectionMatrix : Get the OpenXr camera projection matrix
int _GetOpenXrDeviceName(mmachine m)
_GetOpenXrDeviceName : Get the openXr device type
int _GetOpenXrVisibility(mmachine m)
_GetOpenXrVisibility : Get the OpenXr HMD visibility state
int _CRopenXrDevice(mmachine m)
_CRopenXrDevice : This function create a OpenXr object
int _GetOpenXrControllerAxis(mmachine m)
_GetOpenXrControllerAxis : Get the OpenXr controller axis values Axis order is touch pad X,...
int _GetOpenXrFovY(mmachine m)
_GetOpenXrFovY : Get the OpenXr fovY
int _GetOpenXrOrientation(mmachine m)
_GetOpenXrOrientation : Get the OpenXr sensor orientation
int _GetOpenXrControllerVisibility(mmachine m)
_GetOpenXrControllerVisibility : Get the OpenXr controller visibility state
int _GetOpenXrControllerTouches(mmachine m)
_GetOpenXrControllerTouches : Get the OpenXr controller touch state button order in list is A,...
int _GetOpenXrControllerOrientation(mmachine m)
_GetOpenXrControllerOrientation : Get the OpenXr controller orientation
int _SetOpenXrExtensions(mmachine m)
_SetOpenXrExtensions : Set the OpenXr extensions to enable if this is supported
int _GetOpenXrTextureSize(mmachine m)
_GetOpenXrTextureSize : Get the OpenXr texture size for RTT
int _GetOpenXrIPD(mmachine m)
_GetOpenXrIPD : Get the OpenXr eye spacing
int _UpdateOpenXrTextures(mmachine m)
_UpdateOpenXrTextures : Update the HMD textures pointer
int _GetOpenXrControllerBonesRotation(mmachine m)
_GetOpenXrControllerBonesRotation : Get the OpenXr controller bones rotation
int _SetOpenXrControllerRumble(mmachine m)
_SetOpenXrControllerRumble : Set the OpenXr controller rumble value
int _GetOpenXrControllerAngularVelocity(mmachine m)
_GetOpenXrControllerAngularVelocity : Get the OpenXr controller velocity
int _SetOpenXrAppName(mmachine m)
_SetOpenXrAppName : Set the OpenXr application name