diff --git a/examples/gjs.js b/examples/gjs.js new file mode 100755 index 0000000..07ec7ca --- /dev/null +++ b/examples/gjs.js @@ -0,0 +1,35 @@ +#!/usr/bin/env gjs + +const GOpenHMD = imports.gi.GOpenHMD; + + +function devs_info(context) { + devs = context.enumerate() + + for (var i = 0; i < devs.length; i++) { + print("Discovered device:" + + ` vendor: '${devs[i].vendor}'` + + ` product': '${devs[i].product}'`) + } +} + + +function dev_quat_info(context, dev) { + context.update(); + var quat = dev.rotation_quat(); + console.debug(`quat: x=${quat.x}, y=${quat.y}, z=${quat.z}, w=${quat.w}`); + GOpenHMD.sleep(0.01); +} + + +print(`Version: ${GOpenHMD.version().to_string()}`) + +var context = new GOpenHMD.Context(); + +devs_info(context); + +var dev = context.open_device(0, null) + +for(var i = 0; i < 300; i++){ + dev_quat_info(context, dev) +} diff --git a/examples/python.py b/examples/python.py new file mode 100755 index 0000000..fb162ca --- /dev/null +++ b/examples/python.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import gi + +gi.require_version('GOpenHMD', '1.0') +from gi.repository import GOpenHMD + + +def devs_info(context): + for dev in context.enumerate(): + print(f"Discovered device: vendor '{dev.get_vendor()}'" + f", product '{dev.get_product()}'" + ) + + +def dev_quat_info(context, dev): + context.update() + quat = dev.rotation_quat() + print(f"quat: x={quat.x} y={quat.y} z={quat.z} w={quat.w}") + GOpenHMD.sleep(0.01) + + +print(f"Version: {GOpenHMD.version().to_string()}") + +context = GOpenHMD.Context() + +devs_info(context) + +dev = context.open_device(0) + +for i in range(0, 300): + dev_quat_info(context, dev)