-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix[SNESpad]: updates lib to latest with snes mouse to analog working…
… correctly
- Loading branch information
1 parent
1a4cea6
commit a718b80
Showing
5 changed files
with
239 additions
and
49 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
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 |
---|---|---|
@@ -1,22 +1,110 @@ | ||
# SNESpad for PicoSDK | ||
# SNESpad for Arduino and PicoSDK | ||
|
||
This is an extensive rewrite and port of the original SNESpad Arduino library to be compatible with the Pico SDK. This version of the library is designed to work with the GP2040-CE project. | ||
This is a library for the Raspberry Pi Pico that allows it to interface with a SNES controller. This library was adapted from the Arduino SNESpad library, with changes and optimizations made for better performance and compatibility with the Pico SDK. | ||
|
||
## Original Library | ||
|
||
This library is based on the [nespad](https://github.com/rahji/nespad) library developed by rahji. The original library was designed for the Arduino platform. | ||
|
||
## Features | ||
|
||
This library allows for the reading of button states from a SNES controller connected to a Pico or Arduino. It supports standard SNES controller, the NES controller, and the SNES Mouse. Each of these devices can be identified and read by this library. | ||
|
||
## Usage | ||
|
||
1. Include the SNESpad.h header in your program. | ||
2. Create a SNESpad object, specifying the clock, latch, and data pin numbers. | ||
3. Use the `begin()` and `start()` function to initialize the SNESpad. | ||
4. Use the `poll()` function to update the state of the SNESpad. | ||
5. You can then read the state of the buttons and the direction pad using the appropriate members of the SNESpad class. | ||
|
||
## Button Variables | ||
|
||
Here are the members of the SNESpad class that hold the state of the buttons: | ||
|
||
- `buttonA` | ||
- `buttonB` | ||
- `buttonX` | ||
- `buttonY` | ||
- `buttonStart` | ||
- `buttonSelect` | ||
- `buttonL` | ||
- `buttonR` | ||
- `directionUp` | ||
- `directionDown` | ||
- `directionLeft` | ||
- `directionRight` | ||
|
||
For the SNES Mouse, these additional variables are available: | ||
|
||
- `mouseX` | ||
- `mouseY` | ||
|
||
## Example | ||
|
||
Here is an example of how to create a SNESpad object and read the state of the buttons: | ||
|
||
```cpp | ||
#include "SNESpad.h" | ||
|
||
#define CLOCK 0 | ||
#define LATCH 1 | ||
#define DATA 2 | ||
|
||
SNESpad snespad(CLOCK, LATCH, DATA); | ||
|
||
void setup() { | ||
snespad.begin(); | ||
snespad.start(); | ||
} | ||
|
||
void loop() { | ||
snespad.poll(); | ||
|
||
if (snespad.buttonA) { | ||
printf("Button A is pressed.\n"); | ||
} | ||
|
||
if (snespad.buttonB) { | ||
printf("Button B is pressed.\n"); | ||
} | ||
|
||
// Add more button checks as needed. | ||
} | ||
``` | ||
This example will print a message to the console whenever button A or B is pressed. | ||
## Author | ||
The library was ported and substantially rewritten by Robert Dale Smith. | ||
This library was ported and substantially rewritten by Robert Dale Smith. | ||
Email: <[email protected]> | ||
## Examples | ||
Included in this repository are three examples that demonstrate different use cases for the SNESpad library. | ||
1. [serial.ino](examples/serial/serial.ino) - Demonstrates how to use the SNESpad library to monitor a SNES controller over a USB serial connection. | ||
2. [hid.ino](examples/hid/hid.ino) - Demonstrates how to use the SNESpad library to create HID mouse and HID joystick USB devices using a SNES controller. | ||
3. [xinput.ino](examples/xinput/xinput.ino) - Demonstrates how to use the SNESpad library to create an XInput USB controller using a SNES controller or mouse. | ||
## Changes and Enhancements | ||
The original library was refactored and optimized for performance and compatibility. Notable changes include: | ||
This version of the library is optimized for performance and compatibility. Notable changes from the original Arduino version include: | ||
- The control polling methods have been optimized to closely match the specifications of the original console. | ||
- Added support for the Super Nintendo mouse and the original NES controllers. | ||
## Version History | ||
- Version: 2.0 (2023) | ||
- Extended to Pico SDK (Robert Dale Smith) | ||
- Total refactor of class structure. (Robert Dale Smith) | ||
- Mouse and NES controller support (Robert Dale Smith) | ||
Below is a history of the original SNESpad library: | ||
- Version: 1.3 (11/12/2010) - Removed shortcut constructor which was causing issues. | ||
|
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
Oops, something went wrong.