mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
d/remote: Expose a Index controller instead of simple controller
This commit is contained in:
parent
46305b77db
commit
7f73a58045
|
@ -56,26 +56,38 @@ r_device_update_inputs(struct xrt_device *xdev)
|
|||
struct r_remote_controller_data *latest = rd->is_left ? &r->latest.left : &r->latest.right;
|
||||
|
||||
if (!latest->active) {
|
||||
xdev->inputs[0].active = false;
|
||||
xdev->inputs[0].timestamp = now;
|
||||
xdev->inputs[1].active = false;
|
||||
xdev->inputs[1].timestamp = now;
|
||||
xdev->inputs[2].active = false;
|
||||
xdev->inputs[2].timestamp = now;
|
||||
xdev->inputs[3].active = false;
|
||||
xdev->inputs[3].timestamp = now;
|
||||
} else {
|
||||
xdev->inputs[0].active = true;
|
||||
xdev->inputs[0].timestamp = now;
|
||||
xdev->inputs[0].value.boolean = latest->select;
|
||||
xdev->inputs[1].active = true;
|
||||
xdev->inputs[1].timestamp = now;
|
||||
xdev->inputs[1].value.boolean = latest->menu;
|
||||
xdev->inputs[2].active = true;
|
||||
xdev->inputs[2].timestamp = now;
|
||||
xdev->inputs[3].active = true;
|
||||
xdev->inputs[3].timestamp = now;
|
||||
for (uint32_t i = 0; i < 19; i++) {
|
||||
xdev->inputs[i].active = false;
|
||||
xdev->inputs[i].timestamp = now;
|
||||
U_ZERO(&xdev->inputs[i].value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 19; i++) {
|
||||
xdev->inputs[i].active = true;
|
||||
xdev->inputs[i].timestamp = now;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
xdev->inputs[0].value.boolean = latest->system_click;
|
||||
xdev->inputs[1].value.boolean = latest->system_touch;
|
||||
xdev->inputs[2].value.boolean = latest->a_click;
|
||||
xdev->inputs[3].value.boolean = latest->a_touch;
|
||||
xdev->inputs[4].value.boolean = latest->b_click;
|
||||
xdev->inputs[5].value.boolean = latest->b_touch;
|
||||
xdev->inputs[6].value.vec1 = latest->squeeze_value;
|
||||
xdev->inputs[7].value.vec1 = latest->squeeze_force;
|
||||
xdev->inputs[8].value.boolean = latest->trigger_click;
|
||||
xdev->inputs[9].value.vec1 = latest->trigger_value;
|
||||
xdev->inputs[10].value.boolean = latest->trigger_touch;
|
||||
xdev->inputs[11].value.vec2 = latest->thumbstick;
|
||||
xdev->inputs[12].value.boolean = latest->thumbstick_click;
|
||||
xdev->inputs[13].value.boolean = latest->thumbstick_touch;
|
||||
xdev->inputs[14].value.vec2 = latest->trackpad;
|
||||
xdev->inputs[15].value.vec1 = latest->trackpad_force;
|
||||
xdev->inputs[16].value.boolean = latest->trackpad_touch;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -87,7 +99,7 @@ r_device_get_tracked_pose(struct xrt_device *xdev,
|
|||
struct r_device *rd = r_device(xdev);
|
||||
struct r_hub *r = rd->r;
|
||||
|
||||
if (name != XRT_INPUT_SIMPLE_AIM_POSE && name != XRT_INPUT_SIMPLE_GRIP_POSE) {
|
||||
if (name != XRT_INPUT_INDEX_AIM_POSE && name != XRT_INPUT_INDEX_GRIP_POSE) {
|
||||
U_LOG_E("Unknown input name");
|
||||
return;
|
||||
}
|
||||
|
@ -147,7 +159,7 @@ r_device_get_hand_tracking(struct xrt_device *xdev,
|
|||
struct xrt_pose hand_on_handle_pose = XRT_POSE_IDENTITY;
|
||||
|
||||
struct xrt_space_relation relation;
|
||||
xrt_device_get_tracked_pose(xdev, XRT_INPUT_SIMPLE_GRIP_POSE, requested_timestamp_ns, &relation);
|
||||
xrt_device_get_tracked_pose(xdev, XRT_INPUT_INDEX_GRIP_POSE, requested_timestamp_ns, &relation);
|
||||
|
||||
u_hand_joints_set_out_data(&rd->hand_tracking, hand, &relation, &hand_on_handle_pose, out_value);
|
||||
out_value->is_active = latest->hand_tracking_active;
|
||||
|
@ -183,7 +195,7 @@ r_device_create(struct r_hub *r, bool is_left)
|
|||
{
|
||||
// Allocate.
|
||||
const enum u_device_alloc_flags flags = 0;
|
||||
const uint32_t input_count = 5;
|
||||
const uint32_t input_count = 20; // 19 + hand tracker
|
||||
const uint32_t output_count = 1;
|
||||
struct r_device *rd = U_DEVICE_ALLOCATE( //
|
||||
struct r_device, flags, input_count, output_count);
|
||||
|
@ -199,7 +211,7 @@ r_device_create(struct r_hub *r, bool is_left)
|
|||
rd->base.orientation_tracking_supported = true;
|
||||
rd->base.position_tracking_supported = true;
|
||||
rd->base.hand_tracking_supported = true;
|
||||
rd->base.name = XRT_DEVICE_SIMPLE_CONTROLLER;
|
||||
rd->base.name = XRT_DEVICE_INDEX_CONTROLLER;
|
||||
rd->r = r;
|
||||
rd->is_left = is_left;
|
||||
|
||||
|
@ -207,17 +219,34 @@ r_device_create(struct r_hub *r, bool is_left)
|
|||
snprintf(rd->base.str, sizeof(rd->base.str), "Remote %s Controller", is_left ? "Left" : "Right");
|
||||
snprintf(rd->base.serial, sizeof(rd->base.str), "Remote %s Controller", is_left ? "Left" : "Right");
|
||||
|
||||
|
||||
|
||||
// Inputs and outputs.
|
||||
rd->base.inputs[0].name = XRT_INPUT_SIMPLE_SELECT_CLICK;
|
||||
rd->base.inputs[1].name = XRT_INPUT_SIMPLE_MENU_CLICK;
|
||||
rd->base.inputs[2].name = XRT_INPUT_SIMPLE_GRIP_POSE;
|
||||
rd->base.inputs[3].name = XRT_INPUT_SIMPLE_AIM_POSE;
|
||||
rd->base.inputs[0].name = XRT_INPUT_INDEX_SYSTEM_CLICK;
|
||||
rd->base.inputs[1].name = XRT_INPUT_INDEX_SYSTEM_TOUCH;
|
||||
rd->base.inputs[2].name = XRT_INPUT_INDEX_A_CLICK;
|
||||
rd->base.inputs[3].name = XRT_INPUT_INDEX_A_TOUCH;
|
||||
rd->base.inputs[4].name = XRT_INPUT_INDEX_B_CLICK;
|
||||
rd->base.inputs[5].name = XRT_INPUT_INDEX_B_TOUCH;
|
||||
rd->base.inputs[6].name = XRT_INPUT_INDEX_SQUEEZE_VALUE;
|
||||
rd->base.inputs[7].name = XRT_INPUT_INDEX_SQUEEZE_FORCE;
|
||||
rd->base.inputs[8].name = XRT_INPUT_INDEX_TRIGGER_CLICK;
|
||||
rd->base.inputs[9].name = XRT_INPUT_INDEX_TRIGGER_VALUE;
|
||||
rd->base.inputs[10].name = XRT_INPUT_INDEX_TRIGGER_TOUCH;
|
||||
rd->base.inputs[11].name = XRT_INPUT_INDEX_THUMBSTICK;
|
||||
rd->base.inputs[12].name = XRT_INPUT_INDEX_THUMBSTICK_CLICK;
|
||||
rd->base.inputs[13].name = XRT_INPUT_INDEX_THUMBSTICK_TOUCH;
|
||||
rd->base.inputs[14].name = XRT_INPUT_INDEX_TRACKPAD;
|
||||
rd->base.inputs[15].name = XRT_INPUT_INDEX_TRACKPAD_FORCE;
|
||||
rd->base.inputs[16].name = XRT_INPUT_INDEX_TRACKPAD_TOUCH;
|
||||
rd->base.inputs[17].name = XRT_INPUT_INDEX_GRIP_POSE;
|
||||
rd->base.inputs[18].name = XRT_INPUT_INDEX_AIM_POSE;
|
||||
if (is_left) {
|
||||
rd->base.inputs[4].name = XRT_INPUT_GENERIC_HAND_TRACKING_LEFT;
|
||||
rd->base.inputs[19].name = XRT_INPUT_GENERIC_HAND_TRACKING_LEFT;
|
||||
} else {
|
||||
rd->base.inputs[4].name = XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT;
|
||||
rd->base.inputs[19].name = XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT;
|
||||
}
|
||||
rd->base.outputs[0].name = XRT_OUTPUT_NAME_SIMPLE_VIBRATION;
|
||||
rd->base.outputs[0].name = XRT_OUTPUT_NAME_INDEX_HAPTIC;
|
||||
|
||||
if (is_left) {
|
||||
rd->base.device_type = XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER;
|
||||
|
|
|
@ -353,13 +353,9 @@ r_create_devices(uint16_t port, struct xrt_system_devices **out_xsysd)
|
|||
u_var_add_pose(r, &r->latest.hmd.pose, "hmd.pose");
|
||||
// u_var_add_gui_header(r, &r->gui.left, "Left");
|
||||
u_var_add_bool(r, &r->latest.left.active, "left.active");
|
||||
u_var_add_bool(r, &r->latest.left.select, "left.select");
|
||||
u_var_add_bool(r, &r->latest.left.menu, "left.menu");
|
||||
u_var_add_pose(r, &r->latest.left.pose, "left.pose");
|
||||
// u_var_add_gui_header(r, &r->gui.right, "Right");
|
||||
u_var_add_bool(r, &r->latest.right.active, "right.active");
|
||||
u_var_add_bool(r, &r->latest.right.select, "right.select");
|
||||
u_var_add_bool(r, &r->latest.right.menu, "right.menu");
|
||||
u_var_add_pose(r, &r->latest.right.pose, "right.pose");
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ struct xrt_system_devices;
|
|||
*
|
||||
* @ingroup drv_remote
|
||||
*/
|
||||
#define R_HEADER_VALUE (*(uint64_t *)"mndrmt1\0")
|
||||
#define R_HEADER_VALUE (*(uint64_t *)"mndrmt2\0")
|
||||
|
||||
/*!
|
||||
* Data per controller.
|
||||
|
@ -51,12 +51,31 @@ struct r_remote_controller_data
|
|||
|
||||
float hand_curl[5];
|
||||
|
||||
bool hand_tracking_active;
|
||||
struct xrt_vec1 trigger_value;
|
||||
struct xrt_vec1 squeeze_value;
|
||||
struct xrt_vec1 squeeze_force;
|
||||
struct xrt_vec2 thumbstick;
|
||||
struct xrt_vec1 trackpad_force;
|
||||
struct xrt_vec2 trackpad;
|
||||
|
||||
bool hand_tracking_active;
|
||||
bool active;
|
||||
bool select;
|
||||
bool menu;
|
||||
bool _pad;
|
||||
|
||||
bool system_click;
|
||||
bool system_touch;
|
||||
bool a_click;
|
||||
bool a_touch;
|
||||
bool b_click;
|
||||
bool b_touch;
|
||||
bool trigger_click;
|
||||
bool trigger_touch;
|
||||
bool thumbstick_click;
|
||||
bool thumbstick_touch;
|
||||
bool trackpad_touch;
|
||||
bool _pad0;
|
||||
bool _pad1;
|
||||
bool _pad2;
|
||||
// active(2) + bools(11) + pad(3) = 16
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
|
@ -105,6 +105,56 @@ handle_downable_button(const char *name)
|
|||
return igIsItemHovered(ImGuiHoveredFlags_RectOnly) && igIsMouseDown(ImGuiMouseButton_Left);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_input(struct r_remote_controller_data *d)
|
||||
{
|
||||
igText("Hover buttons and sliders to touch component.");
|
||||
bool touched = false;
|
||||
|
||||
d->system_click = handle_downable_button("System");
|
||||
d->system_touch = igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
igSameLine(0, 3);
|
||||
|
||||
d->a_click = handle_downable_button("A");
|
||||
d->a_touch = igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
igSameLine(0, 3);
|
||||
|
||||
d->b_click = handle_downable_button("B");
|
||||
d->b_touch = igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
igSameLine(0, 3);
|
||||
|
||||
igCheckbox("Active", &d->active);
|
||||
|
||||
// Squeeze
|
||||
igSliderFloat("Squeeze Value", &d->squeeze_value.x, 0, 1, "%.2f", 0);
|
||||
igSliderFloat("Squeeze Force", &d->squeeze_force.x, 0, 1, "%.2f", 0);
|
||||
|
||||
// Trigger
|
||||
igText("Value > 0.0 causes touch, 0.7 > causes click");
|
||||
igSliderFloat("Trigger", &d->trigger_value.x, 0, 1, "%.2f", 0);
|
||||
touched |= igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
d->trigger_click = d->trigger_value.x > 0.7;
|
||||
touched |= d->trigger_value.x > 0.0001;
|
||||
d->trigger_touch = touched;
|
||||
|
||||
// Thumbstick
|
||||
touched = false;
|
||||
d->thumbstick_click = handle_downable_button("Thumbstick Click");
|
||||
touched |= igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
igSliderFloat2("Thumbstick", &d->thumbstick.x, -1, 1, "%.2f", 0);
|
||||
touched |= igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
d->thumbstick_touch = touched;
|
||||
|
||||
// Trackpad
|
||||
touched = false;
|
||||
igSliderFloat2("Trackpad", &d->trackpad.x, -1, 1, "%.2f", 0);
|
||||
touched |= igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
igSliderFloat("Trackpad Force", &d->trackpad_force.x, 0, 1, "%.2f", 0);
|
||||
touched |= igIsItemHovered(ImGuiHoveredFlags_RectOnly);
|
||||
touched |= d->trackpad_force.x >= 0.0001f;
|
||||
d->trackpad_touch = touched;
|
||||
}
|
||||
|
||||
static void
|
||||
render_cheat_menu(struct gui_remote *gr, struct gui_program *p)
|
||||
{
|
||||
|
@ -264,11 +314,7 @@ render_cheat_menu(struct gui_remote *gr, struct gui_program *p)
|
|||
|
||||
#define BUTTONS(prefix) \
|
||||
do { \
|
||||
d->prefix.select = handle_downable_button("Select"); \
|
||||
igSameLine(0, 3); \
|
||||
d->prefix.menu = handle_downable_button("Menu"); \
|
||||
igSameLine(0, 3); \
|
||||
igCheckbox("Active", &d->prefix.active); \
|
||||
handle_input(&d->prefix); \
|
||||
} while (false)
|
||||
|
||||
#define CURL(prefix, name, index) igDragFloat(#prefix "." #name, &d->prefix.hand_curl[index], 0.01, 0.0, 1.0, "%f", 0);
|
||||
|
|
Loading…
Reference in a new issue