Jelajahi Sumber

vive: use enums for packet ids instead of hardcoded numbers.

Lubosz Sarnecki 7 tahun lalu
induk
melakukan
cea6e709a6
3 mengubah file dengan 5 tambahan dan 4 penghapusan
  1. 1 1
      src/drv_htc_vive/packet.c
  2. 2 2
      src/drv_htc_vive/vive.c
  3. 2 1
      src/drv_htc_vive/vive.h

+ 1 - 1
src/drv_htc_vive/packet.c

@@ -80,7 +80,7 @@ bool vive_decode_config_packet(vive_config_packet* pkt,
 		return false;
 	}*/
 
-	pkt->report_id = 17;
+	pkt->report_id = VIVE_CONFIG_READ_PACKET_ID;
 	pkt->length = size;
 
 	unsigned char output[32768];

+ 2 - 2
src/drv_htc_vive/vive.c

@@ -327,7 +327,7 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 	int bytes;
 
 	LOGI("Getting feature report 16 to 39\n");
-	buffer[0] = 16;
+	buffer[0] = VIVE_CONFIG_START_PACKET_ID;
 	bytes = hid_get_feature_report(priv->imu_handle, buffer, sizeof(buffer));
 	printf("got %i bytes\n", bytes);
 	for (int i = 0; i < bytes; i++) {
@@ -339,7 +339,7 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 
 	int offset = 0;
 	while (buffer[1] != 0) {
-		buffer[0] = 17;
+		buffer[0] = VIVE_CONFIG_READ_PACKET_ID;
 		bytes = hid_get_feature_report(priv->imu_handle, buffer, sizeof(buffer));
 
  		memcpy((uint8_t*)packet_buffer + offset, buffer+2, buffer[1]);

+ 2 - 1
src/drv_htc_vive/vive.h

@@ -9,7 +9,8 @@
 
 typedef enum
 {
-	VIVE_CONFIG_DATA = 17,
+	VIVE_CONFIG_START_PACKET_ID = 16,
+	VIVE_CONFIG_READ_PACKET_ID = 17,
 	VIVE_IRQ_SENSORS = 32,
 } vive_irq_cmd;