extended server example
This commit is contained in:
3
setup.py
3
setup.py
@@ -2,12 +2,13 @@ from setuptools import setup, find_packages
|
|||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from streamdeckapi.const import VERSION
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
|
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
|
||||||
long_description = "\n" + fh.read()
|
long_description = "\n" + fh.read()
|
||||||
|
|
||||||
VERSION = '0.0.3'
|
|
||||||
DESCRIPTION = 'Stream Deck API Library'
|
DESCRIPTION = 'Stream Deck API Library'
|
||||||
|
|
||||||
# Setting up
|
# Setting up
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"""Stream Deck API const."""
|
"""Stream Deck API const."""
|
||||||
|
|
||||||
|
VERSION = '0.0.3'
|
||||||
|
|
||||||
PLUGIN_PORT = 6153
|
PLUGIN_PORT = 6153
|
||||||
PLUGIN_INFO = "/sd/info"
|
PLUGIN_INFO = "/sd/info"
|
||||||
PLUGIN_ICON = "/sd/icon"
|
PLUGIN_ICON = "/sd/icon"
|
||||||
|
|||||||
@@ -3,9 +3,46 @@
|
|||||||
from StreamDeck.DeviceManager import DeviceManager
|
from StreamDeck.DeviceManager import DeviceManager
|
||||||
from streamdeckapi.const import PLUGIN_ICON, PLUGIN_INFO, PLUGIN_PORT
|
from streamdeckapi.const import PLUGIN_ICON, PLUGIN_INFO, PLUGIN_PORT
|
||||||
|
|
||||||
|
# Prints diagnostic information about a given StreamDeck.
|
||||||
|
def print_deck_info(index, deck):
|
||||||
|
image_format = deck.key_image_format()
|
||||||
|
|
||||||
|
flip_description = {
|
||||||
|
(False, False): "not mirrored",
|
||||||
|
(True, False): "mirrored horizontally",
|
||||||
|
(False, True): "mirrored vertically",
|
||||||
|
(True, True): "mirrored horizontally/vertically",
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Deck {} - {}.".format(index, deck.deck_type()))
|
||||||
|
print("\t - ID: {}".format(deck.id()))
|
||||||
|
print("\t - Serial: '{}'".format(deck.get_serial_number()))
|
||||||
|
print("\t - Firmware Version: '{}'".format(deck.get_firmware_version()))
|
||||||
|
print("\t - Key Count: {} (in a {}x{} grid)".format(
|
||||||
|
deck.key_count(),
|
||||||
|
deck.key_layout()[0],
|
||||||
|
deck.key_layout()[1]))
|
||||||
|
if deck.is_visual():
|
||||||
|
print("\t - Key Images: {}x{} pixels, {} format, rotated {} degrees, {}".format(
|
||||||
|
image_format['size'][0],
|
||||||
|
image_format['size'][1],
|
||||||
|
image_format['format'],
|
||||||
|
image_format['rotation'],
|
||||||
|
flip_description[image_format['flip']]))
|
||||||
|
else:
|
||||||
|
print("\t - No Visual Output")
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
streamdecks = DeviceManager().enumerate()
|
streamdecks = DeviceManager().enumerate()
|
||||||
|
|
||||||
print("Found {} Stream Deck(s).\n".format(len(streamdecks)))
|
print("Found {} Stream Deck(s).\n".format(len(streamdecks)))
|
||||||
|
|
||||||
print("Started Stream Deck API server on port", PLUGIN_PORT)
|
print("Started Stream Deck API server on port", PLUGIN_PORT)
|
||||||
|
|
||||||
|
for index, deck in enumerate(streamdecks):
|
||||||
|
deck.open()
|
||||||
|
deck.reset()
|
||||||
|
|
||||||
|
print_deck_info(index, deck)
|
||||||
|
|
||||||
|
deck.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user