size_t OSC_Base::_Send(osc_message* message) { if (message && message->header.path) { _tx(message->header.path, message->header.length); return message->header.length; } return 0; }
void GLView::OnKeyPress (int virtKey, int repeatCount) { return; VARIANTARG params[1]; ::VariantInit (params + 0); params[0].vt = VT_INT; params[0].intVal = virtKey; // invoke script method for the event m_pScriptHostDriver->GetScriptHost()->InvokeScriptMethod ( _tx("gls_keyPress"), params, sizeof(params)/sizeof(params[0]) ); }
void GLView::OnKeyUp (int virtKey) { // #TODO: enable this return; VARIANTARG params[1]; ::VariantInit (params + 0); params[0].vt = VT_INT; params[0].intVal = virtKey; // invoke script method for the event m_pScriptHostDriver->GetScriptHost()->InvokeScriptMethod ( _tx("gls_keyUp"), params, sizeof(params)/sizeof(params[0]) ); }
void GLView::OnMouseMove (int shift, int button, int x, int y) { PostMouseEvent (_tx("gls_mouseMove"), button, x, y); }
size_t OSC_Base::_Send(const char *path, const char *typestring, va_list ap) { const char *typestring_beginning = typestring; char *buffer; data_holder_type data_holder; uint32_t i; int position = 0; uint8_t *src, *dst; uint32_t total_length; va_list ap_size; for (i = 0; i < MAX_PATH_LENGTH && path[i]; i++); total_length = (i+4)&(~3); for (i = 0; i < MAX_TYPESTRING_LENGTH && typestring[i]; i++); total_length += (i+4)&(~3); // find the size of all the data members (and count the length of the typestring) va_copy(ap_size, ap); // we need to use va_args twice for (i = 0; i < MAX_TYPESTRING_LENGTH && typestring[i]; i++) { // get the first character out of the way switch (typestring[i]) { case 'c': // TYPE_CHARACTER; case 'i': // TYPE_INTEGER; case 'm': // TYPE_MIDI; case 'r': // TYPE_RGB; total_length+=4; data_holder.value_uint32 = va_arg(ap_size, uint32_t); break; case 'f': // TYPE_FLOAT; total_length+=4; data_holder.value_float = (float)va_arg(ap_size, double); break; case 'd': // TYPE_DOUBLE; case 'h': // TYPE_LONG; case 't': // TYPE_TIMETAG; total_length+=8; data_holder.value_sint64 = va_arg(ap_size, sint64_t); break; case 's': data_holder.value_string = va_arg(ap_size, char*); data_holder.length = strlen(data_holder.value_string); total_length += (data_holder.length+3)&(~3); break; // TYPE_STRING; case 'b': // TYPE_BLOB case 'B': data_holder.length = va_arg(ap_size, uint32_t); data_holder.value_blob = va_arg(ap_size, uint8_t*); total_length += 4 + (data_holder.length+3)&(~3); break; // TYPE_BLOB with the advanced length field } } va_end(ap_size); //total_length += (i+3)&(~3); buffer = (char*)local_tx_malloc(total_length); if (!buffer) return 0; memset(buffer, 0x00, total_length); memset(&data_holder, 0x00, sizeof(data_holder_type)); // name for (; position < total_length && *path != 0x00; position++) buffer[position] = *path++; buffer[position++] = 0x00; for (; (position & 0x03) != 0x00; position++) buffer[position] = 0x00; // typestring for (; position < total_length && *typestring != 0x00; position++) buffer[position] = *typestring++; buffer[position++] = 0x00; for (; (position & 0x03) != 0x00; position++) buffer[position] = 0x00; // now onto the data typestring = typestring_beginning; for (;position < total_length && *typestring != 0x00; typestring++) { // get the first character out of the way switch (*typestring) { case 'c': data_holder.value_uint32 = va_arg(ap, uint32_t); break; // TYPE_CHARACTER; case 'i': data_holder.value_sint32 = va_arg(ap, int); break; // TYPE_INTEGER; case 'd': data_holder.value_double = va_arg(ap, double); break; // TYPE_DOUBLE; case 'f': data_holder.value_float = (float)va_arg(ap, double); break; // TYPE_FLOAT; case 'm': data_holder.value_uint32 = va_arg(ap, uint32_t); break; // TYPE_MIDI; case 'r': data_holder.value_uint32 = va_arg(ap, uint32_t); break; // TYPE_COLOR; // please note, these are work-arounds to an issue where va_arg requires 64-bit variables // to be located on 8-byte boundaries while the stack pushes 64bit variables without this requirement. case 'h': data_holder.value_sint64 = va_arg(ap, sint64_t); break; case 't': data_holder.value_sint64 = va_arg(ap, sint64_t); break; case 's': data_holder.value_string = va_arg(ap, char*); break; // TYPE_STRING; case 'b': data_holder.length = va_arg(ap, uint32_t); data_holder.value_blob = va_arg(ap, uint8_t*); break; // TYPE_BLOB case 'B': data_holder.length = va_arg(ap, uint32_t); data_holder.value_blob = va_arg(ap, uint8_t*); data_holder.crc16 = 0;// TODO: crc16(0, data_holder.value_blob, (data_holder.shortlength << 2)); <<<<============================================== THIS NEEDS FIXING data_holder.marker = 1; break; // TYPE_BLOB with the advanced length field case 'F': break; // TYPE_FALSE; case 'I': break; // TYPE_IMPULSE; case 'N': break; // TYPE_NONE; case 'T': break; // TYPE_TRUE; case ',': break; } // now copy the data into place switch (*typestring) { case 'c': // TYPE_CHARACTER; case 'f': // TYPE_FLOAT; case 'i': // TYPE_INTEGER; case 'm': // TYPE_MIDI; case 'r': // TYPE_RGB; //*(uint32_t*)(&buffer[position]) = data_holder.value_uint32; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[3]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[2]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[1]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[0]; //position += 4; break; case 'd': // TYPE_DOUBLE; case 'h': // TYPE_LONG; case 't': // TYPE_TIMETAG; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[7]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[6]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[5]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[4]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[3]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[2]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[1]; *(uint8_t*)(&buffer[position++]) = data_holder.value_bytes[0]; //*(uint64_t*)(&buffer[position]) = data_holder.value_uint64; //position += 8; break; case 'b': // TYPE_BLOB; position += 4; src = (uint8_t*)data_holder.value_blob; dst = (uint8_t*)&buffer[position]; for (i = 0; i < (data_holder.length+3)>>2; i++) { dst[0] = src[3]; dst[1] = src[2]; dst[2] = src[1]; dst[3] = src[0]; dst+=4; src+=4; } position += (data_holder.length+3) & (~3); break; case 'B': // TYPE_BLOB; position += 4; src = (uint8_t*)data_holder.value_blob; dst = (uint8_t*)&buffer[position]; for (i = 0; i < data_holder.shortlength; i++) { dst[0] = src[3]; dst[1] = src[2]; dst[2] = src[1]; dst[3] = src[0]; dst+=4; src+=4; } position += (data_holder.length+3) & (~3); break; case 's': // TYPE_STRING; data_holder.length = 0; for (;position < total_length && *data_holder.value_blob;) { buffer[position++] = *data_holder.value_blob++; data_holder.length++; } buffer[position++] = 0x00; for (; position < total_length && (position & 0x03) != 0x00; position++) buffer[position] = 0x00; break; default: break; } } _tx(buffer, total_length); local_free(buffer); return total_length; }