Skip to content

Commit

Permalink
Merge pull request #3 from Gusted/master
Browse files Browse the repository at this point in the history
Right click added
  • Loading branch information
the-vishal authored Apr 27, 2019
2 parents 3f1f02c + 01e2be5 commit 30d4d1f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
58 changes: 30 additions & 28 deletions Air_Mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,50 @@
import time
import math

ip = '192.168.43.173'
ip = '192.168.1.17'
port = 5555

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((ip,port))


oldz = 9
mouse = Controller()

a = [0]
b = [0]

def sensor_data():

sauce = bs4.BeautifulSoup(data,'lxml')
x = sauce.find('accelerometer1')
X = int(float(x.text))
y = sauce.find('accelerometer2')
Y = int(float(y.text))
#z = sauce.find('accelerometer3')
#Z = int(float(z.text))
#print(X)
#print(Y)
#Pythagoras Theorem for 3rd axis
#h1 = int(math.sqrt(X**2 + Z**2))
#h2 = int(math.sqrt(Y**2 + Z**2))
z = sauce.find('accelerometer3')
Z = int(float(z.text))
print('X: ' + str(X))
print('Y: ' + str(Y))
print('Z: ' + str(Z))
single_click = sauce.find('lightintensity')
mouse.move(-X*4,-Y*4)
mouse.move(-X*6,Y*6)

#left click
if int(float(single_click.text)) <= 10:
mouse.click(Button.left)
mouse.release(Button.left)
#print("Right Click")

#print(x.text)
#print(y.text)

print("Left Click")

#right click
if oldz > Z:
if oldz - Z > 2:
mouse.click(Button.right)
mouse.release(Button.right)
print("Right Click")
else:
saveold()

def saveold():
sauce = bs4.BeautifulSoup(data,'lxml')
z = sauce.find('accelerometer3')
Z = int(float(z.text))
oldz = Z

while True:
data,addr = sock.recvfrom(4800)
#print(data)
sensor_data()
time.sleep(0)


rawdata = sock.recvfrom(port)
data = str(rawdata)
sensor_data()
time.sleep(0)
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ FREE Sensor Node Apk: <br />
https://play.google.com/store/apps/details?id=com.mscino.sensornode&hl=en.
![image](https://qph.fs.quoracdn.net/main-qimg-e29636d1e41654fd5b9367b1739f0ccc.webp)

1.Select Stream. <br />
2.Check Accelerometer and Light Intensity. <br />
3.Run the program. <br />
4.For moving mouse tilt mobile left,right,up and down. <br />
5.For right click cover the light sensor (@top front near speaker/front camera). <br />
6.In case of not responding or stuck, press ctrl+Alt+Del.
1. Select Stream. <br />
2. Check Accelerometer and Light Intensity. <br />
3. Run the program. <br />
4. For moving mouse tilt mobile left,right,up and down. <br />
5. For left click cover the light sensor (@top front near speaker/front camera). <br />
6. For right click Push you're device downwards(Make sure it's register it's has been down) and then go upwards with you're device.
7. In case of not responding or stuck, press ctrl+Alt+Del.



Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
beautifulsoup4==4.7.1
bs4==0.0.1
lxml==4.3.3

0 comments on commit 30d4d1f

Please sign in to comment.