The open source OpenXR runtime
0
fork

Configure Feed

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

t/ctl: Implement device IO toggling

authored by

Jakob Bornecrantz and committed by
Jakob Bornecrantz
691881f5 7b9d7091

+43 -17
+43 -17
src/xrt/targets/ctl/main.c
··· 20 20 MODE_GET, 21 21 MODE_SET_PRIMARY, 22 22 MODE_SET_FOCUSED, 23 + MODE_TOGGLE_IO, 23 24 } op_mode_t; 24 25 25 26 int ··· 51 52 } 52 53 53 54 printf( 54 - "id: %d\tact: %d\tdisp: " 55 - "%d\tfoc: %d\tovly: %d\tz: " 56 - "%d\tpid: " 57 - "%d\t %s\t\n", 58 - clients.ids[i], cs.session_active, cs.session_visible, 59 - cs.session_focused, cs.session_overlay, cs.z_order, cs.pid, 55 + "id: %d" 56 + "\tact: %d" 57 + "\tdisp: %d" 58 + "\tfoc: %d" 59 + "\tio: %d" 60 + "\tovly: %d" 61 + "\tz: %d" 62 + "\tpid: %d" 63 + "\t%s\n", 64 + clients.ids[i], // 65 + cs.session_active, // 66 + cs.session_visible, // 67 + cs.session_focused, // 68 + cs.io_active, // 69 + cs.session_overlay, // 70 + cs.z_order, // 71 + cs.pid, // 60 72 cs.info.application_name); 61 73 } 62 74 ··· 92 104 } 93 105 94 106 int 107 + toggle_io(struct ipc_connection *ipc_c, int client_id) 108 + { 109 + xrt_result_t r; 110 + 111 + r = ipc_call_system_toggle_io_device(ipc_c, client_id); 112 + if (r != XRT_SUCCESS) { 113 + printf("failed to set focused client to %d.\n", client_id); 114 + return 1; 115 + } 116 + 117 + return 0; 118 + } 119 + 120 + int 95 121 main(int argc, char *argv[]) 96 122 { 97 123 struct ipc_connection ipc_c; ··· 104 130 int s_val = 0; 105 131 106 132 opterr = 0; 107 - while ((c = getopt(argc, argv, "p:f:")) != -1) { 133 + while ((c = getopt(argc, argv, "p:f:i:")) != -1) { 108 134 switch (c) { 109 135 case 'p': 110 136 s_val = atoi(optarg); ··· 118 144 op_mode = MODE_SET_FOCUSED; 119 145 } 120 146 break; 121 - 147 + case 'i': 148 + s_val = atoi(optarg); 149 + if (s_val >= 0 && s_val < IPC_MAX_CLIENTS) { 150 + op_mode = MODE_TOGGLE_IO; 151 + } 152 + break; 122 153 case '?': 123 154 if (optopt == 's') { 124 155 fprintf(stderr, ··· 172 203 } 173 204 174 205 switch (op_mode) { 175 - case MODE_GET: 176 - exit(get_mode(&ipc_c)); 177 - break; 178 - case MODE_SET_PRIMARY: 179 - exit(set_primary(&ipc_c, s_val)); 180 - break; 181 - case MODE_SET_FOCUSED: 182 - exit(set_focused(&ipc_c, s_val)); 183 - break; 206 + case MODE_GET: exit(get_mode(&ipc_c)); break; 207 + case MODE_SET_PRIMARY: exit(set_primary(&ipc_c, s_val)); break; 208 + case MODE_SET_FOCUSED: exit(set_focused(&ipc_c, s_val)); break; 209 + case MODE_TOGGLE_IO: exit(toggle_io(&ipc_c, s_val)); break; 184 210 default: printf("Unrecognised operation mode.\n"); exit(1); 185 211 } 186 212 }