update mumble link interface for version 1.2

This commit is contained in:
Ludwig Nussel 2010-01-04 14:12:18 +00:00
parent fc05ba7f46
commit f19d437564
2 changed files with 63 additions and 7 deletions

View file

@ -39,14 +39,26 @@
#include "libmumblelink.h" #include "libmumblelink.h"
#ifndef MIN
#define MIN(a, b) ((a)<(b)?(a):(b))
#endif
typedef struct typedef struct
{ {
uint32_t uiVersion; uint32_t uiVersion;
uint32_t uiTick; uint32_t uiTick;
float fPosition[3]; float fAvatarPosition[3];
float fFront[3]; float fAvatarFront[3];
float fTop[3]; float fAvatarTop[3];
wchar_t name[256]; 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; } LinkedMem;
static LinkedMem *lm = NULL; static LinkedMem *lm = NULL;
@ -103,17 +115,52 @@ int mumble_link(const char* name)
} }
void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3]) 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) if (!lm)
return; return;
memcpy(lm->fPosition, fPosition, sizeof(fPosition)); memcpy(lm->fAvatarPosition, fAvatarPosition, sizeof(fAvatarPosition));
memcpy(lm->fFront, fFront, sizeof(fFront)); memcpy(lm->fAvatarFront, fAvatarFront, sizeof(fAvatarFront));
memcpy(lm->fTop, fTop, sizeof(fTop)); memcpy(lm->fAvatarTop, fAvatarTop, sizeof(fAvatarTop));
lm->uiVersion = 1; memcpy(lm->fCameraPosition, fCameraPosition, sizeof(fCameraPosition));
memcpy(lm->fCameraFront, fCameraFront, sizeof(fCameraFront));
memcpy(lm->fCameraTop, fCameraTop, sizeof(fCameraTop));
lm->uiVersion = 2;
lm->uiTick = GetTickCount(); 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() void mumble_unlink()
{ {
if(!lm) if(!lm)

View file

@ -23,4 +23,13 @@
int mumble_link(const char* name); int mumble_link(const char* name);
int mumble_islinked(void); int mumble_islinked(void);
void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3]); 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); void mumble_unlink(void);