Skip to content

Instantly share code, notes, and snippets.

@squirelo
Last active March 17, 2025 15:46
Show Gist options
  • Save squirelo/9ea196b6a8be322ba0bed24282c8e187 to your computer and use it in GitHub Desktop.
Save squirelo/9ea196b6a8be322ba0bed24282c8e187 to your computer and use it in GitHub Desktop.
Durss websocket

Event-Driven JSON Structure Documentation

This document outlines the structure and types of events transmitted in the event-driven JSON format for gamepad, keyboard, and mouse inputs.

Example JSON Event Message

{
  "events": [
    {"type": "button", "code": "A", "value": true},
    {"type": "keyboard", "code": "space", "value": true},
    {"type": "axis", "code": "leftX", "value": 0.5},
    {"type": "trigger", "code": "leftTrigger", "value": 1.0},
    {"type": "mouseButton", "code": "leftClick", "value": true}
  ]
}

{
  "events": [
    {"type": "button", "code": "A", "value": true}
  ]
}
{
  "events": [
    {"type": "button", "code": "A", "value": false}
  ]
}

Event Types

Gamepad Button Events

  • Type: button
  • Properties:
    • code: String - The specific gamepad button (A, B, X, Y, LEFT_SHOULDER, RIGHT_SHOULDER, LEFT_THUMB, RIGHT_THUMB, BACK, START, GUIDE, DPAD_UP, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT, LEFT_STICK_UP, LEFT_STICK_DOWN, LEFT_STICK_LEFT, LEFT_STICK_RIGHT, RIGHT_STICK_UP, RIGHT_STICK_DOWN, RIGHT_STICK_LEFT, RIGHT_STICK_RIGHT)
    • value: Boolean - Indicates whether the button is pressed (true) or released (false)

Axis Events

  • Type: axis
  • Properties:
    • code: String - The specific axis being reported (e.g., leftX, leftY, rightX, rightY, dpadHorz, dpadVert)
    • value: Number - Numeric value ranging from -1 to 1 indicating the position of the axis

Trigger Events

  • Type: trigger
  • Properties:
    • code: String - The specific trigger (e.g., leftTrigger, rightTrigger)
    • value: Number - Numeric value ranging from 0 to 1 indicating the pressure applied to the trigger

MouseButton Events

  • Type: mouseButton
  • Properties:
    • code: String - The specific mouse button (e.g., leftClick, middleClick, rightClick)
    • value: Boolean - Indicates whether the button is pressed (true) or released (false)

Keyboard Key Events

  • Type: keyboard
  • Properties:
    • code: String - The specific key code:
      • a through z (representing each letter of the alphabet)
      • 0 through 9 (representing the top row number keys)
      • numpad_0 through numpad_9 (representing the numeric keypad numbers)
      • backspace
      • delete
      • enter
      • tab
      • escape
      • up, down, left, right (arrow keys)
      • home
      • end
      • pageup, pagedown
      • f1 through f12 (function keys)
      • alt
      • control
      • shift
      • space
      • windows
      • play
      • pause
      • mute
      • fn
    • value: Boolean - Indicates whether the key is pressed (true) or released (false)

Get Twitchat Profile

{
  "events": [
    {"type": "GET_PROFILE_MAPPINGS", "profile": "Twitchat"}
  ]
}

Answer:

{
  "type": "PROFILE_MAPPINGS",
  "data": {
    "profile": "Twitchat",
    "mappings": [
      {
        "input": {
          "type": "",
          "code": "",
          "settings": {}
        },
        "output": {
          "type": "mouseButton",
          "code": "leftClick",
          "value": false
        },
        "description": "Left Click",
        "id": 23
      },
      {
        "description": "",
        "input": {
          "type": "",
          "code": ""
        },
        "output": {
          "type": "button",
          "code": "A",
          "value": false
        },
        "id": 24
      }
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment