This application provides a touchscreen interface to control the StepMania game. It enables users to play the game using touchscreen devices as inputs.
- Dynamically determines touchscreen device paths based on physical IDs.
- Displays graphical buttons for game controls.
- Supports dual monitor setups.
- Simulates key presses in response to touchscreen events.
Currently running ITGMania with two of these touchscreens: https://www.amazon.com/ELECROW-Raspberry-Touchscreen-Monitor-HDMI-Compatible/dp/B07FDYXPT7/
On an Intel NUC running Ubuntu 22.04 LTS
- Python 3
- tkinkter
- pip
pygame
librarypyautogui
libraryevdev
library
- Clone this repository:
git clone https://github.com/thinkjk/touchscreen-control-stepmania.git
- Install pip and tkinter
sudo apt-get install python3-pip python3-tk
- Navigate to the cloned directory and install the required Python libraries:
pip3 install pygame pyautogui evdev
- For the application to access input devices, you need to grant the necessary permissions. This can be achieved by adding the current user to the
input
group. Note: After executing the command, you may need to log out and log back in for the changes to take effect.
Execute the following command:
sudo usermod -a -G input $USER
This application relies on the touchscreen to be in a fixed position. Please refer to the picture on how I set up my touchscreens.
To determine the physical ID of your touchscreen monitor, you'll need to use the evdev_monitor_list
script provided in this repository.
Run the script:
python3 evdev_monitor_list.py
The script will list all connected input devices, along with their paths, names, and physical IDs. Look for your touchscreen device in the list and note down its physical ID. This ID will be used to dynamically determine the device paths for touchscreens in the main application.
Note: Ensure you have the necessary permissions to access the input devices. If you encounter permission issues, refer to the "Granting Permissions for Input Devices" section in this README.
The control_panel.py
script contains predefined button mappings that correspond to keyboard keys for the game controls. If you wish to customize these mappings to better suit your setup or preferences, you can do so directly in the control_panel.py
file.
- Open the
control_panel.py
file in your preferred text editor and update theBUTTON_KEY_MAPPING
for each monitor as needed.
-
Before starting the game, you can use the provided startup script. This script ensures the proper order of operations and logs debug information to
/tmp/startup_log.txt
.To use the startup script:
chmod +x path_to_startup_script.sh
To run the touchscreen control panel for a specific monitor, execute:
python3 control_panel.py <monitor_number>
Replace <monitor_number>
with either 1
or 2
depending on the monitor you want to use.
- The program uses the
evdev
library to determine the device paths of the touchscreens based on their physical IDs. pygame
is used to display the game controls (buttons) on the touchscreen.- When a button is pressed on the touchscreen, the corresponding key press is simulated using
pyautogui
.
- Monitor Physical ID Finder:
- Retrieves and displays information about connected input devices.
- Startup Script:
- Launches the StepMania game and initializes the touchscreen control panels for both monitors.
- Game Code:
- Provides the main functionality of displaying the touchscreen interface and handling touch events.
Contributions are welcome! Please open an issue or submit a pull request if you have improvements or fixes.
Distributed under the MIT License. See LICENSE.txt
for more information.
- All images made by ESB Studio
- Model modified by Wei Chen Lin
- Add images
- Have touchscreen position be dynamic so the location isn't fixed in code
- Have an easier way to detect physical ID of the touchscreens