diff --git a/src/gimxAPI.py b/src/gimxAPI.py index 3e892fc..48f26fc 100644 --- a/src/gimxAPI.py +++ b/src/gimxAPI.py @@ -172,7 +172,7 @@ def stopGimx(): def GetConfigurationParameters(): """ If successful, returns a dict with all settings. - Current Valid settings are: 'sensibility', 'dzx' and 'dzy'. + Current Valid settings are: 'sensibility', 'dzx', 'dzy', 'yx_ratio', 'exp_x' and 'exp_y'. None is returned when failed. """ @@ -188,19 +188,19 @@ def GetConfigurationParameters(): data=bytearray(data)[1:] # first byte is always the packet code (4). #print ">%s<" % str(''.join('{:02x}'.format(x) for x in data)) config={} - config['sensibility'], config['dzx'], config['dzy']=struct.unpack('>fhh',data[0:8]) + config['sensibility'], config['dzx'], config['dzy'], config['yx_ratio'], config['exp_x'], config['exp_y']=struct.unpack('>fhhfff',data[0:20]) sock.close() return config except socket.timeout: sock.close() return None -def SetConfigurationParameters(sensibility=-1,dzx=32767,dzy=32767): +def SetConfigurationParameters(sensibility=-1,dzx=32767,dzy=32767,exp_x=-1,exp_y=-1,yx_ratio=-1): global GIMX_PORT - if(sensibility==-1 and dzx==32767 and dzy==32767): return + if(sensibility==-1 and dzx==32767 and dzy==32767 and exp_x==-1 and exp_y==-1 and yx_ratio==-1): return dest = ("127.0.0.1", GIMX_PORT) - data = bytearray(struct.pack('>Bfhh',3,sensibility,dzx,dzy)) + data = bytearray(struct.pack('>Bfhhfff',3,sensibility,dzx,dzy,yx_ratio,exp_x,exp_y)) sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP sock.sendto(data, dest) diff --git a/src/webAPI.py b/src/webAPI.py index 840cc79..aca2007 100644 --- a/src/webAPI.py +++ b/src/webAPI.py @@ -337,6 +337,9 @@ def post(self): sensibility=-1 dzx=32767 dzy=32767 + expx=-1 + expy=-1 + yxratio=-1 save=False fform=flask.request.form if 'sensibility' in fform: @@ -349,8 +352,14 @@ def post(self): save = fform['save'].lower()=='true' if((not save) and fform['save'].lower()!='false'): LOGGER.warning('Configurator: invalid value for save "%s"' % fform['save']) - - SetConfigurationParameters(sensibility,dzx,dzy) + if 'exp_x' in fform: + expx = float(fform['exp_x']) + if 'exp_y' in fform: + expy = float(fform['exp_y']) + if 'yx_ratio' in fform: + yxratio = float(fform['yx_ratio']) + + SetConfigurationParameters(sensibility,dzx,dzy,expx,expy,yxratio) if(save): saveConfigurationParameters() return {'return_code':0}