Skip to content

Commit

Permalink
Exposed exponent and yx_ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucashsmello committed Apr 15, 2019
1 parent ac15f53 commit 08069c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/gimxAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions src/webAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}
Expand Down

0 comments on commit 08069c4

Please sign in to comment.