Skip to content

A high-level UI library for Elgato Stream Deck applications

Notifications You must be signed in to change notification settings

aetheryx/streamdeck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

streamdeck

out_1.mp4
const createCircle = (color: string, text: string = ''): JSX.Element => (
  <svg height={100} width={100}>
    <circle cx={50} cy={50} r={40} fill={color} />
    <text x="50%" y="67%" textAnchor="middle" fontSize={50}>
      {text}
    </text>
  </svg>
);

let startedAt: number;
let buttons: Array<{ button: Button; index: number }>;

client.on('keyDown', (button) => {
  startedAt ??= Date.now();

  if (buttons.length === 0 && button.coordinates.x === 2 && button.coordinates.y === 1) {
    button.setTitle('');
    return main();
  }

  if (button.index !== buttons[0].button.index) {
    const { index } = buttons.find(b => b.button.index === button.index);
    return button.setImage(createCircle('red', index.toString()));
  }

  if (buttons.shift().index !== client.buttons.length) {
    return button.setImage(createCircle('green'));
  }

  onFinish();
});

function main(): void {
  startedAt = null;
  buttons = [ ...client.buttons ]
    .sort(() => Math.random() - 0.5)
    .map((button, index) => ({ button, index: index + 1 }));

  for (const { index, button } of buttons) {
    button.setImage(createCircle('white', index.toString()));
  }
}

function onFinish(): void {
  for (const button of client.buttons) {
    button.setImage(<svg height={100} width={100} />);
  }

  const duration = Date.now() - startedAt;
  client.getButton({ x: 2, y: 1 }).setTitle(`${(duration / 1000).toFixed(2)}s`);
}

About

A high-level UI library for Elgato Stream Deck applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published