Difference between revisions of "Chroma"

From GiderosMobile
Line 9: Line 9:
 
A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.</translate>
 
A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.</translate>
  
[[File:Razer.png|thumb|left|Screenshot of plugin working with Razer Chroma emulator]]
+
[[File:Razer.png|thumb|Screenshot of plugin working with Razer Chroma emulator]]
 
<br/>
 
<br/>
  

Revision as of 14:49, 27 June 2020


Supported platforms: Platform html5.pngPlatform pc.png
Available since: Gideros 2020.6

Description

An interface for the RΛZΞR Chroma SDK

Device can be any of: "keyboard","mouse","headset","mousepad","keypad" or "chromalink". A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.

Screenshot of plugin working with Razer Chroma emulator


Examples

Example

pcall(function() require "json" end)

pcall(function() require "chroma" end)
if Chroma then
	print("Chroma successfully loaded")
	
	chroma=Chroma.new()

	chroma:clear("keyboard")
	local h=chroma:getHeight("keyboard")
	for y=1,h do
		for x=1,0xf do
			chroma:setColor("keyboard",x,y,(x*16)<<16)
			chroma:setColor("keyboard",31-x,y,(x*16)<<16)
		end
	end
	for loop=1,12 do
		chroma:setKey("f"..loop,0x100-(loop*0x10))
	end
	chroma:setKey({"w","up"},0xffffff)
	chroma:setKey({"z","down"},0xffffff)
	chroma:setKey({"a","left"},0xffffff)
	chroma:setKey({"s","right"},0xffffff)
end

frameCounter=0
test1=false

function gameLoop(e)
	frameCounter+=1
	if chroma and chroma:isReady() then
		if not test1 then
			chroma:effect("mouse","static",255<<8)
			chroma:effect("mousepad","static",255<<16)
			test1=true
		end
		chroma:colorScroll("keyboard",1,0,true)
	end
end

stage:addEventListener(Event.ENTER_FRAME,gameLoop)

Methods

chroma.new Initialises the plugin.
Chroma:getSession Gets the session id
Chroma:getTicks Gets the number of ticks (seconds) from the razer chroma server that you have been connected.
Chroma:isReady Returns true if Chroma has started and is ready to accept commands.
Chroma:getLastError Returns the last error number.
Chroma:getErrorText Returns the text representation of the error number.
Chroma:getWidth Returns the number of LED columns.
Chroma:getHeight Returns the number of LED rows.
Chroma:setKey Sets the LED colour for a specific key.
Chroma:setColor Basically this sets the colour for the LED at x,y on the device.
Chroma:getColor Returns the colour of the LED at x,y on the device.
Chroma:clear Basically sets all the LED colours on the device to a specific colour.
Chroma:flush Sends the wanted colours of the LEDs to the device.
Chroma:color This sets all the LED colours very quickly to a specific colour.
Chroma:colorScroll Scrolls the LED colours in a given direction.
Chroma:effect Sends raw effect data to the Chroma server.

Events

Constants