Utilities

Device Utilities

device.color()

This function is your way of fetching color data from the canvas. It takes in an X,Y position relative to and within the device's pixel buffer on the canvas and returns an [R,G,B] array of the color at that pixel.

ParameterTypeDescriptionExample
XIntAn Int value representing the X coordinate within the Devices Pixel Buffer5
YIntAn Int value representing the Y coordinate within the Devices Pixel Buffer3
  • Note: the sent X,Y coordinates must be within the Pixel Buffer set by the Size() Export
ReturnTypeDescriptionExample
ColorArray1D ArrayA length 3 array containing the coordinated [R, G, B] values ranging from 0-255 (HEX 00-FF)[128,158,255]

Below is a cut-down example of the function being used in a typical situation.

Javascript
Copy

device.getBrightness()

Returns the devices current brightness level within SignalRGB. This value is already applied to any colors returned by device.color() or similar.

ReturnTypeDescriptionExample
BrightnessintCurrent brightness in the range 0-10042

device.getMotherboardName()

Returns the WMI name of the current systems motherboard.

ReturnTypeDescriptionExample
MotherboardNamestringSystem's motherboard nameB550 Aorus Elite

device.pause()

This function attempts to pause the device thread for the given length. These pauses are not guaranteed to be exact due to how the operating system handles thread sleeps.

ParameterTypeDescriptionExample
DurationIntRequested pause length in milliseconds1
  • Note: Windows has a minimum sleep time of 1-2ms and will start to break down as the sleep gets longer so don't use these for exact timings.
Javascript
Copy

device.set_endpoint()

This function changes the active endpoint for all read and write commands. This is useful for devices that have multiple open endpoints for different commands. A common example of this is Logitech devices which have an RGB data endpoint and a system command endpoint for things like DPI settings.

ParameterTypeDescriptionExample
interfaceHEXAn 0x Hex value representing the interface of the endpoint to open0x0002
usageHEXAn 0x Hex value representing the usage of the endpoint to open0x0006
usage_pageHEXAn 0x Hex value representing the usage_page of the endpoint to open0x0080
collectionHEXAn 0x Hex value representing the collection of the endpoint to open0x0001
Javascript
Copy

device.log()

This function is the plugin's version of console.log. It takes in a String, Number, Object, or Array and logs it in the device's console for debugging and user information. This can be especially useful to list things like DPI changes, errors, or during development to show your packets layout or input from read commands.

  • Note: This function will try to convert JavaScript variables to strings where It can. Logging JavaScript Template Literals using parseInt(), toString(), or JSON.stringify can give you more control over conversion and formatting.
ParameterTypeDescriptionExampleDefault
ItemJavascript ValueA string, number, array or other JavaScript value to be logged
OptionsJavaScript ObjectA Javascript object containing setting parameters{hex: True}{}
OptionsDescriptionTypeDefault
HexSets if integers should be printed in decimal or hex formatBooleanFalse
toFileSets if the printed items should appear in debug logs, or just the device's consoleBooleanFalse
Javascript
Copy

Alerts

Alerts can be used to visible prompt the user if there's an issue with their device. These should be used sparingly and reserved for show stopping issues like devices not being configured properly.

device.notify()

Creates an new alert for the user. The return value can be used to selectively remove the alert and should be done if the user fixes the alerted issue.

Alert text should be consistent in order to not spam the user with alerts.

Alert PriorityDescriptionValue
InfoNormal Alert0
ImportantCritical (Highlighted) Alert1
parametertypedescriptionExample
TitleStringAlert TitleFirmware Incompatible
DescriptionStringAlert DescriptionFirmware Version must be >= 2.0.0
PriorityIntAlert Priority0 | 1
returntypedescription
AlertIdStringThe created alerts Id string
Javascript
Copy

device.denotify()

Removes the given alert if it exists.

parametertypedescription
AlertIdStringAlertId returned by device.notify
Javascript
Copy

Messages

Device messages provide a way to relay important, but not show stopping information to the user. These messages will only appear on the device's page

device.addMessage()

Adds a new device message with the given MessageId.

parametertypedescriptionexample
messageIdstringMessageId tied to the device message"mymessage"
messagestringmessage text to be displayed"The message"
tooltipstringaddition text displayed on hover"Some more info"
Javascript
Copy

device.removeMessage()

Removes the message created with the given MessageId if one exists.

parametertypedescription
messageIdstringMessageId to be removed
Javascript
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard