Skip to content

Commit

Permalink
Merge branch 'dhobi/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
1kc committed Dec 19, 2020
2 parents 270c19b + 4e5068c commit 7715da0
Show file tree
Hide file tree
Showing 9 changed files with 549 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Laptops:

* Razer Blade Advanced 2018

Headphones:

* Razer Kraken V2

Please feel free to open pull requests for new devices you have tested.

## Roadmap
Expand Down
10 changes: 10 additions & 0 deletions src/driver/addon.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,15 @@ void HeadphoneSetModeNone(const Napi::CallbackInfo &info)
razer_headphone_attr_write_mode_none(headphoneDev, "1", 1);
}

void HeadphoneSetModeSpectrum(const Napi::CallbackInfo &info)
{
if (headphoneDev == NULL)
{
return;
}
razer_headphone_attr_write_mode_spectrum(headphoneDev, "1", 1);
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set("getKeyboardDevice", Napi::Function::New(env, GetKeyboardDevice));
exports.Set("closeKeyboardDevice", Napi::Function::New(env, CloseKeyboardDevice));
Expand Down Expand Up @@ -982,6 +991,7 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set("headphoneSetModeBreathe", Napi::Function::New(env, HeadphoneSetModeBreathe));
exports.Set("headphoneSetModeStatic", Napi::Function::New(env, HeadphoneSetModeStatic));
exports.Set("headphoneSetModeStaticNoStore", Napi::Function::New(env, HeadphoneSetModeStaticNoStore));
exports.Set("headphoneSetModeSpectrum", Napi::Function::New(env, HeadphoneSetModeSpectrum));

return exports;
}
Expand Down
1 change: 1 addition & 0 deletions src/driver/razerdevice.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ bool is_headphone(IOUSBDeviceInterface **usb_dev)
switch (product)
{
case USB_DEVICE_ID_RAZER_KRAKEN_KITTY_EDITION:
case USB_DEVICE_ID_RAZER_KRAKEN_V2:
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/driver/razerdevice.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "razermousemat_driver.h"
#include "razerheadphone_driver.h"
#include "razeregpu_driver.h"
#include "razerkraken_driver.h"

#define TYPE_KEYBOARD 0
#define TYPE_BLADE 1
Expand Down
34 changes: 29 additions & 5 deletions src/driver/razerheadphone_driver.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "razerheadphone_driver.h"
#include "razercommon.h"
#include "razerchromacommon.h"
#include "razerkraken_driver.h"

/**
* Send report to the headphone
Expand Down Expand Up @@ -66,7 +67,9 @@ ssize_t razer_headphone_attr_read_device_type(IOUSBDeviceInterface **usb_dev, ch
case USB_DEVICE_ID_RAZER_KRAKEN_KITTY_EDITION:
device_type = "Razer Kraken Kitty Edition\n";
break;

case USB_DEVICE_ID_RAZER_KRAKEN_V2:
device_type = "Razer Kraken V2\n";
break;
default:
device_type = "Unknown Device\n";
break;
Expand All @@ -92,7 +95,8 @@ ssize_t razer_headphone_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, con
report = razer_chroma_extended_matrix_effect_none(VARSTORE, ZERO_LED);
report.transaction_id.id = 0x1F;
break;

case USB_DEVICE_ID_RAZER_KRAKEN_V2:
return razer_kraken_attr_write_mode_none(usb_dev, buf, count);
default:
report = razer_chroma_standard_matrix_effect_none(VARSTORE, BACKLIGHT_LED);
break;
Expand Down Expand Up @@ -132,7 +136,14 @@ ssize_t razer_headphone_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, c
break;
}
break;

case USB_DEVICE_ID_RAZER_KRAKEN_V2:
// "Random" colour mode
if(count == 1) {
count = 3;
char color[3] = {(unsigned char)rand(), (unsigned char)rand(), (unsigned char)rand()};
return razer_kraken_attr_write_mode_breath(usb_dev, color, count);
}
return razer_kraken_attr_write_mode_breath(usb_dev, buf, count);
default:
switch(count) {
case 3: // Single colour mode
Expand Down Expand Up @@ -173,7 +184,8 @@ ssize_t razer_headphone_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, c
report = razer_chroma_extended_matrix_effect_static(VARSTORE, ZERO_LED, (struct razer_rgb *)&buf[0]);
report.transaction_id.id = 0x1F;
break;

case USB_DEVICE_ID_RAZER_KRAKEN_V2:
return razer_kraken_attr_write_mode_static(usb_dev, buf, count);
default:
report = razer_chroma_standard_matrix_effect_static(VARSTORE, BACKLIGHT_LED, (struct razer_rgb*)&buf[0]);
break;
Expand Down Expand Up @@ -207,7 +219,8 @@ ssize_t razer_headphone_attr_write_mode_static_no_store(IOUSBDeviceInterface **u
report = razer_chroma_extended_matrix_effect_static(VARSTORE, ZERO_LED, (struct razer_rgb *)&buf[0]);
report.transaction_id.id = 0x1F;
break;

case USB_DEVICE_ID_RAZER_KRAKEN_V2:
return razer_kraken_attr_write_mode_static(usb_dev, buf, count);
default:
report = razer_chroma_standard_matrix_effect_static(NOSTORE, BACKLIGHT_LED, (struct razer_rgb*)&buf[0]);
break;
Expand All @@ -218,5 +231,16 @@ ssize_t razer_headphone_attr_write_mode_static_no_store(IOUSBDeviceInterface **u
printf("razerheadphone: Static mode only accepts RGB (3byte)\n");
}

return count;
}

ssize_t razer_headphone_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count)
{
UInt16 product = -1;
(*usb_dev)->GetDeviceProduct(usb_dev, &product);
switch(product) {
case USB_DEVICE_ID_RAZER_KRAKEN_V2:
return razer_kraken_attr_write_mode_spectrum(usb_dev, buf, count);
}
return count;
}
1 change: 1 addition & 0 deletions src/driver/razerheadphone_driver.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ ssize_t razer_headphone_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, con
ssize_t razer_headphone_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count);
ssize_t razer_headphone_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count);
ssize_t razer_headphone_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count);
ssize_t razer_headphone_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count);

#endif
Loading

0 comments on commit 7715da0

Please sign in to comment.