A simple cross-platform desktop application built with Go and Fyne to count gamepad button presses. It features a resizable window, a large display for the count, a reset button, and a user-configurable button mapping mode.
- Gamepad Button Counting: Increments a counter each time a configured gamepad button is pressed.
- Resizable UI: The application window can be resized, and the counter text scales accordingly.
- Reset Functionality: A "Reset Counter" button allows you to set the count back to zero at any time.
- Custom Button Configuration:
- Enter a special configuration mode by clicking the "Configure Buttons" button.
- In this mode, press any button on your gamepad to add it to the set of buttons that will be counted.
- Press the
ESC
key on your keyboard to save the new configuration and exit configuration mode.
- Status Display: A status bar provides feedback on gamepad connection and instructions during button configuration.
- Go: Version 1.18 or newer (as specified in
go.mod
). You can download Go from golang.org. - Gamepad/Joystick: A compatible gamepad or joystick connected to your computer.
- GCC or Clang: (For Fyne) Fyne has C dependencies, so a C compiler like GCC or Clang is needed. On macOS, this is typically provided by Xcode Command Line Tools. On Linux, install
build-essential
orgcc
. On Windows, TDM-GCC or MSYS2/MinGW is recommended.
-
Clone the Repository (or download the files): If this project were on Git, you would clone it. For now, ensure you have
main.go
andgo.mod
in a directory (e.g.,gocounter
). -
Navigate to the Project Directory: Open your terminal or command prompt and change to the directory where the project files are located:
cd path/to/gocounter
-
Run the Application: Execute the following command:
go run main.go
This command will compile and run the application. The necessary dependencies will be downloaded automatically if they are not already present (thanks to Go modules).
-
Start the Application: Run
go run main.go
as described above. -
Gamepad Detection:
- Upon starting, the application will attempt to detect a connected gamepad.
- The status bar at the bottom will display the name of the detected gamepad or "No gamepad detected. Connect & restart." if none is found.
-
Counting Button Presses:
- By default, the application is configured to count common face buttons (e.g., A, B, X, Y on an Xbox controller or their equivalents like Cross, Circle, Square, Triangle on a PlayStation controller).
- Pressing any of these configured buttons will increment the counter displayed in large yellow text.
-
Resetting the Counter:
- Click the "Reset Counter" button to set the displayed count back to 0.
-
Configuring Custom Buttons:
- Click the "Configure Buttons" button. The application will enter button configuration mode.
- The status bar will change to: "Config: Press desired buttons. Press ESC on keyboard when done."
- Press each button on your gamepad that you want the application to count. Each time you press a new button, the status bar will briefly confirm, e.g., "Added button X. Press more or ESC to finish."
- Once you have pressed all the buttons you wish to track, press the
ESC
key on your keyboard. - The application will save this new button configuration for the current session, reset the counter to 0, and exit configuration mode. The status bar will revert to showing the gamepad name.
- Now, only the buttons you selected during configuration will increment the counter.
The application relies on the following Go packages:
fyne.io/fyne/v2
: For the graphical user interface.github.com/0xcafed00d/joystick
: For gamepad input handling.
These dependencies are managed by Go modules and will be automatically downloaded when you build or run the project.
- "No gamepad detected":
- Ensure your gamepad is properly connected to your computer (USB or Bluetooth).
- Verify that your operating system recognizes the gamepad.
- If you connected the gamepad after starting the application, please restart the application.
- Application doesn't build/run (Fyne issues):
- Make sure you have a C compiler (GCC or Clang) installed and in your system's PATH. See Fyne's prerequisites: https://developer.fyne.io/started/