3D VR Headset

Blitz3D Forums/Blitz3D Programming/3D VR Headset


it won't return anything.
I can't read out PYR cause i don't know how to.


Of course you first need to execute the commands to initialise the device. Then the PYR should work like this (assuming you have declared it in the decls)

my_pitch=createbank(4)
my_yaw=createbank(4)
my_roll=createbank(4)

Get_PYR(my_pitch, my_yaw, my_roll)
print peekint(my_pitch,0)
print peekint(my_yaw,0)
print peekint(my_roll,0)

as for the C++ code, it looks like everything is pretty simple to convert to blitz:


my_pitch=createbank(4)
my_yaw=createbank(4)
my_roll=createbank(4)


;// Start by connecting to the CyberMaxx
if AutoDetectComPort()=0
 ;// ERROR CyberMaxx not Found
 runtimeerror "ERROR CyberMaxx not Found"
endif

;// These are optional
;CyberHMD.SetHysteresisOn(); // turn on the hysteresis filter to minimize jittering (try this later)

my_version_adr=Get_Version%() ; returns a pointer to a string

SetSamplingRate(50); // Used only in continous mode
;// default is 40 packets/s

;// This is how you read
while keyhit(1)=0
 ;// if the CyberMaxx has supplied data, this returns true
 if  ReadFromPort()<>0
  Get_PYR(my_pitch, my_yaw, my_roll)
  print peekint(my_pitch,0)
  print peekint(my_yaw,0)
  print peekint(my_roll,0)
 else
  print "Error"
 endif
wend

Of course I doubt it will work right away, but probably it gives you the direction.

Again, make sure your decls are using the right function name return types, I see you have a lot of string return types, doublecheck if everything is right

void dothis() means it won't return anything
char dothis() means it will return a string. declare: dothis$()
char* dothis() means it will return a (32bit int) pointer to a string, use dothis%() (see below how to use a pointer)
int dothis() means it will return an int, use dothis%()
BOOL dothis() means it will return true or false, I think you can use an int here.

The function Get_Version is a bit special, it will return an adress (=Pointer) of a 10 Bytes string. You need to use RTLMemoryMove2 to copy the 10 bytes to a blitz bank. See code archives, userlibs, Avifil32 Frame grabber example on how to declare and use RTLMemoryMove.