Skip to content

Instantly share code, notes, and snippets.

@squirelo
Last active May 29, 2024 15:16
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": "gamepadButton", "button": "A", "state": true},
    {"type": "keyboard", "key": "space", "state": true},
    {"type": "axis", "axis": "leftX", "value": 0.5},
    {"type": "trigger", "trigger": "leftTrigger", "value": 1.0},
    {"type": "mouseButton", "button": "leftClick", "state": true}
  ]
}

{
  "events": [
    {"type": "gamepadButton", "button": "A", "state": true}
  ]
}
{
  "events": [
    {"type": "gamepadButton", "button": "A", "state": false}
  ]
}

Event Types

Gamepad Button Events

  • Type: gamepadButton
  • Properties:
    • button: 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).
    • state: Boolean - Indicates whether the button is pressed (true) or released (false).

Axis Events

  • Type: axis
  • Properties:
    • axis: 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:
    • trigger: 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:
    • button: String - The specific mouse button (e.g., leftClick, middleClick, rightClick).
    • state: Boolean - Indicates whether the button is pressed (true) or released (false).

Keyboard Key Events

  • Type: keyboard
  • Properties:
    • key:

      • 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
    • state: Boolean - Indicates whether the key is pressed (true) or released (false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment