mirror of
https://github.com/option8/RetroConnector.git
synced 2024-06-09 16:29:32 +00:00
updated readme, removed older non-working code
This commit is contained in:
parent
f4d90b4d16
commit
a10126984a
BIN
IIe-USB/arduino/.DS_Store
vendored
BIN
IIe-USB/arduino/.DS_Store
vendored
Binary file not shown.
|
@ -1,105 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
// set pin 4 as the slave select for the digital pot:
|
|
||||||
const int slaveSelectPin = A0; //4;
|
|
||||||
const float foo = .21;
|
|
||||||
const int Butt0Pin = A4;
|
|
||||||
const int Butt1Pin = A5;
|
|
||||||
|
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include <avrpins.h>
|
|
||||||
#include <max3421e.h>
|
|
||||||
#include <usbhost.h>
|
|
||||||
#include <usb_ch9.h>
|
|
||||||
#include <Usb.h>
|
|
||||||
#include <usbhub.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include <address.h>
|
|
||||||
#include <hid.h>
|
|
||||||
#include <hiduniversal.h>
|
|
||||||
|
|
||||||
#include "hidjoystickrptparser.h"
|
|
||||||
|
|
||||||
#include <printhex.h>
|
|
||||||
#include <message.h>
|
|
||||||
#include <hexdump.h>
|
|
||||||
#include <parsetools.h>
|
|
||||||
|
|
||||||
USB Usb;
|
|
||||||
USBHub Hub(&Usb);
|
|
||||||
HIDUniversal Hid(&Usb);
|
|
||||||
JoystickEvents JoyEvents;
|
|
||||||
JoystickReportParser Joy(&JoyEvents);
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
// set the slaveSelectPin as an output:
|
|
||||||
pinMode (slaveSelectPin, OUTPUT);
|
|
||||||
|
|
||||||
|
|
||||||
pinMode (Butt0Pin, OUTPUT);
|
|
||||||
pinMode (Butt1Pin, OUTPUT);
|
|
||||||
|
|
||||||
|
|
||||||
// initialize SPI:
|
|
||||||
SPI.begin();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Serial.begin( 115200 );
|
|
||||||
Serial.println("Start");
|
|
||||||
|
|
||||||
if (Usb.Init() == -1)
|
|
||||||
Serial.println("OSC did not start.");
|
|
||||||
|
|
||||||
delay( 200 );
|
|
||||||
|
|
||||||
if (!Hid.SetReportParser(0, &Joy))
|
|
||||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
Usb.Task();
|
|
||||||
|
|
||||||
int joyX = JoyEvents.X;
|
|
||||||
int channel = 5;
|
|
||||||
|
|
||||||
digitalPotWrite(channel, joyX);
|
|
||||||
digitalPotWrite(channel - 1, joyX * foo);
|
|
||||||
|
|
||||||
int joyY = JoyEvents.Y;
|
|
||||||
channel = 3;
|
|
||||||
|
|
||||||
digitalPotWrite(channel, joyY);
|
|
||||||
digitalPotWrite(channel - 1, joyY * foo);
|
|
||||||
|
|
||||||
|
|
||||||
digitalWrite(Butt0Pin,JoyEvents.Butt0);
|
|
||||||
digitalWrite(Butt1Pin,JoyEvents.Butt1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void digitalPotWrite(int address, int value) {
|
|
||||||
// take the SS pin low to select the chip:
|
|
||||||
digitalWrite(slaveSelectPin,LOW);
|
|
||||||
// send in the address and value via SPI:
|
|
||||||
SPI.transfer(address);
|
|
||||||
SPI.transfer(value);
|
|
||||||
// take the SS pin high to de-select the chip:
|
|
||||||
digitalWrite(slaveSelectPin,HIGH);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "hidjoystickrptparser.h"
|
|
||||||
|
|
||||||
JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
|
|
||||||
joyEvents(evt),
|
|
||||||
oldHat(0xDE),
|
|
||||||
oldButtons(0)
|
|
||||||
{
|
|
||||||
for (uint8_t i=0; i<RPT_GEMEPAD_LEN; i++)
|
|
||||||
oldPad[i] = 0xD;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
|
|
||||||
{
|
|
||||||
bool match = true;
|
|
||||||
|
|
||||||
// Checking if there are changes in report since the method was last called
|
|
||||||
for (uint8_t i=0; i<RPT_GEMEPAD_LEN; i++)
|
|
||||||
if (buf[i] != oldPad[i])
|
|
||||||
{
|
|
||||||
match = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calling Game Pad event handler
|
|
||||||
if (!match && joyEvents)
|
|
||||||
{
|
|
||||||
joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
|
|
||||||
|
|
||||||
for (uint8_t i=0; i<RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t buttons = (0x0000 | buf[6]);
|
|
||||||
buttons <<= 4;
|
|
||||||
buttons |= (buf[5] >> 4);
|
|
||||||
uint16_t changes = (buttons ^ oldButtons);
|
|
||||||
|
|
||||||
// Calling Button Event Handler for every button changed
|
|
||||||
if (changes)
|
|
||||||
{
|
|
||||||
for (uint8_t i=0; i<0x0C; i++)
|
|
||||||
{
|
|
||||||
uint16_t mask = (0x0001 << i);
|
|
||||||
|
|
||||||
if (((mask & changes) > 0) && joyEvents)
|
|
||||||
if ((buttons & mask) > 0)
|
|
||||||
joyEvents->OnButtonDn(i+1);
|
|
||||||
else
|
|
||||||
joyEvents->OnButtonUp(i+1);
|
|
||||||
}
|
|
||||||
oldButtons = buttons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
|
|
||||||
{
|
|
||||||
|
|
||||||
X = evt->X;
|
|
||||||
Y = evt->Y;
|
|
||||||
Serial.print("X: ");
|
|
||||||
Serial.print(X);
|
|
||||||
//PrintHex<uint8_t>(evt->X, 0x80);
|
|
||||||
Serial.print("\tY: ");
|
|
||||||
Serial.print(Y);
|
|
||||||
// PrintHex<uint8_t>(evt->Y, 0x80);
|
|
||||||
Serial.println("");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void JoystickEvents::OnButtonUp(uint8_t but_id)
|
|
||||||
{
|
|
||||||
Serial.print("Up: ");
|
|
||||||
Serial.println(but_id);
|
|
||||||
if(but_id == 1) {
|
|
||||||
Butt0 = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(but_id == 2) {
|
|
||||||
Butt1 = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void JoystickEvents::OnButtonDn(uint8_t but_id)
|
|
||||||
{
|
|
||||||
Serial.print("Dn: ");
|
|
||||||
Serial.println(but_id);
|
|
||||||
|
|
||||||
|
|
||||||
if(but_id == 1) {
|
|
||||||
Butt0 = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(but_id == 2) {
|
|
||||||
Butt1 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
#if !defined(__HIDJOYSTICKRPTPARSER_H__)
|
|
||||||
#define __HIDJOYSTICKRPTPARSER_H__
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include "avrpins.h"
|
|
||||||
#include "max3421e.h"
|
|
||||||
#include "usbhost.h"
|
|
||||||
#include "usb_ch9.h"
|
|
||||||
#include "Usb.h"
|
|
||||||
|
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
|
||||||
#include "Arduino.h"
|
|
||||||
#else
|
|
||||||
#include <WProgram.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "printhex.h"
|
|
||||||
#include "hexdump.h"
|
|
||||||
#include "message.h"
|
|
||||||
#include "confdescparser.h"
|
|
||||||
#include "hid.h"
|
|
||||||
|
|
||||||
struct GamePadEventData
|
|
||||||
{
|
|
||||||
uint8_t X, Y;
|
|
||||||
};
|
|
||||||
|
|
||||||
class JoystickEvents
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void OnGamePadChanged(const GamePadEventData *evt);
|
|
||||||
virtual void OnButtonUp(uint8_t but_id);
|
|
||||||
virtual void OnButtonDn(uint8_t but_id);
|
|
||||||
|
|
||||||
uint8_t X;
|
|
||||||
uint8_t Y;
|
|
||||||
|
|
||||||
boolean Butt0;
|
|
||||||
boolean Butt1;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RPT_GEMEPAD_LEN 5
|
|
||||||
|
|
||||||
class JoystickReportParser : public HIDReportParser
|
|
||||||
{
|
|
||||||
JoystickEvents *joyEvents;
|
|
||||||
|
|
||||||
uint8_t oldPad[RPT_GEMEPAD_LEN];
|
|
||||||
uint8_t oldHat;
|
|
||||||
uint16_t oldButtons;
|
|
||||||
|
|
||||||
public:
|
|
||||||
JoystickReportParser(JoystickEvents *evt);
|
|
||||||
|
|
||||||
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __HIDJOYSTICKRPTPARSER_H__
|
|
|
@ -3,7 +3,7 @@ _Tested and works with the following USB gamepads:_
|
||||||
- Super Nintendo generic http://www.amazon.com/gp/product/B002JAU20W
|
- Super Nintendo generic http://www.amazon.com/gp/product/B002JAU20W
|
||||||
|
|
||||||
_Will NOT work with the following:_
|
_Will NOT work with the following:_
|
||||||
- PS3 Sixaxis Dualshock. The Dualshock draws too much power (300mA), since it charges the battery over USB.
|
- PS3 Sixaxis (Dualshock or Original flavor). The PS3 wireless controllers draw too much power, since they charge the battery over USB.
|
||||||
|
|
||||||
|
|
||||||
Plug and Play
|
Plug and Play
|
||||||
|
|
Loading…
Reference in New Issue
Block a user