-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21dbf04
commit 0caac50
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from pynput.mouse import Button,Controller | ||
import socket | ||
import bs4 | ||
import time | ||
import math | ||
|
||
ip = '192.168.43.173' | ||
port = 5555 | ||
|
||
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) | ||
sock.bind((ip,port)) | ||
|
||
|
||
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)) | ||
single_click = sauce.find('lightintensity') | ||
mouse.move(-X*4,-Y*4) | ||
|
||
#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) | ||
|
||
while True: | ||
data,addr = sock.recvfrom(4800) | ||
#print(data) | ||
sensor_data() | ||
time.sleep(0) | ||
|
||
|