Class StreamDeck
java.lang.Object
de.rcblum.stream.deck.device.StreamDeck
- All Implemented Interfaces:
IStreamDeck, purejavahidapi.InputReportListener
Provides low level access to a connected stream deck. Allows to do the
following without having to deal with the HID format:
1. Reset the device
2. Set the brightness of the device
3. Set an image for one of the key at a time.
4. Receive an
For the device to properly function, it has to be initialised properly. This is done by 1.) resetting it, 2) setting the brightness of the device.
All processing is don asynchronous, meaning anything sent to the deck is put in a queue and processed in another thread. Processing is done at a tick rate of 100 (100 updates per second max).
MIT License
Copyright (c) 2017 Roland von Werden
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1. Reset the device
2. Set the brightness of the device
3. Set an image for one of the key at a time.
4. Receive an
KeyEvent whenever a key was
pressed/released/clicked.For the device to properly function, it has to be initialised properly. This is done by 1.) resetting it, 2) setting the brightness of the device.
All processing is don asynchronous, meaning anything sent to the deck is put in a queue and processed in another thread. Processing is done at a tick rate of 100 (100 updates per second max).
MIT License
Copyright (c) 2017 Roland von Werden
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Version:
- 1.0.0
- Author:
- Roland von Werden
-
Constructor Summary
ConstructorsConstructorDescriptionStreamDeck(DeckDescriptor descriptor, purejavahidapi.HidDevice streamDeck, int brightness) Creates a wrapper for the Stream Deck HID -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKey(int keyId, StreamItem item) Adds aStreamKeyListenerto the given indexbooleanaddKeyListener(StreamKeyListener listener) Adds an StreamKeyListener to the ESD.voidaddToSendPool(DeckUpdater task) voidclearButton(int i) voiddrawFullImage(SDImage imgData) voidCreates a Job to send the give icon to the ESD to be displayed on the given keyxIndexvoidCreates a Job to send the give icon to the ESD to be displayed on the given keyxIndexvoiddrawTouchScreenImage(SDImage imgData) Creates a Job to send the give icon to the ESD to be displayed on the the Touch screen at the given starting pointvoiddrawTouchScreenImage(Point startPoint, SDImage imgData) Creates a Job to send the give icon to the ESD to be displayed on the the Touch screen at the given starting pointReturns the descriptor representing this devicegetDial(int keyIndex) Return the dials of the stream deck.DialKey[]getDials()Return the dials of the stream deck.purejavahidapi.HidDeviceReturns the Hid Devices representation the stream deck.getItems()getKey(int i) intReturns the amount of keys on the StreamDeck.intReturns the amount of rows on the StreamDeck.intReturn the touch screen of the stream deck.booleanhasDials()Returns if the stream deck has dialsbooleanReturns if the stream deck has a touch screenbooleanReturns if behind the interface is actual hardware or a software only StreamDeck.booleanbooleanbooleanvoidonInputReport(purejavahidapi.HidDevice source, byte reportID, byte[] reportData, int reportLength) voidpressButton(int no) Manually presses a button at the given id untilreleaseButton(int)is called.voidpushButton(int no) Manually Pushing a button at the given id.voidreleaseButton(int no) Manually releases a button at the given id.voidremoveKey(int keyId) Removes a registered Key.booleanremoveKeyListener(StreamKeyListener listener) Removes an StreamKeyListener from the ESD.voidreset()Queues a task to reset the stream deck.booleansendOutputReport(byte[] report) voidsetBrightness(int brightness) Sets the desired brightness from 0 - 100 % and queues the change.voidstop()Tells the background task for the stream deck to stop working.voidWait for all tasks to be executedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IStreamDeck
getColumnSize
-
Constructor Details
-
StreamDeck
Creates a wrapper for the Stream Deck HID- Parameters:
streamDeck- Stream Decks HID Devicesbrightness- Brightness from 0 .. 99
-
-
Method Details
-
getKeySize
public int getKeySize()Description copied from interface:IStreamDeckReturns the amount of keys on the StreamDeck.- Specified by:
getKeySizein interfaceIStreamDeck- Returns:
- Numbers of keys on the deck (Default 15).
-
getRowSize
public int getRowSize()Description copied from interface:IStreamDeckReturns the amount of rows on the StreamDeck.- Specified by:
getRowSizein interfaceIStreamDeck- Returns:
- Numbers of keys on the deck (Default 15).
-
addKey
Description copied from interface:IStreamDeckAdds aStreamKeyListenerto the given index- Specified by:
addKeyin interfaceIStreamDeck- Parameters:
keyId- Index of the key, 0..14item- StreamItem to be bound to the index
-
addKeyListener
Description copied from interface:IStreamDeckAdds an StreamKeyListener to the ESD. WHenever a Event is generated, the Listener will be informed.- Specified by:
addKeyListenerin interfaceIStreamDeck- Parameters:
listener- Listener to be added- Returns:
trueif listener was added,falseif listener is already registered.
-
removeKeyListener
Description copied from interface:IStreamDeckRemoves an StreamKeyListener from the ESD.- Specified by:
removeKeyListenerin interfaceIStreamDeck- Parameters:
listener- Listener to be removed- Returns:
trueif listener was removed,falseif listener is not registered.
-
drawImage
Description copied from interface:IStreamDeckCreates a Job to send the give icon to the ESD to be displayed on the given keyxIndex- Specified by:
drawImagein interfaceIStreamDeck- Parameters:
keyIndex- Index on the ESD as defined byDeckDescriptorimgData- Image to be displayed
-
drawImage
Description copied from interface:IStreamDeckCreates a Job to send the give icon to the ESD to be displayed on the given keyxIndex- Specified by:
drawImagein interfaceIStreamDeck- Parameters:
keyIndex- Index on the ESD as defined byDeckDescriptorimgData- Image to be displayedoverrideSize- Overrides the default icon size of the given streamdeck
-
drawFullImage
- Specified by:
drawFullImagein interfaceIStreamDeck
-
hasTouchScreen
public boolean hasTouchScreen()Description copied from interface:IStreamDeckReturns if the stream deck has a touch screen- Specified by:
hasTouchScreenin interfaceIStreamDeck- Returns:
- True if it has a touch screen, false if not
-
getTouchScreen
Description copied from interface:IStreamDeckReturn the touch screen of the stream deck.- Specified by:
getTouchScreenin interfaceIStreamDeck- Returns:
- Returns the touch screen object or null, if the stream deck has none.
-
hasDials
public boolean hasDials()Description copied from interface:IStreamDeckReturns if the stream deck has dials- Specified by:
hasDialsin interfaceIStreamDeck- Returns:
- True if it has one or more dials, false if not
-
getDials
Description copied from interface:IStreamDeckReturn the dials of the stream deck.- Specified by:
getDialsin interfaceIStreamDeck- Returns:
- Returns the dial objects or an empty array, if the stream deck has none.
-
getDial
Description copied from interface:IStreamDeckReturn the dials of the stream deck.- Specified by:
getDialin interfaceIStreamDeck- Parameters:
keyIndex- Index on the ESD as defined byDeckDescriptor- Returns:
- Returns the dial objects or an empty array, if the stream deck has none.
-
drawTouchScreenImage
Description copied from interface:IStreamDeckCreates a Job to send the give icon to the ESD to be displayed on the the Touch screen at the given starting point- Specified by:
drawTouchScreenImagein interfaceIStreamDeck- Parameters:
imgData- Image to be displayed
-
drawTouchScreenImage
Description copied from interface:IStreamDeckCreates a Job to send the give icon to the ESD to be displayed on the the Touch screen at the given starting point- Specified by:
drawTouchScreenImagein interfaceIStreamDeck- Parameters:
startPoint- Pixel coordinates to start drawing the imageimgData- Image to be displayed
-
sendOutputReport
public boolean sendOutputReport(byte[] report) -
getHidDevice
public purejavahidapi.HidDevice getHidDevice()Description copied from interface:IStreamDeckReturns the Hid Devices representation the stream deck.- Specified by:
getHidDevicein interfaceIStreamDeck- Returns:
- HidDevice representation the stream deck.
-
onInputReport
public void onInputReport(purejavahidapi.HidDevice source, byte reportID, byte[] reportData, int reportLength) - Specified by:
onInputReportin interfacepurejavahidapi.InputReportListener
-
removeKey
public void removeKey(int keyId) Description copied from interface:IStreamDeckRemoves a registered Key. Queues update to the stream deck- Specified by:
removeKeyin interfaceIStreamDeck- Parameters:
keyId- id of the key to be removed
-
reset
public void reset()Description copied from interface:IStreamDeckQueues a task to reset the stream deck.- Specified by:
resetin interfaceIStreamDeck
-
setBrightness
public void setBrightness(int brightness) Description copied from interface:IStreamDeckSets the desired brightness from 0 - 100 % and queues the change.- Specified by:
setBrightnessin interfaceIStreamDeck- Parameters:
brightness- Brightness in percentile
-
stop
public void stop()Description copied from interface:IStreamDeckTells the background task for the stream deck to stop working.- Specified by:
stopin interfaceIStreamDeck
-
waitForCompletion
public void waitForCompletion()Description copied from interface:IStreamDeckWait for all tasks to be executed- Specified by:
waitForCompletionin interfaceIStreamDeck
-
clearButton
public void clearButton(int i) - Specified by:
clearButtonin interfaceIStreamDeck- See Also:
-
getItems
-
isHardware
public boolean isHardware()Description copied from interface:IStreamDeckReturns if behind the interface is actual hardware or a software only StreamDeck.- Specified by:
isHardwarein interfaceIStreamDeck- Returns:
trueif hardware is sued,falseif the implementation is only software.
-
isRunning
public boolean isRunning() -
getDescriptor
Description copied from interface:IStreamDeckReturns the descriptor representing this device- Specified by:
getDescriptorin interfaceIStreamDeck- Returns:
- DeckDescriptor with the appropriate information
-
pushButton
public void pushButton(int no) Manually Pushing a button at the given id.- Specified by:
pushButtonin interfaceIStreamDeck- Parameters:
no- Number of the button to be pushed, 0 - 14, right top to left bottom.
-
pressButton
public void pressButton(int no) Manually presses a button at the given id untilreleaseButton(int)is called.- Specified by:
pressButtonin interfaceIStreamDeck- Parameters:
no- Number of the button to be pushed, 0 - 14, right top to left bottom.
-
releaseButton
public void releaseButton(int no) Manually releases a button at the given id. If the button is not pressed, it will be pushed instead.- Specified by:
releaseButtonin interfaceIStreamDeck- Parameters:
no- Number of the button to be pushed, 0 - 14, right top to left bottom.
-
isRecievePoolEmpty
public boolean isRecievePoolEmpty() -
getKey
-
pollRecievePool
-
getListeners
-
isSendPoolEmpty
public boolean isSendPoolEmpty() -
getSendPoolSize
public int getSendPoolSize() -
pollSendPool
-
addToSendPool
-