diff --git a/index.html b/index.html new file mode 100644 index 0000000..52f43fc --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + WebSocket Test + + + + +
+
+ +
+
+ + diff --git a/index.js b/index.js new file mode 100644 index 0000000..049a22c --- /dev/null +++ b/index.js @@ -0,0 +1,69 @@ +window.onload = function () { + var app = new Vue({ + el: '#app', + + mounted () { + this.connectSteamVR() + }, + + data: function () { + return { + wsUri: 'ws://127.0.0.1:8998/', + wsData: null, + controllers: { left: {}, right: {} } + } + }, + + watch: { + controllers: function (newVal, oldVal) { + console.log('Update') + } + }, + + methods: { + connectSteamVR: function () { + console.log('Open data socket') + this.wsData = new WebSocket(this.wsUri) + this.wsData.onopen = this.onOpen + this.wsData.onclose = this.onClose + this.wsData.onerror = this.onError + this.wsData.onmessage = this.onMessage + }, + + onOpen: function (evt) { + console.log("Connected") + this.wsData.send('mailbox_open controller_visualizer') + this.wsData.send('mailbox_send input_server {"type":"request_input_state_updates","device_path":"/user/hand/left","returnAddress":"controller_visualizer"}') + this.wsData.send('mailbox_send input_server {"type":"request_input_state_updates","device_path":"/user/hand/right","returnAddress":"controller_visualizer"}') + }, + + onClose: function () { + console.log("Disconnected") + }, + + onError: function (evt) { + console.log('Error:', evt.data) + }, + + onMessage: function (evt) { + let msgData = JSON.parse(evt.data) + if (typeof msgData.components === 'undefined') return + + for (const componentData in msgData.components) { + if (!msgData.components.hasOwnProperty(componentData)) continue + const componentValue = msgData.components[componentData] + let componentName = componentData.split('/')[2] + let valueType = componentData.split('/')[3] + console.log(componentData.split('/')) + let hand = null + if (msgData.device === '/user/hand/left') hand = 'left' + else if (msgData.device === '/user/hand/right') hand = 'right' + + if (typeof this.controllers[hand][componentName] === 'undefined') this.controllers[hand][componentName] = {} + if (typeof this.controllers[hand][componentName][valueType] === 'undefined') this.controllers[hand][componentName][valueType] = 0 + this.controllers[hand][componentName][valueType] = componentValue + } + } + } + }) +} \ No newline at end of file diff --git a/index_controller_profile.json b/index_controller_profile.json new file mode 100644 index 0000000..bf8c00e --- /dev/null +++ b/index_controller_profile.json @@ -0,0 +1,127 @@ +{ + "/input/system" : { + "type" : "button", + "click" : true, + "touch" : true, + "binding_image_point" : [ 34,45 ], + "order" : 1 + }, + "/input/a" : { + "type" : "button", + "click" : true, + "touch" : true, + "binding_image_point" : [ 26, 42 ], + "order" : 6 + }, + "/input/b" : { + "type" : "button", + "click" : true, + "touch" : true, + "binding_image_point" : [ 18, 37 ], + "order" : 5 + }, + "/input/trigger" : { + "type" : "trigger", + "click" : true, + "touch" : true, + "value" : true, + "binding_image_point" : [ 11, 60 ], + "order" : 2 + }, + "/input/trackpad" : { + "type" : "trackpad", + "force" : true, + "touch" : true, + "binding_image_point" : [ 27, 37 ], + "order" : 3 + }, + "/input/grip" : { + "type" : "trigger", + "force" : true, + "value" : true, + "touch" : true, + "input_activity_path" : "/input/grip/force", + "input_activity_threshold" : 0.1, + "binding_image_point" : [ 47, 86 ], + "order" : 7 + }, + "/input/thumbstick" : { + "type" : "joystick", + "click" : true, + "touch" : true, + "binding_image_point" : [ 31, 26 ], + "order" : 4 + }, + "/input/pinch" : { + "type" : "pinch", + "value_source" : "/input/trigger", + "capsense_source" : "/input/finger/index", + "force_source" : "/input/trackpad", + "binding_image_point" : [ 27, 37 ], + "order" : 8 + }, + + "/input/finger/index" : { + "type" : "trigger", + "visibility" : "InputValueVisibility_AvailableButHidden", + "binding_image_point" : [ 56, 86 ], + "order" : 100 + }, + "/input/finger/middle" : { + "type" : "trigger", + "visibility" : "InputValueVisibility_AvailableButHidden", + "binding_image_point" : [ 56, 86 ], + "order" : 101 + }, + "/input/finger/ring" : { + "type" : "trigger", + "visibility" : "InputValueVisibility_AvailableButHidden", + "binding_image_point" : [ 56, 86 ], + "order" : 102 + }, + "/input/finger/pinky" : { + "type" : "trigger", + "visibility" : "InputValueVisibility_AvailableButHidden", + "binding_image_point" : [ 56, 86 ], + "order" : 103 + }, + + "/pose/raw" : { + "type" : "pose", + "binding_image_point" : [ 5, 35 ] + }, + "/pose/base" : { + "type" : "pose", + "binding_image_point" : [ 65, 136 ] + }, + "/pose/handgrip" : { + "type" : "pose", + "binding_image_point" : [ 56, 95 ] + }, + "/pose/tip" : { + "type" : "pose", + "binding_image_point" : [ 5, 35 ] + }, + "/pose/gdc2015" : { + "type" : "pose", + "binding_image_point" : [ 5, 35 ] + }, + + "/input/skeleton/left" : { + "type" : "skeleton", + "skeleton": "/skeleton/hand/left", + "side" : "left", + "binding_image_point" : [ 5, 35 ] + }, + "/input/skeleton/right" : { + "type" : "skeleton", + "skeleton": "/skeleton/hand/right", + "side" : "right", + "binding_image_point" : [ 5, 35 ] + }, + + "/output/haptic" : { + "type" : "vibration", + "binding_image_point" : [ 5, 35 ] + } +} diff --git a/touch_profile.json b/touch_profile.json new file mode 100644 index 0000000..d591f69 --- /dev/null +++ b/touch_profile.json @@ -0,0 +1,95 @@ +{ + "/input/joystick" : { + "type" : "joystick", + "binding_image_point" : [ 54, 31 ], + "click" : true, + "touch" : true, + "order" : 2 + }, + "/input/trigger" : { + "type" : "trigger", + "binding_image_point" : [ 22, 85 ], + "value" : true, + "touch" : true, + "order" : 1 + }, + "/input/grip" : { + "type" : "trigger", + "binding_image_point" : [ 100, 86 ], + "value" : true, + "touch" : true, + "order" : 3 + }, + "/input/a" : { + "type" : "button", + "side" : "right", + "binding_image_point" : [ 70, 49 ], + "click" : true, + "touch" : true, + "order" : 4 + }, + "/input/b" : { + "type" : "button", + "side" : "right", + "binding_image_point" : [ 54, 55 ], + "click" : true, + "touch" : true, + "order" : 5 + }, + "/input/x" : { + "type" : "button", + "side" : "left", + "binding_image_point" : [ 70, 49 ], + "click" : true, + "touch" : true, + "order" : 4 + }, + "/input/y" : { + "type" : "button", + "side" : "left", + "binding_image_point" : [ 54, 55 ], + "click" : true, + "touch" : true, + "order" : 5 + }, + "/input/system" : { + "type" : "button", + "side" : "left", + "binding_image_point" : [ 72, 39 ], + "click" : true, + "touch" : true, + "order" : 0 + }, + "/input/skeleton/right" : { + "type" : "skeleton", + "side" : "right", + "skeleton" : "/skeleton/hand/right", + "binding_image_point" : [ 11, 150 ] + }, + "/input/skeleton/left" : { + "type" : "skeleton", + "side" : "left", + "skeleton" : "/skeleton/hand/left", + "binding_image_point" : [ 11, 150 ] + }, + "/output/haptic" : { + "type" : "vibration", + "binding_image_point" : [ 72, 39 ] + }, + "/pose/raw" : { + "type" : "pose", + "binding_image_point" : [ 14, 16 ] + }, + "/pose/base" : { + "type" : "pose", + "binding_image_point" : [ 11, 150 ] + }, + "/pose/handgrip" : { + "type" : "pose", + "binding_image_point" : [ 24, 86 ] + }, + "/pose/tip" : { + "type" : "pose", + "binding_image_point" : [ 14, 16 ] + } +} diff --git a/vive_controller_profile.json b/vive_controller_profile.json new file mode 100644 index 0000000..dc56db0 --- /dev/null +++ b/vive_controller_profile.json @@ -0,0 +1,70 @@ +{ + "/input/trackpad" : { + "type" : "trackpad", + "click" : true, + "touch" : true, + "binding_image_point" : [ 66, 59 ], + "order" : 2 + }, + "/input/trigger" : { + "type" : "trigger", + "click" : true, + "value" : true, + "binding_image_point" : [ 41, 64 ], + "order" : 1 + }, + "/input/grip" : { + "type" : "button", + "click" : true, + "binding_image_point" : [ 52, 87 ], + "order" : 3 + }, + "/input/application_menu" : { + "type" : "button", + "click" : true, + "binding_image_point" : [ 64, 35 ], + "order" : 4 + }, + "/input/system" : { + "type" : "button", + "click" : true, + "binding_image_point" : [ 67, 81 ], + "order" : 5 + }, + "/input/skeleton/right" : { + "type" : "skeleton", + "side" : "right", + "skeleton" : "/skeleton/hand/right", + "binding_image_point" : [ 62, 16 ] + }, + "/input/skeleton/left" : { + "type" : "skeleton", + "side" : "left", + "skeleton" : "/skeleton/hand/left", + "binding_image_point" : [ 62, 16 ] + }, + "/pose/raw" : { + "type" : "pose", + "binding_image_point" : [ 62, 16 ] + }, + "/pose/base" : { + "type" : "pose", + "binding_image_point" : [ 65, 150 ] + }, + "/pose/handgrip" : { + "type" : "pose", + "binding_image_point" : [ 52, 86 ] + }, + "/pose/tip" : { + "type" : "pose", + "binding_image_point" : [ 62, 16 ] + }, + "/pose/gdc2015" : { + "type" : "pose", + "binding_image_point" : [ 62, 16 ] + }, + "/output/haptic" : { + "type" : "vibration", + "binding_image_point" : [ 66, 59 ] + } +} \ No newline at end of file