SteelSeries / gamesense-sdk

472 stars 146 forks source link

Event binding/registering always returning 400 #115

Closed ghost closed 3 years ago

ghost commented 3 years ago

I've been attempting to bind/register events, yet every time it returns 400 codes. I've tried example jsons and others, but nothing works.

Game registering has been working fine, just this is the problem Steelapp.TXT

import requests
import json
import time
import random
import os
import logging

#common variables
game = "A_GAME"
name = "aaaaaa_gmae"
event = "rand_num"
running = 0
headers = {"Content-Type":"application/json"}

def init():
    global sseAddress
    corePropsPath = os.getenv('PROGRAMDATA') + "/SteelSeries/SteelSeries Engine 3/coreProps.json"
    sseAddress = json.load(open(corePropsPath))["address"]
    # now de-register and register the app
    metadata = {"game": game}
    r = requests.post("http://" + sseAddress + "/remove_game", json=metadata, headers=headers)
    metadata = {"game": game, "game_display_name": name, "icon_color_id": 6}
    r = requests.post("http://"+sseAddress+"/game_metadata", json=metadata, headers=headers)
    # now add some handlers for new event
    color_handler = {"device-type": "keyboard", "zone": "main-keyboard", "mode": "context-color", "context-frame-key": "key-zone"}
    color_handler = {"game": game, "event": event}
    handlers = {"game": game, "event": event, "handlers": [color_handler]}
    r = requests.post("http://"+sseAddress+"/register_game_event", json=handlers, headers=headers)
    #r = send_event()

def send_event():
    while running == 0:
        eventData = {"game": game, "event": event, "data": {"frame": {"main-keyboard-color": {"red": random.randint(0,255), "green": random.randint(0,255), "blue": random.randint(0,255)}}}}
        r = requests.post("http://"+sseAddress+"/game_event", json=eventData, headers=headers)
        time.sleep(3)

logging.basicConfig(level=logging.DEBUG)

import http.client
http.client.HTTPConnection.debuglevel = 1

logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

requests.get('http://httpbin.org/headers')

r = init()

Thats the code I've been using, it's supposed to just change the main-keyboard zone to a random color every second. (python btw)

Any idea whats wrong? Thanks

JHunz commented 3 years ago

First thing I noticed is that your event names should also be using uppercase lettering

ghost commented 3 years ago

well, dang

thanks so much it worked perfectly