From 3ce71302b7e1ef3dd2111ab7049cb85b90e0de2b Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 18 Mar 2018 15:58:41 -0230 Subject: [PATCH] Minor updates and commenting for PhysicalJoystickHandler. --- src/common/PJoystickHandler.cxx | 33 ++++++++++++++++++--------------- src/common/PJoystickHandler.hxx | 5 ++++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 7b19cba99..522b9ba27 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -49,21 +49,6 @@ PhysicalJoystickHandler::PhysicalJoystickHandler( } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PhysicalJoystickHandler::printDatabase() const -{ - cerr << "---------------------------------------------------------" << endl - << "joy database:" << endl; - for(const auto& i: myDatabase) - cerr << i.first << endl << i.second << endl << endl; - - cerr << "---------------------" << endl - << "joy active:" << endl; - for(const auto& i: mySticks) - cerr << i.first << ": " << *i.second << endl; - cerr << "---------------------------------------------------------" << endl << endl << endl; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int PhysicalJoystickHandler::add(PhysicalJoystickPtr stick) { @@ -721,6 +706,24 @@ VariantList PhysicalJoystickHandler::database() const return db; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh) +{ + os << "---------------------------------------------------------" << endl + << "joy database:" << endl; + for(const auto& i: jh.myDatabase) + os << i.first << endl << i.second << endl << endl; + + os << "---------------------" << endl + << "joy active:" << endl; + for(const auto& i: jh.mySticks) + os << i.first << ": " << *i.second << endl; + os << "---------------------------------------------------------" + << endl << endl << endl; + + return os; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Used by the Stelladaptor to send absolute axis values const Event::Type PhysicalJoystickHandler::SA_Axis[2][2] = { diff --git a/src/common/PJoystickHandler.hxx b/src/common/PJoystickHandler.hxx index be33a2792..94a13fb68 100644 --- a/src/common/PJoystickHandler.hxx +++ b/src/common/PJoystickHandler.hxx @@ -96,6 +96,7 @@ class PhysicalJoystickHandler return j ? j->hatTable[hat][int(value)][mode] : Event::NoType; } + /** Returns a list of pairs consisting of joystick name and associated ID. */ VariantList database() const; private: @@ -119,8 +120,10 @@ class PhysicalJoystickHandler return i != mySticks.cend() ? i->second : nullptr; } + // Set default mapping for given joystick when no mappings already exist void setStickDefaultMapping(int stick, Event::Type type, EventMode mode); - void printDatabase() const; + + friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh); // Static lookup tables for Stelladaptor/2600-daptor axis/button support static const Event::Type SA_Axis[2][2];