Permalink
Browse files

Some minor whitespace and formatting tweaks.

  • Loading branch information...
1 parent 0126e40 commit 3f2782e59190be9d886240a36a4d19b29c4b2168 @bramp committed Jul 21, 2016
Showing with 9 additions and 23 deletions.
  1. +4 −12 src/libcec.cpp
  2. +3 −10 src/main.cpp
  3. +2 −1 src/main.h
View
@@ -34,6 +34,7 @@ using std::endl;
using std::map;
using std::ostream;
using std::string;
+using std::hex;
// cecloader has to be after some #includes and using namespaces :(
using std::cout;
@@ -157,7 +158,7 @@ Cec::~Cec() {}
void Cec::init()
{
- if (! cec)
+ if (!cec)
{
// LibCecInitialise is noisy, so we redirect cout to nowhere
RedirectStreamBuffer redirect(cout, 0);
@@ -205,7 +206,7 @@ void Cec::open(const std::string &name) {
}
// Just use the first found
- LOG4CPLUS_INFO(logger, "Openning " << devices[id].path);
+ LOG4CPLUS_INFO(logger, "Opening " << devices[id].path);
if (!cec->Open(devices[id].comm)) {
throw std::runtime_error("Failed to open adapter");
@@ -283,7 +284,7 @@ ostream & Cec::listDevices(ostream & out) {
cec_vendor_id vendor = (cec_vendor_id) cec->GetDeviceVendorId(logical_addres);
out << "\t" << cec->ToString(logical_addres)
- << "@" << physical_address
+ << " @ 0x" << hex << physical_address
<< " " << name.name << " (" << cec->ToString(vendor) << ")"
<< endl;
}
@@ -417,15 +418,6 @@ std::ostream& operator<<(std::ostream &out, const cec_keypress & key) {
}
std::ostream& operator<<(std::ostream &out, const cec_command & cmd) {
-// cec_logical_address initiator; /**< the logical address of the initiator of this message */
-// cec_logical_address destination; /**< the logical address of the destination of this message */
-// int8_t ack; /**< 1 when the ACK bit is set, 0 otherwise */
-// int8_t eom; /**< 1 when the EOM bit is set, 0 otherwise */
-// cec_opcode opcode; /**< the opcode of this message */
-// cec_datapacket parameters; /**< the parameters attached to this message */
-// int8_t opcode_set; /**< 1 when an opcode is set, 0 otherwise (POLL message) */
-// int32_t transmit_timeout; /**< the timeout to use in ms */
-
return out << "Command "
<< cmd.initiator << "->" << cmd.destination
<< "[" << (cmd.ack ? "A" : " ") << (cmd.eom ? "A" : " ") << "]"
View
@@ -72,7 +72,6 @@ Main::Main() : cec(getCecName(), this), uinput(UINPUT_NAME, uinputCecMap),
makeActive(true), running(false), lastUInputKeys({ }), logicalAddress(CECDEVICE_UNKNOWN)
{
LOG4CPLUS_TRACE_STR(logger, "Main::Main()");
-
}
Main::~Main() {
@@ -218,7 +217,7 @@ void Main::signalHandler(int sigNum) {
char *Main::getCecName() {
LOG4CPLUS_TRACE_STR(logger, "Main::getCecName()");
- if (gethostname(cec_name,HOST_NAME_MAX) < 0 ) {
+ if (gethostname(cec_name, HOST_NAME_MAX) < 0 ) {
LOG4CPLUS_TRACE_STR(logger, "Main::getCecName()");
strncpy(cec_name, CEC_NAME, sizeof(HOST_NAME_MAX));
}
@@ -519,14 +518,7 @@ void Main::onCecSourceActivated(const cec_logical_address & address, bool bActiv
LOG4CPLUS_DEBUG(logger, "Main::onCecSourceActivated(logicalAddress " << address << " = " << bActivated << ")");
if( logicalAddress == address )
{
- if( bActivated )
- {
- push(Command(COMMAND_ACTIVE));
- }
- else
- {
- push(Command(COMMAND_INACTIVE));
- }
+ push(Command(bActivated ? COMMAND_ACTIVE : COMMAND_INACTIVE));
}
}
@@ -577,6 +569,7 @@ int main (int argc, char *argv[]) {
("verbose,v", accumulator<int>(&loglevel)->implicit_value(1), "verbose output (use -vv for more)")
("quiet,q", "quiet output (print almost nothing)")
("donotactivate,a", "do not activate device on startup")
+
("onstandby", value<string>()->value_name("<path>"), "command to run on standby")
("onactivate", value<string>()->value_name("<path>"), "command to run on activation")
("ondeactivate", value<string>()->value_name("<path>"), "command to run on deactivation")
View
@@ -30,7 +30,7 @@ class Main : public CecCallback {
// Some config params
bool makeActive;
- bool running;
+ bool running; // TODO Change this to be threadsafe!. Voiatile or better
//
std::list<__u16> lastUInputKeys; // for key(s) repetition
@@ -80,6 +80,7 @@ class Main : public CecCallback {
void listDevices();
void setMakeActive(bool active) {this->makeActive = active;};
+
void setOnStandbyCommand(const std::string &cmd) {this->onStandbyCommand = cmd;};
void setOnActivateCommand(const std::string &cmd) {this->onActivateCommand = cmd;};
void setOnDeactivateCommand(const std::string &cmd) {this->onDeactivateCommand = cmd;};

0 comments on commit 3f2782e

Please sign in to comment.