Skip to content

Commit

Permalink
implemented VST host independant timeout (time based)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrgraf committed Jan 26, 2021
1 parent 6349989 commit 8dc79c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions midiFromJoystick/midiFromJoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ void MidiFromJoystick::processMidiEvents(VstMidiEventVec *inputs, VstMidiEventVe
static BYTE lastPress = 0;
static BYTE lastExpr = 0;

static short timeOut = 0;
static DWORD timeOut = 0;
if (timeOut)
{
timeOut--;
return;
if (GetTickCount() > timeOut)
timeOut = 0;
else
return; // skip
}

XINPUT_STATE state;
Expand Down Expand Up @@ -362,7 +364,7 @@ void MidiFromJoystick::processMidiEvents(VstMidiEventVec *inputs, VstMidiEventVe
else
{
dbg("XInput Joystick " << (joystick+1) << " not found");
timeOut = 2000;
timeOut = GetTickCount() + 2000; // 2s
}
}

Expand Down
7 changes: 4 additions & 3 deletions midiUartBridge/midiUartBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,11 @@ void MidiUartBridge::processMidiEvents(VstMidiEventVec *inputs, VstMidiEventVec
curComPort = 0;
}

static short timeOut = 0;
static DWORD timeOut = 0;
if (timeOut)
{
timeOut--;
if (GetTickCount() > timeOut)
timeOut = 0;
}
else if (reqComPort) // open requested port
{
Expand All @@ -350,7 +351,7 @@ void MidiUartBridge::processMidiEvents(VstMidiEventVec *inputs, VstMidiEventVec
me.midiData[0] = MIDI_NOTEOFF | uartChannel; // "Error Message"
outputs[0].push_back(me);

timeOut = 2000;
timeOut = GetTickCount() + 2000; // 2s
}
else
curComPort = reqComPort;
Expand Down

0 comments on commit 8dc79c8

Please sign in to comment.