Skip to content

Commit

Permalink
added hotkeys to randomize
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Mar 10, 2024
1 parent 203f713 commit efffad9
Show file tree
Hide file tree
Showing 6 changed files with 430 additions and 373 deletions.
58 changes: 57 additions & 1 deletion VortexEditor/VortexEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ bool VortexEditor::init(HINSTANCE hInst)
m_window.addCallback(ID_EDIT_CLEAR_PATTERN, handleMenusCallback);
m_window.addCallback(ID_OPTIONS_TRANSMIT_DUO, handleMenusCallback);
m_window.addCallback(ID_OPTIONS_TRANSMIT_INFRARED, handleMenusCallback);
m_window.addCallback(ID_OPTIONS_RECEIVE_FROM_DUO, handleMenusCallback);
m_window.addCallback(ID_EDIT_UNDO, handleMenusCallback);
m_window.addCallback(ID_EDIT_REDO, handleMenusCallback);
m_window.addCallback(ID_FILE_PULL, handleMenusCallback);
Expand Down Expand Up @@ -276,6 +277,20 @@ bool VortexEditor::init(HINSTANCE hInst)
{ FCONTROL | FVIRTKEY, 'U', ID_OPTIONS_TRANSMIT_DUO },
// ctrl + i
{ FCONTROL | FVIRTKEY, 'I', ID_OPTIONS_TRANSMIT_INFRARED },
// ctrl + k
{ FCONTROL | FVIRTKEY, 'K', ID_OPTIONS_RECEIVE_FROM_DUO },
// ctrl + 1
{ FCONTROL | FVIRTKEY, '1', ID_COLORSET_RANDOM_MONOCHROMATIC },
// ctrl + 2
{ FCONTROL | FVIRTKEY, '2', ID_COLORSET_RANDOM_COMPLIMENTARY },
// ctrl + 3
{ FCONTROL | FVIRTKEY, '3', ID_COLORSET_RANDOM_TRIADIC },
// ctrl + 4
{ FCONTROL | FVIRTKEY, '4', ID_COLORSET_RANDOM_SQUARE },
// ctrl + 5
{ FCONTROL | FVIRTKEY, '5', ID_COLORSET_RANDOM_PENTADIC },
// ctrl + 6
{ FCONTROL | FVIRTKEY, '6', ID_COLORSET_RANDOM_RAINBOW },
};
m_accelTable = CreateAcceleratorTable(accelerators, sizeof(accelerators) / sizeof(accelerators[0]));
if (!m_accelTable) {
Expand Down Expand Up @@ -401,6 +416,9 @@ void VortexEditor::handleMenus(uintptr_t hMenu)
case ID_OPTIONS_TRANSMIT_INFRARED:
transmitIR(nullptr);
return;
case ID_OPTIONS_RECEIVE_FROM_DUO:
receiveVL(nullptr);
return;
case ID_TOOLS_COLOR_PICKER:
m_colorPicker.show();
return;
Expand Down Expand Up @@ -915,7 +933,7 @@ void VortexEditor::pull(VWindow *window)
// now immediately tell it what to do
port->writeData(EDITOR_VERB_PULL_MODES);
stream.clear();
if (!port->readModes(stream) || !stream.size()) {
if (!port->readByteStream(stream) || !stream.size()) {
debug("Couldn't read anything");
return;
}
Expand Down Expand Up @@ -1120,6 +1138,44 @@ void VortexEditor::transmitIR(VWindow *window)
{
}

void VortexEditor::receiveVL(VWindow *window)
{
VortexPort *port = nullptr;
if (!isConnected() || !getCurPort(&port)) {
return;
}
int sel = m_modeListBox.getSelection();
if (sel < 0 || !isConnected()) {
return;
}
// now unserialize the stream of data that was read
ByteStream curMode;
if (!m_vortex.getCurMode(curMode) || curMode.size() <= 4) {
// error!
// TODO: abort
return;
}
// now immediately tell it what to do
port->writeData(EDITOR_VERB_LISTEN_VL);
// listen for he mode
ByteStream stream;
stream.clear();
if (!port->readByteStream(stream) || !stream.size()) {
debug("Couldn't read anything");
return;
}
m_vortex.setLedCount(2);
m_vortex.addNewMode(stream);
// read data again
port->expectData(EDITOR_VERB_LISTEN_VL_ACK);
// refresh
refreshModeList();
// select the new mode
m_modeListBox.setSelection(m_vortex.numModes() - 1);
m_ledsMultiListBox.setSelection(0);
refreshLedList();
}

void VortexEditor::selectMode(VWindow *window)
{
int sel = m_modeListBox.getSelection();
Expand Down
1 change: 1 addition & 0 deletions VortexEditor/VortexEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class VortexEditor
void exportMode(VWindow *window);
void transmitVL(VWindow *window);
void transmitIR(VWindow *window);
void receiveVL(VWindow *window);
void selectMode(VWindow *window);
void demoCurMode();
void clearDemo();
Expand Down
13 changes: 7 additions & 6 deletions VortexEditor/VortexEditor.rc
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ BEGIN
END
POPUP "Random Colorset"
BEGIN
MENUITEM "Monochromatic", ID_COLORSET_RANDOM_MONOCHROMATIC
MENUITEM "Complimentary", ID_COLORSET_RANDOM_COMPLIMENTARY
MENUITEM "Triadic", ID_COLORSET_RANDOM_TRIADIC
MENUITEM "Square", ID_COLORSET_RANDOM_SQUARE
MENUITEM "Pentadic", ID_COLORSET_RANDOM_PENTADIC
MENUITEM "Rainbow", ID_COLORSET_RANDOM_RAINBOW
MENUITEM "Monochromatic\tctrl+1", ID_COLORSET_RANDOM_MONOCHROMATIC
MENUITEM "Complimentary\tctrl+2", ID_COLORSET_RANDOM_COMPLIMENTARY
MENUITEM "Triadic\tctrl+3", ID_COLORSET_RANDOM_TRIADIC
MENUITEM "Square\tctrl+4", ID_COLORSET_RANDOM_SQUARE
MENUITEM "Pentadic\tctrl+5", ID_COLORSET_RANDOM_PENTADIC
MENUITEM "Rainbow\tctrl+6", ID_COLORSET_RANDOM_RAINBOW
END
END
POPUP "Tools"
Expand All @@ -101,6 +101,7 @@ BEGIN
BEGIN
MENUITEM "Transmit to Duo\tctrl+u", ID_OPTIONS_TRANSMIT_DUO
MENUITEM "Transmit Infrared\tctrl+i", ID_OPTIONS_TRANSMIT_INFRARED
MENUITEM "Receive from Duo\tctrl+k", ID_OPTIONS_RECEIVE_FROM_DUO
END
POPUP "Help"
BEGIN
Expand Down
Loading

0 comments on commit efffad9

Please sign in to comment.