60#ifndef WHITEBOARD_POSTER_STRING_CONVERSION
61#define WHITEBOARD_POSTER_STRING_CONVERSION
72#pragma clang diagnostic push
73#pragma clang diagnostic ignored "-Wunused-macros"
77#elif defined(__APPLE__)
78# include <machine/endian.h>
79# include <architecture/byte_order.h>
80# define bswap_16(x) NXSwapShort(x)
81# define bswap_32(x) NXSwapInt(x)
82# define bswap_64(x) NXSwapLongLong(x)
84# define bswap_16(x) __builtin_bswap16(x)
85# define bswap_32(x) __builtin_bswap32(x)
86# define bswap_64(x) __builtin_bswap64(x)
91#if (!defined(__BYTE_ORDER) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN)
92# if !defined(htonll) && !defined(ntohll)
93# define htonll(x) bswap_64(x)
94# define ntohll(x) bswap_64(x)
96# if !defined(htonl) && !defined(ntohl)
97# define htonl(x) bswap_32(x)
98# define ntohl(x) bswap_32(x)
100# if !defined(htons) && !defined(ntohs)
101# define htons(x) bswap_16(x)
102# define ntohs(x) bswap_16(x)
105# if !defined(htonll) && !defined(ntohll)
106# define htonll(x) (x)
107# define ntohll(x) (x)
109# if !defined(htonl) && !defined(ntohl)
113# if !defined(htons) && !defined(ntohs)
118#pragma clang diagnostic pop
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wunused-variable"
130 if (len >= bufferSize) {
133 switch (self->movementOptions) {
136 len += snprintf(descString + len, bufferSize - len,
"movementOptions=VRResting");
141 len += snprintf(descString + len, bufferSize - len,
"movementOptions=VRStanding");
146 len += snprintf(descString + len, bufferSize - len,
"movementOptions=VRWalking");
150 if (len >= bufferSize) {
153 len = gu_strlcat(descString,
", ", bufferSize);
154 if (len >= bufferSize) {
157 switch (self->walkingOptions) {
160 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=NUM_VR_CONTROL_WALKING_OPTIONS");
165 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementBack");
170 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementForward");
175 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementLeft");
180 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementRight");
185 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementRotateLeft");
190 len += snprintf(descString + len, bufferSize - len,
"walkingOptions=VRMovementRotateRight");
195#pragma clang diagnostic pop
203#pragma clang diagnostic push
204#pragma clang diagnostic ignored "-Wunused-variable"
206 if (len >= bufferSize) {
209 switch (self->movementOptions) {
212 len += snprintf(toString + len, bufferSize - len,
"VRResting");
217 len += snprintf(toString + len, bufferSize - len,
"VRStanding");
222 len += snprintf(toString + len, bufferSize - len,
"VRWalking");
226 if (len >= bufferSize) {
229 len = gu_strlcat(toString,
", ", bufferSize);
230 if (len >= bufferSize) {
233 switch (self->walkingOptions) {
236 len += snprintf(toString + len, bufferSize - len,
"NUM_VR_CONTROL_WALKING_OPTIONS");
241 len += snprintf(toString + len, bufferSize - len,
"VRMovementBack");
246 len += snprintf(toString + len, bufferSize - len,
"VRMovementForward");
251 len += snprintf(toString + len, bufferSize - len,
"VRMovementLeft");
256 len += snprintf(toString + len, bufferSize - len,
"VRMovementRight");
261 len += snprintf(toString + len, bufferSize - len,
"VRMovementRotateLeft");
266 len += snprintf(toString + len, bufferSize - len,
"VRMovementRotateRight");
271#pragma clang diagnostic pop
279 size_t temp_length = strlen(str);
280 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
285 char* var_str = &var_str_buffer[0];
287 char* key = &key_buffer[0];
294 if (index == 0 && str[0] ==
'{') {
300 for (
int i = index; i < length; i++) {
302 if (bracecount == 0 && str[i] ==
'=') {
307 if (bracecount == 0 && isspace(str[i])) {
314 if (bracecount == 0 && str[i] ==
',') {
324 if (bracecount < 0) {
329 if (i == length - 1) {
333 if (endKey >= startKey && endKey - startKey < length) {
334 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
335 key[(endKey - startKey) + 1] = 0;
339 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
340 var_str[(index - startVar) + 1] = 0;
346 if (strlen(key) > 0) {
347 if (0 == strcmp(
"movementOptions", key)) {
349 }
else if (0 == strcmp(
"walkingOptions", key)) {
359 if (strcmp(
"VRResting", var_str) == 0) {
360#pragma clang diagnostic push
361#pragma clang diagnostic ignored "-Wbad-function-cast"
363#pragma clang diagnostic pop
364 }
else if (strcmp(
"VRStanding", var_str) == 0) {
365#pragma clang diagnostic push
366#pragma clang diagnostic ignored "-Wbad-function-cast"
368#pragma clang diagnostic pop
369 }
else if (strcmp(
"VRWalking", var_str) == 0) {
370#pragma clang diagnostic push
371#pragma clang diagnostic ignored "-Wbad-function-cast"
373#pragma clang diagnostic pop
375#pragma clang diagnostic push
376#pragma clang diagnostic ignored "-Wbad-function-cast"
378#pragma clang diagnostic pop
384 if (strcmp(
"NUM_VR_CONTROL_WALKING_OPTIONS", var_str) == 0) {
385#pragma clang diagnostic push
386#pragma clang diagnostic ignored "-Wbad-function-cast"
388#pragma clang diagnostic pop
389 }
else if (strcmp(
"VRMovementBack", var_str) == 0) {
390#pragma clang diagnostic push
391#pragma clang diagnostic ignored "-Wbad-function-cast"
393#pragma clang diagnostic pop
394 }
else if (strcmp(
"VRMovementForward", var_str) == 0) {
395#pragma clang diagnostic push
396#pragma clang diagnostic ignored "-Wbad-function-cast"
398#pragma clang diagnostic pop
399 }
else if (strcmp(
"VRMovementLeft", var_str) == 0) {
400#pragma clang diagnostic push
401#pragma clang diagnostic ignored "-Wbad-function-cast"
403#pragma clang diagnostic pop
404 }
else if (strcmp(
"VRMovementRight", var_str) == 0) {
405#pragma clang diagnostic push
406#pragma clang diagnostic ignored "-Wbad-function-cast"
408#pragma clang diagnostic pop
409 }
else if (strcmp(
"VRMovementRotateLeft", var_str) == 0) {
410#pragma clang diagnostic push
411#pragma clang diagnostic ignored "-Wbad-function-cast"
413#pragma clang diagnostic pop
414 }
else if (strcmp(
"VRMovementRotateRight", var_str) == 0) {
415#pragma clang diagnostic push
416#pragma clang diagnostic ignored "-Wbad-function-cast"
418#pragma clang diagnostic pop
420#pragma clang diagnostic push
421#pragma clang diagnostic ignored "-Wbad-function-cast"
423#pragma clang diagnostic pop
431 }
while(index < length);
442 uint16_t bit_offset = 0;
446 for (b = (32 - 1); b >= 0; b--) {
448 uint16_t
byte = bit_offset / 8;
449 uint16_t bit = 7 - (bit_offset % 8);
450 unsigned long newbit = !!((movementOptions_nbo >> b) & 1U);
451 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
452 bit_offset = bit_offset + 1;
460 for (b = (32 - 1); b >= 0; b--) {
462 uint16_t
byte = bit_offset / 8;
463 uint16_t bit = 7 - (bit_offset % 8);
464 unsigned long newbit = !!((walkingOptions_nbo >> b) & 1U);
465 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
466 bit_offset = bit_offset + 1;
481 uint16_t bit_offset = 0;
484 for (b = (32 - 1); b >= 0; b--) {
486 uint16_t
byte = bit_offset / 8;
487 uint16_t bit = 7 - (bit_offset % 8);
488 char dataByte = src[byte];
489 unsigned char bitValue = (dataByte >> bit) & 1U;
491 bit_offset = bit_offset + 1;
499 for (b = (32 - 1); b >= 0; b--) {
501 uint16_t
byte = bit_offset / 8;
502 uint16_t bit = 7 - (bit_offset % 8);
503 char dataByte = src[byte];
504 unsigned char bitValue = (dataByte >> bit) & 1U;
506 bit_offset = bit_offset + 1;
WHITEBOARD_POSTER_STRING_CONVERSION.
enum VRControlMovementOptions movementOptions
controls the robots movement
enum VRControlWalkingOptions walkingOptions
controls the direction of high-level walk commands
const char * wb_gu_vr_teleop_vulkan_control_description(const struct wb_gu_vr_teleop_vulkan_control *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_gu_vr_teleop_vulkan_control_from_network_serialised(const char *src, struct wb_gu_vr_teleop_vulkan_control *dst)
Convert from a compressed, serialised, network byte order byte stream.
size_t wb_gu_vr_teleop_vulkan_control_to_network_serialised(const struct wb_gu_vr_teleop_vulkan_control *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
struct wb_gu_vr_teleop_vulkan_control * wb_gu_vr_teleop_vulkan_control_from_string(struct wb_gu_vr_teleop_vulkan_control *self, const char *str)
Convert from a string.
const char * wb_gu_vr_teleop_vulkan_control_to_string(const struct wb_gu_vr_teleop_vulkan_control *self, char *toString, size_t bufferSize)
Convert to a string.
#define GU_VR_TELEOP_VULKAN_CONTROL_DESC_BUFFER_SIZE
@ NUM_VR_CONTROL_WALKING_OPTIONS