From a10126984af44b6ace3b10ae1903f6a069cbc02a Mon Sep 17 00:00:00 2001 From: Charles Mangin Date: Thu, 6 Feb 2014 13:42:32 -0500 Subject: [PATCH] updated readme, removed older non-working code --- .DS_Store | Bin 15364 -> 12292 bytes IIe-USB/arduino/.DS_Store | Bin 6148 -> 6148 bytes .../Arduino/USBHIDJoystick/USBHIDJoystick.ino | 105 ------------------ .../USBHIDJoystick/hidjoystickrptparser.cpp | 104 ----------------- .../USBHIDJoystick/hidjoystickrptparser.h | 60 ---------- USB_Joystick/README.md | 2 +- 6 files changed, 1 insertion(+), 270 deletions(-) delete mode 100644 USB_Joystick/Arduino/USBHIDJoystick/USBHIDJoystick.ino delete mode 100644 USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.cpp delete mode 100644 USB_Joystick/Arduino/USBHIDJoystick/hidjoystickrptparser.h diff --git a/.DS_Store b/.DS_Store index 819ddfe0f000c3750b529d504e64ff71524ad4dd..76c9a4166a6ed7a0fbd82e92f4ddb81439f2fa22 100644 GIT binary patch delta 581 zcmZpvXi1P@U|?W$DortDU;r^WfEYvza8E20o2Vx_*+7Ry6v$^#1Y$;@I73dlVQ_MO zZoy_jgXQd;Kp_y|;0AKVSvITlJYi;3oXn#jX&KLa6ez*MpvRETkjYSzoA2V1Qd*MC zz;Nzfwh&kol3WUs+~ha~Y395DhRKYIW&$wVz#15vm4JdyEE{wfK(ZE->lL|R95eoc z42Z)ZN*_!v6cC<#Psw(&oB$Wgx!(bcCtp+)nd~6I!vtj}2}n+!DPY8Ox_a_i0XdN9 zTLA?S#V@GD*f5z=+UK$zNq9Ia7+0bCUA&a~LQ8mz15HDaOlmA`Zxu zncO7{vGAj;EI+DVhRGl?6pMu$HWtoi5@ZJZok4;dNV|d}akC)Dcjn3bI-ZmLc{n(L okp+rhhRN|f)5J=Ev69S?jTA3HXF-f6!a87df9Bq-V6c=802L{m%K!iX literal 15364 zcmeHN4{#J$8UMaVAiK8-*-M}y356@6fDj;okUxkJLdxF&X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o1JDHA6O~C)J`F|0BZsA(MwSa2@*8;8uTno4sa4q0k Lz_q}2VS)bwf7Ar- diff --git a/IIe-USB/arduino/.DS_Store b/IIe-USB/arduino/.DS_Store index 9a6520c0c31bea30a8af54314a70542cea33e8a0..f8958a63f56d6648fe2758186faacc4bf72a7ab1 100644 GIT binary patch delta 75 zcmZoMXffCj&B&y5cd{X)%;ZW&Zr0!WLJSNbo - -// 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