It is just a straight one to one wrapper for the functions available via the framework / headers using extern. I dunno how hard it would be add other support to it as, as you can see in my comment in the code, I am crap for C/C++, but I suppose writing another one as long as there was documentation on your other hardware wouldn't be too difficult.
Here it is if you want to see it... It is too bad that Vuzix's current framework on the Mac doesn't support stereoscopic 3D... the IWEAR_Stereo function returns an error that the hardware is not supported.
'Okay here's how this works... and I am crap when it comes to C/C++
'I made a .m file that simply #include the iweardrv.h file since Blitz's compiler
'pukes when you specify a .h file instead of a whole group with *.h
'Looking through the Mac specific Blitz sources I learned how to link against a
'Framework... by telling it To with -Framework FRAMEWORKNAME ... kinda a "duh" moment.
Import "iweardrv.m"
Import "-framework IWear"
Extern
Function IWEAR_End:Int() 'Call at the end of your program to shut down any connection and handles to the iWear device(s)
Function IWEAR_Start:Int() 'Must be called at the beginning to initialize the iWear
Function IWEAR_Count:Int() 'Returns the number of iWear devices connection to the system.
Function IWEAR_OpenIndexed:Int( c:Int ) 'Attempt to connect to the id of a specific iWear device. Returns pointer to device.
Function IWEAR_Open:Int() 'Attemp to connect to the next available iWear. Returns errorcode or null.
Function IWEAR_Close(handle:Int) 'Close the device at the handle.
Function IWEAR_GetCapabilities:Int() 'Get what features the device supports.
Function IWEAR_ZeroSet:Int(handle:Int) 'Set the current head position of the user as the calibrated ZERO point straight ahead and level.
Function IWEAR_ZeroClear:Int(handle:Int)
Function IWEAR_SetSmoothing:Int(handle:Int,smooth:Int) 'smooth can be 0 - 32 with 32 being max smoothing average.
Function IWEAR_GetTracking:Int( handle:Int,yaw:Int Var, pitch:Int Var, roll:Int Var)
Function IWEAR_GetTrackingNormalized:Int( handle:Int,yaw:Float Var, pitch:Float Var, roll:Float Var) 'Returns all values between -1.0 and 1.0
Function IWEAR_GetHeading:Int(handle:Int,heading:Int Var) 'Returns the heading where 0 is north and -16000 is east (from 0) and 16000 is west
Function IWEAR_GetHeadingNormalized:Int(handle:Int,heading:Float Var) 'returns the heading between -1.0 and 1.0, 0 = north, 1,-1 south, 0.5 = west, -0.5 = east.
Function IWEAR_BeginCalibrate:Int(handle:Int) 'Begin the calibration process. See iWear docs for comments.
Function IWEAR_EndCalibrate:Int(handle:Int, save:Int) 'save = 1 to save or 0 to not save the date to com.vuzix.VR920.plist.
Function IWEAR_Stereo:Int(handle:Int, eye:Int)
Rem
Control how the iWear displays content
eye = 0 then view is 2D, same for both eyes
eye = 1 then the next frame should to go the left eye.
eye = 2 the next frame goes to the right eye.
eye = 3 AUTO starting left, so LRLR
eye = 4 AUTO starting right, so RLRL
EndRem
EndExtern
'Consts
Const IWEAR_2D:Int = 0
Const IWEAR_LEFT:Int = 1
Const IWEAR_RIGHT:Int = 2
Const IWEAR_AUTO_LR:Int = 3
Const IWEAR_AUTO_RL:Int = 4
Rem
ERROR CODES (From iweardrv.h for reference)
IWEAR_SUCCESS (0) /* the call was successful */
IWEAR_ERROR_NOT_FOUND (-1) /* the device was not found */
IWEAR_ERROR_UNABLE_TO_OPEN (-2) /* unable to open the device */
IWEAR_ERROR_OUT_OF_RANGE (-3) /* value was out of range */
IWEAR_ERROR_SAVING_PREFS (-4) /* unable to save the preferences */
IWEAR_ERROR_BAD_HANDLE (-5) /* handle passed in was bad */
IWEAR_ERROR_INCAPABLE (-6) /* device is incapable of that */
EndRem
'TESTING
testrResult:Int = 0
Print "TEST CASES: SANITY CHECK OF FUNCTIONALITY"
Print "-----------------------------------------"
Print "TEST 1:"
testResult = IWEAR_Start()
If testResult <> 0
Print " START() failed code:"+testResult
Else
Print " PASSED!"
EndIf
Print "TEST 2:"
testResult = IWEAR_Count()
Print " COUNT() returned:"+testResult
Print " Verify that "+testResult+" iWear devices are connected to the USB ports of the system."
Print "TEST 3:"
iwearhnd:Int = IWEAR_Open() 'we will need iwearhnd later to test close()
If iwearhnd > 0
Print " PASSED! Device handle:"+iwearhnd
EndIf
If iwearhnd < 0
Print " Open() failed code:"+iwearhnd
EndIf
Print "This concludes the sanity check to connect to a device."
Local headyaw:Int
Local headpitch:Int
Local headroll:Int
Graphics 800,600,32,0
While Not KeyDown(KEY_ESCAPE)
Cls
IWEAR_GetTracking(iwearhnd, headyaw,headpitch,headroll)
DrawText "YAW:"+headyaw+" PITCH:"+headpitch+" ROLL:"+headroll,10,10
Flip
Wend
Print "End() = "+IWEAR_End()
End
Type TiWear
Field hmds:TiWearHMD[]
'Init the iWear hardware and update the count of how many are attached and get all of their handles.
Method init()
IWEAR_Start()
Local count = IWEAR_Count()
Self.hmds = New TiWearHMD[count]
For Local currHMD:TiWearHMD = EachIn hmds
currHMD.handle = IWEAR_Open()
Next
EndMethod
Method update()
For Local currHMD:tiWearHMD = EachIn hmds
currHMD.update()
Next
EndMethod
Method cleanup()
For Local currHMD:tiWearHMD = EachIn hmds
currHMD.close()
Next
hmds = Null
GCCollect
IWEAR_End()
EndMethod
Method setDisplayMode(device:Int,mode:Int)
If device <= hmds.length-1
If mode > 0 And mode < 4
hmds[device].display_mode = mode
EndIf
EndIf
EndMethod
EndType
Type TiWearHMD
Field handle:Int 'pointer to the iWear headset
Field display_mode:Int = 0 'the current display mode of content on the device. See the consts.
Field current_eye:Int = 0 '0 = left, 1 = right
Field status:Int 'last return code will be here
Field yaw:Float 'I'll be using the normalized tracking.
Field pitch:Float
Field roll:Float
Method update()
'Get the latest head tracking data
Self.status = IWEAR_GetTrackingNormalized(Self.handle, Self.yaw,Self.pitch,Self.roll)
'update the stereo views if needed.
If display_mode > 0
update3D()
EndIf
EndMethod
Method update3D()
current_eye = Abs(current_eye - 1)
IWEAR_Stereo(Self.handle,current_eye)
EndMethod
Method close()
IWEAR_Close(Self.handle)
EndMethod
EndType
|