private static void CleanExit(object sender, EventArgs e) { using (var deck = StreamDeck.FromHID()) { deck.ClearKeys(); } notifyIcon.Visible = false; Application.Exit(); Environment.Exit(1); }
private Business() { try { Deck = StreamDeck.FromHID(); Deck.KeyPressed += Deck_KeyPressed; } catch { //Application.Current.MainWindow.Dispatcher.BeginInvoke((Action)(() => //{ // MessageBox.Show("StreamDeck not connnedted."); //}), null); } }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; using (var deck = StreamDeck.FromHID()) { deck.SetBrightness(100); Console.WriteLine("Connected. Now press some keys on the Stream Deck."); deck.ClearKeys(); deck.KeyPressed += Deck_KeyPressed; Console.WriteLine("To close the console app press Ctrl + C"); exitSignal.WaitOne(); } }
static void Main(string[] args) { //Create some color we use later to draw the flag of austria var red = StreamDeckKeyBitmap.FromRGBColor(237, 41, 57); var white = StreamDeckKeyBitmap.FromRGBColor(255, 255, 255); var rowColors = new StreamDeckKeyBitmap[] { red, white, red }; //Open the Stream Deck device using (var deck = StreamDeck.FromHID()) { deck.SetBrightness(100); //Send the bitmap informaton to the device for (int i = 0; i < deck.NumberOfKeys; i++) { deck.SetKeyBitmap(i, rowColors[i / 5]); } } }
public DeckHandler() { //Load the default profile var path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/OpenStreamDeck/profiles/default.json"; try { CurrentProfile = ProfileManager.loadProfile(path); } catch (Exception e) { MessageBox.Show(String.Format("An error occurred while loading your default profile. Generating a new default profile. ({0})", e.Message)); if (CurrentProfile == null) { CurrentProfile = new Profile("Default"); ProfileManager.saveProfile(CurrentProfile); } } try { Deck = StreamDeck.FromHID(); } catch (Exception e) { //MessageBox.Show(String.Format("Cannot connect to StreamDeck ({0})", e.Message)); Debug.WriteLine("Cannot connect to StreamDeck {0}", e.Message); return; } Application.ApplicationExit += onApplicationExit; Deck.ClearKeys(); Deck.SetBrightness(DeckBrightness); Deck.KeyPressed += onKeyPressed; KeyPressedTimer = new System.Timers.Timer(); KeyPressedTimer.Interval = 10; KeyPressedTimer.Elapsed += onKeyHeld; CurrentPage = CurrentProfile.MainPage; PageStack = new Stack <Page>(); renderPage(); }
static void Run() { using (var deck = StreamDeck.FromHID()) { deck.SetBrightness(100); ///////////////////////// // -key locations- // // 4 3 2 1 0 // // 9 8 7 6 5 // // 14 13 12 11 10 // ///////////////////////// Console.WriteLine("Loading Keys..."); Keys.Add(new KeyList { KeyName = "Preview 1", KeyType = KEY_PREVIEW, Loc = 14, IconDisabled = "icons\\1_grey.png", IconEnabled = "icons\\1_green.png", Input = 1 }); Keys.Add(new KeyList { KeyName = "Preview 2", KeyType = KEY_PREVIEW, Loc = 13, IconDisabled = "icons\\2_grey.png", IconEnabled = "icons\\2_green.png", Input = 2 }); Keys.Add(new KeyList { KeyName = "Preview 3", KeyType = KEY_PREVIEW, Loc = 12, IconDisabled = "icons\\3_grey.png", IconEnabled = "icons\\3_green.png", Input = 3 }); Keys.Add(new KeyList { KeyName = "Preview 4", KeyType = KEY_PREVIEW, Loc = 11, IconDisabled = "icons\\4_grey.png", IconEnabled = "icons\\4_green.png", Input = 4 }); Keys.Add(new KeyList { KeyName = "Output 1", KeyType = KEY_OUTPUT, Loc = 9, IconDisabled = "icons\\1_grey.png", IconEnabled = "icons\\1_red.png", Input = 1 }); Keys.Add(new KeyList { KeyName = "Output 2", KeyType = KEY_OUTPUT, Loc = 8, IconDisabled = "icons\\2_grey.png", IconEnabled = "icons\\2_red.png", Input = 2 }); Keys.Add(new KeyList { KeyName = "Output 3", KeyType = KEY_OUTPUT, Loc = 7, IconDisabled = "icons\\3_grey.png", IconEnabled = "icons\\3_red.png", Input = 3 }); Keys.Add(new KeyList { KeyName = "Output 4", KeyType = KEY_OUTPUT, Loc = 6, IconDisabled = "icons\\4_grey.png", IconEnabled = "icons\\4_red.png", Input = 4 }); Keys.Add(new KeyList { KeyName = "Overlay 1", KeyType = KEY_OVERLAY, Loc = 4, IconDisabled = "icons\\1_grey.png", IconEnabled = "icons\\1_yel.png", Input = 1, Active = false }); Keys.Add(new KeyList { KeyName = "Overlay 2", KeyType = KEY_OVERLAY, Loc = 3, IconDisabled = "icons\\2_grey.png", IconEnabled = "icons\\2_yel.png", Input = 2, Active = false }); Keys.Add(new KeyList { KeyName = "Overlay 3", KeyType = KEY_OVERLAY, Loc = 2, IconDisabled = "icons\\3_grey.png", IconEnabled = "icons\\3_yel.png", Input = 3, Active = false }); Keys.Add(new KeyList { KeyName = "Stream", KeyType = KEY_STREAM, Loc = 1, IconDisabled = "icons\\stream_off.png", IconEnabled = "icons\\stream_on.png" }); Keys.Add(new KeyList { KeyName = "Record", KeyType = KEY_RECORD, Loc = 0, IconDisabled = "icons\\record_off.png", IconEnabled = "icons\\record_on.png" }); Keys.Add(new KeyList { KeyName = "Quick Play", KeyType = KEY_QUICKPLAY, Loc = 5, IconDisabled = "icons\\quickplay.png", IconEnabled = "icons\\quickplay.png" }); Keys.Add(new KeyList { KeyName = "Cut", KeyType = KEY_CUT, Loc = 10, IconDisabled = "icons\\cut.png", IconEnabled = "icons\\cut.png" }); deck.ClearKeys(); //Load keys foreach (KeyList KeyInit in Keys) { //combined += thing.Name; deck.SetKeyBitmap(KeyInit.Loc, StreamDeckKeyBitmap.FromFile(KeyInit.IconDisabled)); } Console.WriteLine("Keys loaded, doing update..."); Boolean status = UpdateKeyStatus(deck, true); //first update if (status) { Console.WriteLine("Connected. Performing initial key status update."); Console.WriteLine("Waiting for input."); } else { Console.WriteLine("vMix Connection Error, retrying...."); while (status == false) { status = UpdateKeyStatus(deck, true); } Console.WriteLine("Connected to vMix. Waiting for key input."); } //Console.WriteLine("keypress listen start"); deck.KeyPressed += Deck_KeyPressed; //listen for keypresses while (true) { Thread.Sleep(2000); //two second update to check for changes not triggered by a keypress UpdateKeyStatus(deck); //Console.WriteLine("Update keys LOOP."); } } }
static void Main(string[] args) { ///////////////////////// // -key locations- // // 4 3 2 1 0 // // 9 8 7 6 5 // // 14 13 12 11 10 // ///////////////////////// //Set key locations var key_location_hours = 8; var key_location_minutes = 7; var key_location_ampm = 6; //Attempt to initially give the buttom time to change the image before starting the loop to avoid display lag System.Threading.Thread.Sleep(500); //Open the Stream Deck device using (var deck = StreamDeck.FromHID()) { //Set loop while (true) { //Get the current time (hours, minutes and am/pm) string time_output_hours = DateTime.Now.ToString("hh"); string time_output_minutes = DateTime.Now.ToString("mm"); string time_output_ampm = DateTime.Now.ToString("tt"); //Check if hours string is not empty if (!string.IsNullOrEmpty(time_output_hours)) { //check if hours start with "0" if (time_output_hours.StartsWith("0")) { //remove starting "0" from string time_output_hours = time_output_hours.Remove(0, 1); } //send results to Set_Time to deal with Set_Time(time_output_hours, key_location_hours); } //Check if minutes string is not empty if (!string.IsNullOrEmpty(time_output_minutes)) { //send results to Set_Time to deal with Set_Time(time_output_minutes, key_location_minutes); } //Check if am/pm string is not empty if (!string.IsNullOrEmpty(time_output_ampm)) { //send results to Set_Time to deal with Set_Time(time_output_ampm, key_location_ampm); } //Wait 1 second before restarting loop System.Threading.Thread.Sleep(1000); //Check for key presses, if pressed send exit command deck.KeyPressed += Deck_KeyPressed; } void Set_Time(string time_result, int key_location) { //Set corresponding icons to the time of day string time_result_icon = time_result + ".png"; var clock_bitmap = StreamDeckKeyBitmap.FromFile("clock_icons\\" + time_result_icon); deck.SetKeyBitmap(key_location, clock_bitmap); } void Deck_KeyPressed(object sender, StreamDeckKeyEventArgs e) { //Kill console App Environment.Exit(0); } } }