From 7f3780edf7c7bb59e2561a9254803e94f868c064 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Mon, 4 Jan 2010 23:44:04 +0000 Subject: * Merge ioq3-r1765 --- src/client/libmumblelink.c | 63 ++++++++++++++++++++++++++++++++++++++++------ src/client/libmumblelink.h | 9 +++++++ 2 files changed, 65 insertions(+), 7 deletions(-) (limited to 'src/client') diff --git a/src/client/libmumblelink.c b/src/client/libmumblelink.c index 07b0c1ea..1b1e521e 100644 --- a/src/client/libmumblelink.c +++ b/src/client/libmumblelink.c @@ -40,14 +40,26 @@ #include "libmumblelink.h" +#ifndef MIN +#define MIN(a, b) ((a)<(b)?(a):(b)) +#endif + typedef struct { uint32_t uiVersion; uint32_t uiTick; - float fPosition[3]; - float fFront[3]; - float fTop[3]; + float fAvatarPosition[3]; + float fAvatarFront[3]; + float fAvatarTop[3]; wchar_t name[256]; + /* new in mumble 1.2 */ + float fCameraPosition[3]; + float fCameraFront[3]; + float fCameraTop[3]; + wchar_t identity[256]; + uint32_t context_len; + unsigned char context[256]; + wchar_t description[2048]; } LinkedMem; static LinkedMem *lm = NULL; @@ -95,6 +107,8 @@ int mumble_link(const char* name) lm = (LinkedMem *) (mmap(NULL, sizeof(LinkedMem), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd,0)); if (lm == (void *) (-1)) { lm = NULL; + close(shmfd); + return -1; } close(shmfd); #endif @@ -104,17 +118,52 @@ int mumble_link(const char* name) } void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3]) +{ + mumble_update_coordinates2(fPosition, fFront, fTop, fPosition, fFront, fTop); +} + +void mumble_update_coordinates2(float fAvatarPosition[3], float fAvatarFront[3], float fAvatarTop[3], + float fCameraPosition[3], float fCameraFront[3], float fCameraTop[3]) { if (!lm) return; - memcpy(lm->fPosition, fPosition, sizeof(fPosition)); - memcpy(lm->fFront, fFront, sizeof(fFront)); - memcpy(lm->fTop, fTop, sizeof(fTop)); - lm->uiVersion = 1; + memcpy(lm->fAvatarPosition, fAvatarPosition, sizeof(fAvatarPosition)); + memcpy(lm->fAvatarFront, fAvatarFront, sizeof(fAvatarFront)); + memcpy(lm->fAvatarTop, fAvatarTop, sizeof(fAvatarTop)); + memcpy(lm->fCameraPosition, fCameraPosition, sizeof(fCameraPosition)); + memcpy(lm->fCameraFront, fCameraFront, sizeof(fCameraFront)); + memcpy(lm->fCameraTop, fCameraTop, sizeof(fCameraTop)); + lm->uiVersion = 2; lm->uiTick = GetTickCount(); } +void mumble_set_identity(const char* identity) +{ + size_t len; + if (!lm) + return; + len = MIN(sizeof(lm->identity), strlen(identity)+1); + mbstowcs(lm->identity, identity, len); +} + +void mumble_set_context(const unsigned char* context, size_t len) +{ + if (!lm) + return; + len = MIN(sizeof(lm->context), len); + memcpy(lm->context, context, len); +} + +void mumble_set_description(const char* description) +{ + size_t len; + if (!lm) + return; + len = MIN(sizeof(lm->description), strlen(description)+1); + mbstowcs(lm->description, description, len); +} + void mumble_unlink() { if(!lm) diff --git a/src/client/libmumblelink.h b/src/client/libmumblelink.h index 805b9850..fc4929ff 100644 --- a/src/client/libmumblelink.h +++ b/src/client/libmumblelink.h @@ -24,4 +24,13 @@ int mumble_link(const char* name); int mumble_islinked(void); void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3]); + +/* new for mumble 1.2: also set camera position */ +void mumble_update_coordinates2(float fAvatarPosition[3], float fAvatarFront[3], float fAvatarTop[3], + float fCameraPosition[3], float fCameraFront[3], float fCameraTop[3]); + +void mumble_set_description(const char* description); +void mumble_set_context(const unsigned char* context, size_t len); +void mumble_set_identity(const char* identity); + void mumble_unlink(void); -- cgit