The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/wmr: Differentiate Odyssey+ controller

Switch the device name and input/binding mappings for
Odyssey+ controllers to differentiate them from OG WMR
controllers, allowing applications to load the correct
controller model

authored by

Jan Schmidt and committed by
Jakob Bornecrantz
7e18fac2 3d0c898e

+76 -25
+2 -1
src/xrt/drivers/wmr/wmr_controller.c
··· 16 16 struct wmr_controller_base * 17 17 wmr_controller_og_create(struct wmr_controller_connection *conn, 18 18 enum xrt_device_type controller_type, 19 + uint16_t pid, 19 20 enum u_logging_level log_level); 20 21 21 22 struct wmr_controller_base * ··· 36 37 37 38 switch (pid) { 38 39 case WMR_CONTROLLER_PID: 39 - case ODYSSEY_CONTROLLER_PID: ret = wmr_controller_og_create(conn, controller_type, log_level); break; 40 + case ODYSSEY_CONTROLLER_PID: ret = wmr_controller_og_create(conn, controller_type, pid, log_level); break; 40 41 case REVERB_G2_CONTROLLER_PID: ret = wmr_controller_hp_create(conn, controller_type, log_level); break; 41 42 default: break; 42 43 }
+74 -24
src/xrt/drivers/wmr/wmr_controller_og.c
··· 18 18 #include <assert.h> 19 19 #include <errno.h> 20 20 21 + #include "wmr_common.h" 21 22 #include "wmr_controller.h" 22 23 23 24 #ifdef XRT_DOXYGEN ··· 44 45 WMR_CONTROLLER_INDEX_AIM_POSE, 45 46 }; 46 47 47 - #define SET_INPUT(wcb, NAME) (wcb->base.inputs[WMR_CONTROLLER_INDEX_##NAME].name = XRT_INPUT_WMR_##NAME) 48 + #define SET_WMR_INPUT(wcb, NAME) (wcb->base.inputs[WMR_CONTROLLER_INDEX_##NAME].name = XRT_INPUT_WMR_##NAME) 49 + #define SET_ODYSSEY_INPUT(wcb, NAME) \ 50 + (wcb->base.inputs[WMR_CONTROLLER_INDEX_##NAME].name = XRT_INPUT_ODYSSEY_CONTROLLER_##NAME) 48 51 49 52 /* 50 53 * ··· 52 55 * 53 56 */ 54 57 55 - static struct xrt_binding_input_pair simple_inputs[4] = { 58 + static struct xrt_binding_input_pair simple_inputs_og[4] = { 56 59 {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_WMR_TRIGGER_VALUE}, 57 60 {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_WMR_MENU_CLICK}, 58 61 {XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_WMR_GRIP_POSE}, 59 62 {XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_WMR_AIM_POSE}, 60 63 }; 61 64 62 - static struct xrt_binding_output_pair simple_outputs[1] = { 65 + static struct xrt_binding_output_pair simple_outputs_og[1] = { 63 66 {XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_WMR_HAPTIC}, 64 67 }; 65 68 66 - static struct xrt_binding_profile binding_profiles[1] = { 69 + static struct xrt_binding_profile binding_profiles_og[1] = { 70 + { 71 + .name = XRT_DEVICE_SIMPLE_CONTROLLER, 72 + .inputs = simple_inputs_og, 73 + .input_count = ARRAY_SIZE(simple_inputs_og), 74 + .outputs = simple_outputs_og, 75 + .output_count = ARRAY_SIZE(simple_outputs_og), 76 + }, 77 + }; 78 + 79 + static struct xrt_binding_input_pair simple_inputs_odyssey[4] = { 80 + {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_ODYSSEY_CONTROLLER_TRIGGER_VALUE}, 81 + {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_ODYSSEY_CONTROLLER_MENU_CLICK}, 82 + {XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_ODYSSEY_CONTROLLER_GRIP_POSE}, 83 + {XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_ODYSSEY_CONTROLLER_AIM_POSE}, 84 + }; 85 + 86 + static struct xrt_binding_output_pair simple_outputs_odyssey[1] = { 87 + {XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_ODYSSEY_CONTROLLER_HAPTIC}, 88 + }; 89 + 90 + static struct xrt_binding_profile binding_profiles_odyssey[1] = { 67 91 { 68 92 .name = XRT_DEVICE_SIMPLE_CONTROLLER, 69 - .inputs = simple_inputs, 70 - .input_count = ARRAY_SIZE(simple_inputs), 71 - .outputs = simple_outputs, 72 - .output_count = ARRAY_SIZE(simple_outputs), 93 + .inputs = simple_inputs_odyssey, 94 + .input_count = ARRAY_SIZE(simple_inputs_odyssey), 95 + .outputs = simple_outputs_odyssey, 96 + .output_count = ARRAY_SIZE(simple_outputs_odyssey), 73 97 }, 74 98 }; 99 + 75 100 76 101 /* OG WMR Controller inputs struct */ 77 102 struct wmr_controller_og_input ··· 301 326 struct wmr_controller_base * 302 327 wmr_controller_og_create(struct wmr_controller_connection *conn, 303 328 enum xrt_device_type controller_type, 329 + uint16_t pid, 304 330 enum u_logging_level log_level) 305 331 { 306 332 DRV_TRACE_MARKER(); ··· 316 342 317 343 wcb->handle_input_packet = handle_input_packet; 318 344 345 + if (pid == ODYSSEY_CONTROLLER_PID) { 346 + wcb->base.name = XRT_DEVICE_SAMSUNG_ODYSSEY_CONTROLLER; 347 + } else { 348 + wcb->base.name = XRT_DEVICE_WMR_CONTROLLER; 349 + } 319 350 wcb->base.destroy = wmr_controller_og_destroy; 320 351 wcb->base.update_inputs = wmr_controller_og_update_xrt_inputs; 321 352 wcb->base.set_output = wmr_controller_og_set_output; 322 353 323 - SET_INPUT(wcb, MENU_CLICK); 324 - SET_INPUT(wcb, HOME_CLICK); 325 - SET_INPUT(wcb, SQUEEZE_CLICK); 326 - SET_INPUT(wcb, TRIGGER_VALUE); 327 - SET_INPUT(wcb, THUMBSTICK_CLICK); 328 - SET_INPUT(wcb, THUMBSTICK); 329 - SET_INPUT(wcb, TRACKPAD_CLICK); 330 - SET_INPUT(wcb, TRACKPAD_TOUCH); 331 - SET_INPUT(wcb, TRACKPAD); 332 - SET_INPUT(wcb, GRIP_POSE); 333 - SET_INPUT(wcb, AIM_POSE); 354 + if (pid == ODYSSEY_CONTROLLER_PID) { 355 + SET_ODYSSEY_INPUT(wcb, MENU_CLICK); 356 + SET_ODYSSEY_INPUT(wcb, HOME_CLICK); 357 + SET_ODYSSEY_INPUT(wcb, SQUEEZE_CLICK); 358 + SET_ODYSSEY_INPUT(wcb, TRIGGER_VALUE); 359 + SET_ODYSSEY_INPUT(wcb, THUMBSTICK_CLICK); 360 + SET_ODYSSEY_INPUT(wcb, THUMBSTICK); 361 + SET_ODYSSEY_INPUT(wcb, TRACKPAD_CLICK); 362 + SET_ODYSSEY_INPUT(wcb, TRACKPAD_TOUCH); 363 + SET_ODYSSEY_INPUT(wcb, TRACKPAD); 364 + SET_ODYSSEY_INPUT(wcb, GRIP_POSE); 365 + SET_ODYSSEY_INPUT(wcb, AIM_POSE); 366 + 367 + wcb->base.outputs[0].name = XRT_OUTPUT_NAME_ODYSSEY_CONTROLLER_HAPTIC; 368 + 369 + wcb->base.binding_profiles = binding_profiles_odyssey; 370 + wcb->base.binding_profile_count = ARRAY_SIZE(binding_profiles_odyssey); 371 + } else { 372 + SET_WMR_INPUT(wcb, MENU_CLICK); 373 + SET_WMR_INPUT(wcb, HOME_CLICK); 374 + SET_WMR_INPUT(wcb, SQUEEZE_CLICK); 375 + SET_WMR_INPUT(wcb, TRIGGER_VALUE); 376 + SET_WMR_INPUT(wcb, THUMBSTICK_CLICK); 377 + SET_WMR_INPUT(wcb, THUMBSTICK); 378 + SET_WMR_INPUT(wcb, TRACKPAD_CLICK); 379 + SET_WMR_INPUT(wcb, TRACKPAD_TOUCH); 380 + SET_WMR_INPUT(wcb, TRACKPAD); 381 + SET_WMR_INPUT(wcb, GRIP_POSE); 382 + SET_WMR_INPUT(wcb, AIM_POSE); 383 + 384 + wcb->base.outputs[0].name = XRT_OUTPUT_NAME_WMR_HAPTIC; 385 + 386 + wcb->base.binding_profiles = binding_profiles_og; 387 + wcb->base.binding_profile_count = ARRAY_SIZE(binding_profiles_og); 388 + } 334 389 335 390 for (uint32_t i = 0; i < wcb->base.input_count; i++) { 336 391 wcb->base.inputs[0].active = true; 337 392 } 338 393 339 394 ctrl->last_inputs.imu.timestamp_ticks = 0; 340 - 341 - wcb->base.outputs[0].name = XRT_OUTPUT_NAME_WMR_HAPTIC; 342 - 343 - wcb->base.binding_profiles = binding_profiles; 344 - wcb->base.binding_profile_count = ARRAY_SIZE(binding_profiles); 345 395 346 396 u_var_add_bool(wcb, &ctrl->last_inputs.menu, "input.menu"); 347 397 u_var_add_bool(wcb, &ctrl->last_inputs.home, "input.home");