فهرست منبع

Enable LEDs for the CV1

Philipp Zabel 7 سال پیش
والد
کامیت
72023bd793
3فایلهای تغییر یافته به همراه11 افزوده شده و 4 حذف شده
  1. 3 2
      src/drv_oculus_rift/packet.c
  2. 3 1
      src/drv_oculus_rift/rift.c
  3. 5 1
      src/drv_oculus_rift/rift.h

+ 3 - 2
src/drv_oculus_rift/packet.c

@@ -222,7 +222,7 @@ int encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive)
 	return 5; // keep alive packet size
 }
 
-int encode_enable_components(unsigned char* buffer, bool display, bool audio)
+int encode_enable_components(unsigned char* buffer, bool display, bool audio, bool leds)
 {
 	uint8_t flags = 0;
 
@@ -233,7 +233,8 @@ int encode_enable_components(unsigned char* buffer, bool display, bool audio)
 		flags |= 1;
 	if (audio)
 		flags |= 2;
-//	flags |= 4; // I don't know what it is. Wireless?
+	if (leds)
+		flags |= 4;
 	WRITE8(flags);
 	return 4;
 }

+ 3 - 1
src/drv_oculus_rift/rift.c

@@ -292,9 +292,11 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 	// Turn the screens on
 	if (desc->revision == REV_CV1)
 	{
-		size = encode_enable_components(buf, true, true);
+		size = encode_enable_components(buf, true, true, true);
 		if (send_feature_report(priv, buf, size) == -1)
 			LOGE("error turning the screens on");
+
+		hid_write(priv->handle, rift_enable_leds_cv1, sizeof(rift_enable_leds_cv1));
 	}
 	else if (desc->revision == REV_DK2)
 	{

+ 5 - 1
src/drv_oculus_rift/rift.h

@@ -52,6 +52,10 @@ static const unsigned char rift_enable_leds_dk2[17] = {
 	0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x5E, 0x01, 0x1A, 0x41, 0x00, 0x00, 0x7F,
 };
 
+static const unsigned char rift_enable_leds_cv1[17] = {
+	0x0c, 0x00, 0x00, 0xFF, 0x05, 0x00, 0x8F, 0x01, 0x00, 0x4B, 0x00, 0x00, 0x7F,
+};
+
 typedef struct {
 	uint16_t command_id;
 	uint16_t accel_scale;
@@ -127,7 +131,7 @@ void vec3f_from_rift_vec(const int32_t* smp, vec3f* out_vec);
 
 int encode_sensor_config(unsigned char* buffer, const pkt_sensor_config* config);
 int encode_keep_alive(unsigned char* buffer, const pkt_keep_alive* keep_alive);
-int encode_enable_components(unsigned char* buffer, bool display, bool audio);
+int encode_enable_components(unsigned char* buffer, bool display, bool audio, bool leds);
 
 void dump_packet_sensor_range(const pkt_sensor_range* range);
 void dump_packet_sensor_config(const pkt_sensor_config* config);