Added connect and disconnect commands
This commit is contained in:
parent
f83c23b831
commit
849a276043
6 changed files with 62 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
IDIR=include
|
||||
SRCDIR=src
|
||||
ODIR=obj
|
||||
BINDIR=bin
|
||||
BINDIR=.
|
||||
|
||||
NAME = zmidimap
|
||||
|
||||
|
|
@ -9,9 +9,7 @@ LDFLAGS = -lpthread
|
|||
|
||||
CC=g++
|
||||
CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++17
|
||||
ifeq ($(RELEASE),true)
|
||||
BINDIR=.
|
||||
else
|
||||
ifeq ($(DEBUG),true)
|
||||
CXXFLAGS += -g
|
||||
endif
|
||||
|
||||
|
|
@ -37,3 +35,6 @@ clean:
|
|||
|
||||
clear:
|
||||
rm $(BINDIR)/$(NAME)
|
||||
|
||||
install:
|
||||
mv $(BINDIR)/$(NAME) /usr/bin
|
||||
14
README
14
README
|
|
@ -22,26 +22,26 @@ To scan a device's inputs use `$ aseqdump -p <client name>`
|
|||
|
||||
-- [COMMAND FORMAT] --
|
||||
|
||||
Format is a regular shell format
|
||||
Format is regular shell format
|
||||
|
||||
-- Environment
|
||||
|
||||
- Note
|
||||
[Note]
|
||||
$id: id of the note
|
||||
$channel: channel of the note
|
||||
$velocity: velocity of the note
|
||||
|
||||
- Controller
|
||||
[Controller]
|
||||
$value: value of the controller (remapped)
|
||||
$id: id of the controller
|
||||
$channel: channel of the controller
|
||||
$rawvalue: original value of the controller
|
||||
|
||||
- Pitch
|
||||
[Pitch]
|
||||
$value: value of the bend (remapped)
|
||||
$rawvalue: original value of the bend
|
||||
|
||||
- System
|
||||
[System]
|
||||
$code: hexadecimal code of the system signal
|
||||
|
||||
|
||||
|
|
@ -68,10 +68,10 @@ $code: hexadecimal code of the system signal
|
|||
-- COMMAND TAGS
|
||||
|
||||
[Global tags]
|
||||
type=<note/controller/pitch/system>
|
||||
type=<note/controller/pitch/system/connect/disconnect>
|
||||
shell=<shell command>
|
||||
--
|
||||
*type: type of the signal: note/controller/pitch
|
||||
*type: type of the signal: note/controller/pitch/system/connect/disconnect
|
||||
> mandatory
|
||||
*shell: shell command to be executed
|
||||
> mandatory
|
||||
|
|
|
|||
|
|
@ -47,6 +47,22 @@ public:
|
|||
std::string shell;
|
||||
};
|
||||
|
||||
class ConnectCommand
|
||||
{
|
||||
public:
|
||||
ConnectCommand(std::string const& sh);
|
||||
|
||||
std::string shell;
|
||||
};
|
||||
|
||||
class DisconnectCommand
|
||||
{
|
||||
public:
|
||||
DisconnectCommand(std::string const& sh);
|
||||
|
||||
std::string shell;
|
||||
};
|
||||
|
||||
class SystemCommand
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public:
|
|||
std::vector<ControllerCommand> ctrlCommands[128];
|
||||
std::vector<PitchCommand> pitchCommands;
|
||||
std::vector<SystemCommand> sysCommands;
|
||||
std::vector<ConnectCommand> connectCommands;
|
||||
std::vector<DisconnectCommand> disconnectCommands;
|
||||
|
||||
std::thread thread;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,16 @@ PitchCommand::PitchCommand(uint8_t ch, int16_t l, int16_t h, float ml, float mh,
|
|||
this->shell=sh;
|
||||
}
|
||||
|
||||
ConnectCommand::ConnectCommand(std::string const& sh)
|
||||
{
|
||||
this->shell=sh;
|
||||
}
|
||||
|
||||
DisconnectCommand::DisconnectCommand(std::string const& sh)
|
||||
{
|
||||
this->shell=sh;
|
||||
}
|
||||
|
||||
SystemCommand::SystemCommand(std::string const& sh)
|
||||
{
|
||||
this->shell=sh;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,18 @@ bool Device::import_chunk(Chunk const& ch)
|
|||
shell=tch["shell"].strval();
|
||||
this->sysCommands.push_back(SystemCommand(shell));
|
||||
}
|
||||
else if (tstr == "connect")
|
||||
{
|
||||
std::string shell;
|
||||
shell=tch["shell"].strval();
|
||||
this->connectCommands.push_back(ConnectCommand(shell));
|
||||
}
|
||||
else if (tstr == "disconnect")
|
||||
{
|
||||
std::string shell;
|
||||
shell=tch["shell"].strval();
|
||||
this->disconnectCommands.push_back(DisconnectCommand(shell));
|
||||
}
|
||||
else
|
||||
{
|
||||
int8_t channel;
|
||||
|
|
@ -401,11 +413,21 @@ void Device::loop(Device* dev)
|
|||
char* buff = NULL;
|
||||
size_t buff_size = 0;
|
||||
|
||||
for( auto it : dev->connectCommands )
|
||||
{
|
||||
std::thread(sh, it.shell).detach();
|
||||
}
|
||||
|
||||
while (getline(&buff, &buff_size, stream) > 0)
|
||||
{
|
||||
dev->run_signal(buff);
|
||||
}
|
||||
|
||||
for( auto it : dev->disconnectCommands )
|
||||
{
|
||||
std::thread(sh, it.shell).detach();
|
||||
}
|
||||
|
||||
printf("Device '%s' disconnected\n", dev->name.c_str());
|
||||
|
||||
pclose(stream);
|
||||
|
|
|
|||
Loading…
Reference in a new issue