Skip to content

Commit

Permalink
add trackpad force, refactor debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
I5UCC committed Sep 5, 2023
1 parent 297b2bf commit 90b42b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/ThumbParamsOSC.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_controllertype():


def send_osc_message(parameter, value):
add_to_debugoutput(parameter, value)
oscClient.send_message("/avatar/parameters/" + parameter, value)


Expand Down Expand Up @@ -75,58 +76,47 @@ def handle_input():

if config["ControllerType"]:
_controller_type = get_controllertype()
add_to_debugoutput("ControllerType", _controller_type)
send_osc_message("ControllerType", _controller_type)

_strinputs = ""
for action in bool_actions[:8]: # Touch Actions
val = get_value(action)
_strinputs += "1" if val else "0"
if action["enabled"]:
add_to_debugoutput(action["osc_parameter"], val)
send_osc_message(action["osc_parameter"], val)
if config["LeftThumb"]:
_leftthumb = _strinputs[:4].rfind("1") + 1
add_to_debugoutput("LeftThumb", _leftthumb)
send_osc_message("LeftThumb", _leftthumb)
if config["RightThumb"]:
_rightthumb = _strinputs[4:].rfind("1") + 1
add_to_debugoutput("RightThumb", _rightthumb)
send_osc_message("RightThumb", _rightthumb)
if config["LeftABButtons"]:
_leftab = _strinputs[0] == "1" and _strinputs[1] == "1"
add_to_debugoutput("LeftABButtons", _leftab)
send_osc_message("LeftABButtons", _leftab)
if config["RightABButtons"]:
_rightab = _strinputs[4] == "1" and _strinputs[5] == "1"
add_to_debugoutput("RightABButtons", _rightab)
send_osc_message("RightABButtons", _rightab)

for action in bool_actions[8:]:
if not action["enabled"]:
continue
val = get_value(action)
add_to_debugoutput(action["osc_parameter"], val)
send_osc_message(action["osc_parameter"], val)

for action in vector1_actions:
if not action["enabled"]:
continue
val = get_value(action)
add_to_debugoutput(action["osc_parameter"], val)
send_osc_message(action["osc_parameter"], val)

for action in vector2_actions[-4:]:
val_x, val_y = get_value(action)
if action["enabled"][0]:
add_to_debugoutput(action["osc_parameter"][0], val_x)
send_osc_message(action["osc_parameter"][0], val_x)
if action["enabled"][1]:
add_to_debugoutput(action["osc_parameter"][1], val_y)
send_osc_message(action["osc_parameter"][1], val_y)
if len(action["osc_parameter"]) > 2 and action["enabled"][2]:
tmp = (val_x > sticktolerance or val_y > sticktolerance) or (val_x < -sticktolerance or val_y < -sticktolerance)
add_to_debugoutput(action["osc_parameter"][2], tmp)
send_osc_message(action["osc_parameter"][2], tmp)

if args.debug:
Expand Down
18 changes: 18 additions & 0 deletions src/bindings/knuckles_thumbparams_bindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@
"value_hold_threshold" : "1.35"
},
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"force" : {
"output" : "/actions/thumbparams/in/lefttrackpadforce"
}
},
"mode" : "force_sensor",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"force" : {
"output" : "/actions/thumbparams/in/righttrackpadforce"
}
},
"mode" : "force_sensor",
"path" : "/user/hand/right/input/trackpad"
}
]
}
Expand Down
12 changes: 12 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@
"osc_parameter": "RightGrabForce",
"enabled": true
},
{
"name": "/actions/thumbparams/in/righttrackpadforce",
"type": "vector1",
"osc_parameter": "RightTrackpadForce",
"enabled": true
},
{
"name": "/actions/thumbparams/in/lefttrackpadforce",
"type": "vector1",
"osc_parameter": "LeftTrackpadForce",
"enabled": true
},
{
"name": "/actions/thumbparams/in/leftstickxy",
"type": "vector2",
Expand Down
4 changes: 2 additions & 2 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python-osc==1.8.0
openvr==1.16.802
python-osc
openvr
argparse

0 comments on commit 90b42b7

Please sign in to comment.