SteelSeries / gamesense-sdk

472 stars 146 forks source link

Context Color doesn't work #92

Closed BestBoyBerlin closed 3 years ago

BestBoyBerlin commented 4 years ago

Is there a way of sending color instead of only sending an int value to the game_event endpoint? And if there is a way, is it required to configure the bind_game_event in a specific way?

JHunz commented 4 years ago

The "context-color" lighting mode allows you to always pull the color from the additional context data sent with the event. It's documented here: https://github.com/SteelSeries/gamesense-sdk/blob/master/doc/api/json-handlers-color.md#dynamic-color-via-context-data

BestBoyBerlin commented 4 years ago

I tried the "context-color" lighting, but it isn't working for me. The light just turns off, even when i was sending rgb color that should display just blue for example or even complete white.


import json
import requests
import time
import random

app = "CONTEXTCOLORTEST"
display_name = "ContextColorTest"
test_event = "TEST"

corePropsPath = "C:/ProgramData/SteelSeries/SteelSeries Engine 3/coreProps.json"
gamesense_url = json.load(open(corePropsPath))["address"]

def register_test():
    test_metadata = {
        "game": app,
        "game_display_name": display_name,
    }
    requests.post('http://'+gamesense_url+'/game_metadata', json=test_metadata)

def bind_test_event():
    test_handler = {
        "game": app,
        "event": test_event,
        "min_value": 0,
        "max_value": 255,
        "handlers": [
            {
                "mode": "context-color",
                "device-type": "rgb-zoned-device",
                "zone": "twenty",
                "context-frame-key": "zone-twenty-color"
            }
        ]
    }
    requests.post('http://'+gamesense_url+'/bind_game_event', json=test_handler)

def send_event(red, green, blue):
    event_data = {
        "game": app,
        "event": test_event,
        "data": {
            "frame": {
                "zone-twenty-color": {
                    "red": red,
                    "green": green,
                    "blue": blue
                }
            }
        }
    }
    requests.post('http://' + gamesense_url + '/game_event', json=event_data)

    register_test()
    bind_test_event()

    while True:
        red = random.randint(0, 255)
        green = random.randint(0, 255)
        blue = random.randint(0, 255)
        send_event(red, green, blue)
        time.sleep(5)
BestBoyBerlin commented 3 years ago

Latest version fixed the bug and it works now