Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetaphor committed Aug 7, 2019
0 parents commit f50477f
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<head>
<title>WebSocket Test</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="/index.js"></script>
</head>
<body>
<div id="app">
<div v-for="(hand, index) in controllers" :key="index">
<template v-for="(control, index) in hand">
{{ control }}
</template>
</div>
</div>
</body>
</html>
69 changes: 69 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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
}
}
}
})
}
127 changes: 127 additions & 0 deletions index_controller_profile.json
Original file line number Diff line number Diff line change
@@ -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 ]
}
}
95 changes: 95 additions & 0 deletions touch_profile.json
Original file line number Diff line number Diff line change
@@ -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 ]
}
}
70 changes: 70 additions & 0 deletions vive_controller_profile.json
Original file line number Diff line number Diff line change
@@ -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 ]
}
}

0 comments on commit f50477f

Please sign in to comment.