diff --git a/.DS_Store b/.DS_Store index 819ddfe..76c9a41 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/IIe-USB/arduino/.DS_Store b/IIe-USB/arduino/.DS_Store index 9a6520c..f8958a6 100644 Binary files a/IIe-USB/arduino/.DS_Store and b/IIe-USB/arduino/.DS_Store differ diff --git a/USB_Joystick/Arduino/USBHIDJoystick/USBHIDJoystick.ino b/USB_Joystick/Arduino/USBHIDJoystick/USBHIDJoystick.ino deleted file mode 100644 index 6ebf4cc..0000000 --- a/USB_Joystick/Arduino/USBHIDJoystick/USBHIDJoystick.ino +++ /dev/null @@ -1,105 +0,0 @@ - - -#include - -// 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hidjoystickrptparser.h" - -#include -#include -#include -#include - -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(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); -} - diff --git a/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.cpp b/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.cpp deleted file mode 100644 index c8aeef9..0000000 --- a/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.cpp +++ /dev/null @@ -1,104 +0,0 @@ - - - - -#include "hidjoystickrptparser.h" - -JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : - joyEvents(evt), - oldHat(0xDE), - oldButtons(0) -{ - for (uint8_t i=0; iOnGamePadChanged((const GamePadEventData*)buf); - - for (uint8_t i=0; i> 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(evt->X, 0x80); - Serial.print("\tY: "); - Serial.print(Y); -// PrintHex(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; - } -} - - diff --git a/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.h b/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.h deleted file mode 100644 index 45f41e9..0000000 --- a/USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.h +++ /dev/null @@ -1,60 +0,0 @@ -#if !defined(__HIDJOYSTICKRPTPARSER_H__) -#define __HIDJOYSTICKRPTPARSER_H__ - -#include -#include -#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 -#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__ diff --git a/USB_Joystick/README.md b/USB_Joystick/README.md index 3be72b6..d6a388c 100644 --- a/USB_Joystick/README.md +++ b/USB_Joystick/README.md @@ -3,7 +3,7 @@ _Tested and works with the following USB gamepads:_ - Super Nintendo generic http://www.amazon.com/gp/product/B002JAU20W _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