//=========================================== // 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") #define _MOUSED_SYS_CONF QString("/etc/rc.conf") #define _MOUSED_DEFAULT_CONF QString("/etc/defaults/rc.conf") using namespace sysadm; QJsonObject moused::listDevices(){ QJsonObject out; //First find all the active devices QDir dir("/var/run"); QStringList devsactive = dir.entryList(QStringList() << "moused-*.pid", QDir::Files, QDir::Name); for(int i=0; i=0 && args.length() > (index+1) ){ if(args[index+1].startsWith("1=")){ righthand = (args[index+1] == "1=1"); } else if(args[index+1].startsWith("4=")){ scrollinvert = (args[index+1] == "4=5"); } index = args.indexOf("-m", index+1); } out.insert("mouse_scroll_invert", scrollinvert ? "true" : "false" ); out.insert("hand_mode", righthand ? "right" : "left"); out.insert("virtual_scrolling", args.contains("-V") ? "true" : "false" ); index = args.indexOf("-A"); 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