int32_t write(uint32_t start_index, uint32_t length, freepie_io_6dof_data *data_to_write) { auto error = check_conditions_and_init_memory(start_index, length); if(error < 0) return error; auto mapped_data = mapping.map(); for(auto i = start_index; i < length + start_index; i++) { mapped_data[i].data_id++; mapped_data[i].data = data_to_write[i - start_index]; } return 0; }
int32_t read(uint32_t start_index, uint32_t length, freepie_io_6dof_data *output) { auto error = check_conditions_and_init_memory(start_index, length); if(error < 0) return error; auto mapped_data = mapping.map(); int32_t new_values = 0; for(auto i = start_index; i < length + start_index; i++) { if(make_equal(data_ids[i], mapped_data[i].data_id)) continue; output[i - start_index] = mapped_data[i].data; new_values |= (1 << (i - start_index)); } return new_values; }