โ ๏ธ Windows computers only
An overview of the process for setting up CTS controllers to connect and output data onto a computer.
- For a brief overview of the project itself, visit this demo.
- Packages & Installations
- Visual Studio .NET Visualizer
- Connection to Socket
- Pygame Demos
- Pynput Keyboard Control
- Possible Problems
- Understanding CTS Controller
- Visual Studio (2019 or 2022)
- Node.js
- Arduino
- Teensyduino
- CMake
or run:
npm i install-cmake
- Python
- Pygame
or run:
python3 -m pip install -U pygame --user
- Pynput
Steps:
- Plug CTS controller into computer.
- Make sure Teensyduino is installed and connected to Arduino application, see photos below:
- Open Arduino file called
Teensy_3_6_Gain_Fireware
. - Make sure the port number is correctly assigned:
This is going to be some example code
Steps:
- Open Visual Studio BLANK project folder.
- Run BLANK file.
- Open
socket.py
file which uses the following to make a connection & recive data:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote_ip = socket.gethostname()
s.connect((remote_ip, 8888))
while True:
data = s.recv(1024)
sf = str(data).split(',')[0]
# Filter out digits from string data
only_digits = "".join([c for c in sf if c.isdigit()])
# Convert string data to float
f = int(only_digits)
print(f)
- No data on first try, run all programs again in same order.
- If input data is skewed, reflash the device by uploading the Arduino sketch again.
Steps:
- With pygame created, implement
socket.py
into pygame file. - Do this first (insert screenshot).
- Then put this here (insert screenshot).
- Set threshold depending on data values.
- Set controls using if statement threshold.
- Open Visual Studio BLANK project folder.
- Run BLANK file.
- Then, run pygame file.
- Connection should now be successful.
Steps:
- Create a new python file.
- Now put the following at the top:
import socket
from pynput.mouse import Button, Controller
- Implement
socket.py
into pynput file, for example:
import socket
from pynput.mouse import Button, Controller
# Mouse Stuff
mouse = Controller()
# Socket Stuff
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote_ip = socket.gethostname()
s.connect((remote_ip, 8888))
while True:
# Recieve data
data = s.recv(1024)
sf = str(data).split(',')[0]
# Filter out digits from string data
only_digits = "".join([c for c in sf if c.isdigit()])
# Convert string data to float
f = int(only_digits)
# Threshold range for CTS actions
if f < 430000:
mouse.scroll(0, -0.20)
# mouse.click(Button.left, 1)
if f > 590000:
mouse.scroll(0, 0.20)
- Specify threshold for controller data.
- Set controls using if statement threshold.
- Control scroll with the code below:
# Scroll down
mouse.scroll(0, -0.20)
# Scroll up
mouse.scroll(0, 0.20)
- Control mouse click with the code below:
# Single left click (2 for double click)
mouse.click(Button.left, 1)
# Single right click
mouse.click(Button.right, 1)