Nicolás de Ory

About meProjectsBlog

Project Firelight

RGB lighting software for Razer Chroma and other peripherals.

Many RGB lighting integrations for games are already available, but the main goal of this project is to improve the usability and ease of use for users, as well as to make it available for as many devices as possible.

Extensibility and modularity remain a priority; the idea is to design a layer that abstracts away vendor-specific interfaces for lighting devices, as well as provide some common utils to create new modules from scratch in hours, rather than days.

Technologies used

The project is written in C#, leveraging .NET Core to achieve a small memory footprint and fast performance.

This is what an example module looks like:

// We extend the class LEDModule to create a new module
public class BlinkWhiteModule : LEDModule
    {
        CancellationTokenSource masterCancelToken = new CancellationTokenSource();

        // Useful module to display common effects
        AnimationModule animation = AnimationModule.Create();

        public event LEDModule.FrameReadyHandler NewFrameReady;

        public static LEDModule Create()
        {
            return new BlinkWhiteModule();
        }

        private BlinkWhiteModule()
        {
            animation.NewFrameReady += FrameReceived;
            Task.Run(() => Blinker(500)).CatchExceptions();
        }

        // Bubble up the lighting event to the main frame queue to be processed by FirelightCore
        private void FrameReceived(LEDFrame frame)
        {
            NewFrameReady.Invoke(frame);
        }

        // Basic blinking effect every 500ms. It's run in another thread.
        public async Task Blinker(int intervalMS)
        {
            bool on = false;
            while (true)
            {
                if (masterCancelToken.IsCancellationRequested)
                    return;
                if (on)
                {
                    animation.HoldColor(HSVColor.Black, LightZone.All, 0.5f, true);
                    on = false;
                }
                else
                {
                    animation.HoldColor(new HSVColor(0.2f, 1f, 1f), LightZone.All, 0.5f, true);
                    on = true;
                }
                await Task.Delay(intervalMS);
            }
        }

        // Stop the blinker in case this module is no longer being used by the user
        public void Dispose()
        {
            masterCancelToken.Cancel();
        }
    }

Creating game integrations for a wide range of peripherals

The full API is still under construction so it's still subject to change, but the snippet above showcases the general idea. Because there is a very wide range of lighting devices in the market, instead of trying to support each of them individually, peripherals are classified into categories or light zones:

public enum LightZone
    {
        None = 0,
        Keyboard = 1, 
        Strip = 2, 
        Mouse = 4, 
        Mousepad = 8, 
        Headset = 16, 
        Keypad = 32, 
        General = 64,
        All = Keyboard | Strip | Mouse | Mousepad | Headset | Keypad | General,
        Desk = Keyboard | Mouse | Mousepad | Keypad,
        MouseKey = Keyboard | Mouse
    }

Each light zone contains a certain number of LEDs. For example, the Keyboard zone contains 109 LEDs, which is roughly how many regular RGB keyboards have. The General zone contains 5 LEDs, which allows addressing devices that don't fall into any of the other categories, such as gaming chairs, PC cases, or monitors.

This architecture allows creating integrations for games in a very modular way:

User Interface design

There's a user interface that lets users customize miscellaneous options, ranging from game-specific settings to lighting effect customization (i.e. what color the health bar should have, disable light effects for specific devices, etc.). The UI is currently written in HTML/CSS/Javascript, running inside .NET Core via Chromely, showcased below:

Featured at Razer DevCon

I was also extremely humbled to have the support of peripheral manufacturer Razer very early into the project, sending me a wide array of hardware to test effects with. I was also very happy and grateful to have the chance to showcase some of the game integrations in Razer DevCon 2021.

Back to top