public void SysExAnswer(SysExMessage m) { byte[] message = m.Data; byte[] stopbytes = { 240, 0, 32, 41, 2, 24, 21, 247 }; if (isScrolling) { if (Enumerable.SequenceEqual(message, stopbytes)) { if (isScrollLooping == false) { isScrollLooping = false; isScrolling = false; } } else Console.WriteLine("SysEx received something, but not a Scrolling Stop Byte!"); } }
private void sysExAnswer(SysExMessage m) { byte[] msg = m.Data; byte[] stopBytes = { 240, 0, 32, 41, 2, 24, 21, 247 }; }
static public void ReceiveSysex(Midi.SysExMessage message) { System.Diagnostics.Debug.WriteLine("RX: " + BitConverter.ToString(message.Data) + " (" + message.Device.Name + ")"); byte[] data = new byte[message.Data.Length - 5]; Array.Copy(message.Data, 4, data, 0, message.Data.Length - 5); //foreach (byte thing in data) // System.Diagnostics.Debug.WriteLine("0x{0:X}", thing); uint index = 0; byte[] decoded = new byte[sysex_decoded_length((ushort)data.Length)]; ushort decoded_length = sysex_decode(decoded, data, (ushort)data.Length); switch ((MT)decoded[index++]) { case MT.SET_DATA: case MT.GET_DATA: break; case MT.SET_DATA_ACK: case MT.GET_DATA_ACK: switch ((DT)decoded[index++]) { case DT.HANDSHAKE: System.Diagnostics.Debug.WriteLine(message.Device.Name + " Available"); available_keyboards.Add(message.Device.Name); updateInput(); updateOutput(); break; case DT.DEFAULT_LAYER: if (Program.optionsWindow != null) { for (int i = 0; i < 8; i++) { if ((decoded[index] >> i & 1) == 1) { Program.optionsWindow.layer_labels[i].BackColor = System.Drawing.Color.FromName("ControlLightLight"); } else { Program.optionsWindow.layer_labels[i].BackColor = System.Drawing.Color.FromName("ControlLight"); } } } break; case DT.AUDIO: if (Program.optionsWindow != null) { Program.optionsWindow.UpdateAudio(Convert.ToBoolean(decoded[index])); } break; case DT.BACKLIGHT: if (Program.optionsWindow != null) { Program.optionsWindow.UpdateBacklight(Convert.ToBoolean(decoded[index])); } break; case DT.RGBLIGHT: if (Program.optionsWindow != null) { uint colordata = bytes_to_uint(decoded, index); rgb_state = new rgblight(colordata); Program.optionsWindow.UpdateRGBLight(rgb_state.enabled); Program.optionsWindow.UpdateRGBLightMode(rgb_state.mode); Program.optionsWindow.colorButton.BackColor = ColorFromAhsb(255, rgb_state.hue * 1f, rgb_state.sat / 255.0f, rgb_state.val / 255.0f); if (Program.optionsWindow.colorButton.BackColor.GetBrightness() > 0.5) { Program.optionsWindow.colorButton.ForeColor = System.Drawing.Color.Black; } else { Program.optionsWindow.colorButton.ForeColor = System.Drawing.Color.White; } } break; case DT.KEYMAP_OPTIONS: if (Program.optionsWindow != null) { uint keymap_data = decoded[index]; //System.Diagnostics.Debug.WriteLine("0x{0:X}", keymap_data); bool swap_control_capslock = ((keymap_data & 0x1) == 0x1); bool capslock_to_control = ((keymap_data >> 1 & 0x1) == 0x1); bool swap_lalt_lgui = ((keymap_data >> 2 & 0x1) == 0x1); bool swap_ralt_rgui = ((keymap_data >> 3 & 0x1) == 0x1); bool no_gui = ((keymap_data >> 4 & 0x1) == 0x1); bool swap_grave_esc = ((keymap_data >> 5 & 0x1) == 0x1); bool swap_backslash_backspace = ((keymap_data >> 6 & 0x1) == 0x1); bool nkro = ((keymap_data >> 7 & 0x1) == 0x1); for (int i = 0; i < 8; i++) { Program.optionsWindow.updateKeymapCheckbox(i, (((keymap_data >> i) & 1) == 1)); } } break; } break; case MT.SEND_DATA: switch ((DT)decoded[index++]) { case DT.UNICODE: uint unicode = decode_uint32_chunk(data, index); SendKeys.SendWait(char.ConvertFromUtf32((int)bytes_to_uint(decoded, index)).ToString()); break; } break; case MT.SEND_DATA_ACK: break; case MT.EXE_ACTION: break; case MT.EXE_ACTION_ACK: break; case MT.TYPE_ERROR: break; } }