d/daydream: fix button bindings
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2664>
34 unmodified lines353637383940414243444545464748484950515253544956505152535 unmodified lines59606162706364656667686970115 unmodified linesExpand all18618718818919419019119219319419519620119719819920020139 unmodified lines24124224324424925024524624724824925028 unmodified lines27928028128228728828929029128328428528628728828929029161 unmodified lines35335435535636136235735835936036136236336836937037137237337436436536636736836937037137237337437 unmodified lines34 unmodified lines * Indices where each input is in the input list. */enum daydream_input_index{ DAYDREAM_POSE, DAYDREAM_TOUCHPAD_CLICK, DAYDREAM_BAR_CLICK, DAYDREAM_CIRCLE_CLICK, DAYDREAM_VOLUP_CLICK, DAYDREAM_VOLDN_CLICK, DAYDREAM_TOUCHPAD,
DAYDREAM_INPUT_COUNT,};
/*! * Input package for Daydream. */struct daydream_input_packet{ uint8_t data[20];};
/* * * Smaller helper functions. *5 unmodified lines return (struct daydream_device *)xdev;}
static voiddaydream_update_input_click(struct daydream_device *daydream, int index, int64_t now, uint32_t bit)daydream_update_input_click(struct daydream_device *daydream, enum daydream_input_index index, int64_t now, uint32_t bit){
daydream->base.inputs[index].timestamp = now; daydream->base.inputs[index].value.boolean = (daydream->last.buttons & bit) != 0;115 unmodified linesExpand all uint8_t buffer[20]; struct daydream_parsed_input input; // = {0};
// wait for a package to sync up, it's discarded but that's okay. if (!daydream_read_one_packet(daydream, buffer, 20)) { if (!daydream_read_one_packet(daydream, buffer, ARRAY_SIZE(buffer))) { // Does null checking and sets to null. time_state_destroy(&time); return NULL; }
timepoint_ns then_ns = time_state_get_now(time); while (daydream_read_one_packet(daydream, buffer, 20)) { while (daydream_read_one_packet(daydream, buffer, ARRAY_SIZE(buffer))) {
timepoint_ns now_ns = time_state_get_now(time);
int num = daydream_parse_input(daydream, buffer, &input);39 unmodified lines{ out_relation->pose.orientation = daydream->fusion.rot;
//! @todo assuming that orientation is actually currently tracked. out_relation->relation_flags = (enum xrt_space_relation_flags)(XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT); out_relation->relation_flags = XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;}
static voiddaydream_device_destroy(struct xrt_device *xdev)28 unmodified lines // Lock the data. os_mutex_lock(&daydream->lock);
// clang-format off daydream_update_input_click(daydream, 1, now, DAYDREAM_TOUCHPAD_BUTTON_MASK); daydream_update_input_click(daydream, 2, now, DAYDREAM_BAR_BUTTON_MASK); daydream_update_input_click(daydream, 3, now, DAYDREAM_CIRCLE_BUTTON_MASK); daydream_update_input_click(daydream, 4, now, DAYDREAM_VOLDN_BUTTON_MASK); daydream_update_input_click(daydream, 5, now, DAYDREAM_VOLUP_BUTTON_MASK); daydream_update_input_click(daydream, DAYDREAM_TOUCHPAD_CLICK, now, DAYDREAM_TOUCHPAD_BUTTON_MASK); daydream_update_input_click(daydream, DAYDREAM_BAR_CLICK, now, DAYDREAM_BAR_BUTTON_MASK); daydream_update_input_click(daydream, DAYDREAM_CIRCLE_CLICK, now, DAYDREAM_CIRCLE_BUTTON_MASK); daydream_update_input_click(daydream, DAYDREAM_VOLUP_CLICK, now, DAYDREAM_VOLUP_BUTTON_MASK); daydream_update_input_click(daydream, DAYDREAM_VOLDN_CLICK, now, DAYDREAM_VOLDN_BUTTON_MASK); // clang-format on
daydream->base.inputs[DAYDREAM_TOUCHPAD].timestamp = now; float x = (daydream->last.touchpad.y / 255.0) * 2.0 - 1.0;61 unmodified lines
struct daydream_device *daydream_device_create(struct os_ble_device *ble){ enum u_device_alloc_flags flags = (enum u_device_alloc_flags)(U_DEVICE_ALLOC_TRACKING_NONE); struct daydream_device *dd = U_DEVICE_ALLOCATE(struct daydream_device, flags, 8, 0); struct daydream_device *dd = U_DEVICE_ALLOCATE(struct daydream_device, U_DEVICE_ALLOC_TRACKING_NONE, DAYDREAM_INPUT_COUNT, 0);
dd->base.name = XRT_DEVICE_DAYDREAM; dd->base.destroy = daydream_device_destroy; dd->base.update_inputs = daydream_device_update_inputs; dd->base.get_tracked_pose = daydream_device_get_tracked_pose; dd->base.inputs[0].name = XRT_INPUT_DAYDREAM_POSE; dd->base.inputs[1].name = XRT_INPUT_DAYDREAM_TOUCHPAD_CLICK; dd->base.inputs[2].name = XRT_INPUT_DAYDREAM_BAR_CLICK; dd->base.inputs[3].name = XRT_INPUT_DAYDREAM_CIRCLE_CLICK; dd->base.inputs[4].name = XRT_INPUT_DAYDREAM_VOLDN_CLICK; dd->base.inputs[5].name = XRT_INPUT_DAYDREAM_VOLUP_CLICK; dd->base.inputs[6].name = XRT_INPUT_DAYDREAM_TOUCHPAD; dd->base.inputs[DAYDREAM_POSE].name = XRT_INPUT_DAYDREAM_POSE; dd->base.inputs[DAYDREAM_TOUCHPAD_CLICK].name = XRT_INPUT_DAYDREAM_TOUCHPAD_CLICK; dd->base.inputs[DAYDREAM_BAR_CLICK].name = XRT_INPUT_DAYDREAM_BAR_CLICK; dd->base.inputs[DAYDREAM_CIRCLE_CLICK].name = XRT_INPUT_DAYDREAM_CIRCLE_CLICK; dd->base.inputs[DAYDREAM_VOLUP_CLICK].name = XRT_INPUT_DAYDREAM_VOLUP_CLICK; dd->base.inputs[DAYDREAM_VOLDN_CLICK].name = XRT_INPUT_DAYDREAM_VOLDN_CLICK; dd->base.inputs[DAYDREAM_TOUCHPAD].name = XRT_INPUT_DAYDREAM_TOUCHPAD; dd->base.binding_profiles = binding_profiles; dd->base.binding_profile_count = ARRAY_SIZE(binding_profiles);
static int controller_num = 0;37 unmodified lines