From 1a9547a73a581afae5d9b38d21778b900aa1ff3d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 18 Jan 2017 16:41:31 -0500 Subject: [PATCH] Oops - forgot to add the new sysadm-moused files to git. --- src/server/library/sysadm-moused.cpp | 141 +++++++++++++++++++++++++++ src/server/library/sysadm-moused.h | 33 +++++++ 2 files changed, 174 insertions(+) create mode 100644 src/server/library/sysadm-moused.cpp create mode 100644 src/server/library/sysadm-moused.h diff --git a/src/server/library/sysadm-moused.cpp b/src/server/library/sysadm-moused.cpp new file mode 100644 index 0000000..c9a5f6b --- /dev/null +++ b/src/server/library/sysadm-moused.cpp @@ -0,0 +1,141 @@ +//=========================================== +// TrueOS source code +// Copyright (c) 2017, TrueOS Software/iXsystems +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "sysadm-general.h" +#include "sysadm-moused.h" +#include "sysadm-global.h" +#include "globals.h" + +#define _MOUSED_CONF QString("/etc/conf.d/moused") + +using namespace sysadm; + +QJsonObject moused::listDevices(){ + QJsonObject out; + QDir dir("/var/run"); + QStringList devs = dir.entryList(QStringList() << "moused-*.pid", QDir::Files, QDir::Name); + //qDebug() << "Found moused devices:" << devs; + for(int i=0; i=0 && args.length() > (index+1) ){ + if(args[index+1].startsWith("1=")){ righthand = (args[index+1] == "1=1"); } + index = args.indexOf("-m", index+1); + } + out.insert("hand_mode", righthand ? "right" : "left"); + out.insert("virtual_scrolling", args.contains("-V") ? "true" : "false" ); + + index = args.indexOf("-A"); + QString val = "1.0"; + if(index>=0 && args.length()>(index+1)){ val = args[index+1].section(",",0,0); } + out.insert("accel_exponential", val); + + index = args.indexOf("-a"); + val = "1.0"; + if(index>=0 && args.length()>(index+1)){ val = args[index+1].section(",",0,0); } + out.insert("accel_linear", val); + + index = args.indexOf("-r"); + val = "medium-low"; //Not sure about the actual default for moused resolution (not in the docs) - Ken Moore 1/18/17 + if(index>=0 && args.length()>(index+1)){ val = args[index+1]; } + out.insert("resolution", val); + + index = args.indexOf("-T"); + val = "0"; //disabled by default + if(index>=0 && args.length()>(index+1)){ val = args[index+1].section(",",0,0); } + out.insert("terminate_drift_threshold_pixels", val); + + //Now make sure to re-tag the output object with the device ID + out.insert("device", device); + return out; +} + +QJsonObject moused::setOptions(QJsonObject obj){ + QJsonObject Cobj = readOptions(obj); //will only use the "device" field of the input object + if(Cobj.keys().isEmpty()){ return Cobj; } //invalid inputs + //Overlay the user's settings on top of the current settings + QStringList keys = Cobj.keys(); + keys.removeAll("device"); + bool foundchange = false; + for(int i=0; i +#include "sysadm-global.h" + +namespace sysadm{ + +class moused{ +public: + static QJsonObject listDevices(); //List all individually-configurable devices + + //Service options for individual devices + static QJsonObject listOptions(); //list all the options and possible values + static QJsonObject readOptions(QJsonObject); //current values for device + static QJsonObject setOptions(QJsonObject); //change values for device + + //sysctl changes for classes of devices + /*static QJsonObject listSysctlDevices(); + static QJsonObject listSysctls(QJsonObject); + static QJsonObject readSysctls(QJsonObject); + static QJsonObject setSysctls(QJsonObject);*/ +}; + +} //end of namespace + +#endif