I have a leonardo , uno and a USB host shield !
i wanted to make a great console for myself !
i have 2 problems in that :-
- Leonardo ain’t compatible with my shield dirtectly , and i have seen a pdf document that will help me , but i am still having problems ! (see the attatched document below);
2)My leonardo bootloader is in trouble :- http://forum.arduino.cc/index.php?topic=347496.0
what i want to do is:-
use my PS3 controller as a keyboard and mouse for my games !
i am burning codes to my leonardo using mu ISP !
and its too troublesome , but my leonardo is OK , and am sucessfully able to emulate it as a mouse and keyboard ! sooo :-
what i can now do is just one thing !
use USB host shield with my uno , and use a data protocol to send data to leonardo , and emulate it as mouse and keyboard !
plz give me a framework so that i can start working on it as soon as possible ! plz help me !
if i need , i can flash the Micro Firmware on my leonardo ! thats Just FINE !
plz … if you can then plz write a code for me !
#include <PS3USB.h>
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb;
PS3USB PS3(&Usb);
bool printAngle;
uint8_t state = 0;
int x1=0,y1=0,x2=0,y2=0,lk=0,rk=0,tmp=0,sp=0;
void setup() {
Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial);
#endif
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nPS3 USB Library Started"));
}
void loop() {
Usb.Task();
if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) {
x1=PS3.getAnalogHat(LeftHatX);
y1=PS3.getAnalogHat(LeftHatY);
x2=PS3.getAnalogHat(RightHatX);
y2=PS3.getAnalogHat(RightHatY);
x1=map(x1,0,255,0,8);x2=map(x2,0,255,0,8);
y1=map(y1,0,255,0,8);y2=map(y2,0,255,0,8);
}
else {x1=4,x2=4,y1=4,y2=4;}
if (PS3.getAnalogButton(L2)) {
tmp=PS3.getAnalogButton(L2);
if(tmp>100)rk=1;
}
else rk=0;
if (PS3.getButtonClick(R1))
lk=1;
else lk=0;
if (PS3.getAnalogButton(R2)) {
tmp=PS3.getAnalogButton(R2);
if(tmp>100)sp=1;
}
else sp=0;
Serial.print(x1);//joystick 1 x,y
Serial.print(y1);
Serial.print(x2);//joystick 2 x,y
Serial.print(y2);
Serial.print(lk);// left click
Serial.print(rk);// right click
Serial.print(sp);// spacebar !
//PS3 Connected Last Option Bracket}
delayMicroseconds(10);
}
sparkfun-usb-host-shield-hack.pdf (1.23 MB)