Hi my name is Mark, I have a raspi 2b with retropie 3 beta using xbox 360 
wireless controllers linked to RPI with a recycled RF Module from a 1st gen 
XBox 360 that has a working sync button, I got this all working with a 
script I found online and after a bit of editing and compiling the Original 
script works great, and my thanks go to the maker who was un-named. But it 
doesn't do everything id like it to and seemed a great starting point, so I 
set about trying to make it do all I wanted from it, I originally started 
this project on my old pc about 3 yrs ago but I don't work well with 
micro-controllers and not being able to find out all the commands I wanted 
to use with it, I gave up, But recently decided to give it another go after 
purchasing a RPi 2, so after hours/days of further research I managed to 
find all the commands I needed and have set about trying to add these to 
the original script in a attempt to get it to do what I originally wanted. 
The problem is I haven't got much experience with programming and don't 
know how to proceed with some of my ideas, my searches online to find out 
how to do things just got confusing, with so many people with different 
ways to do and not do things, different preferences or techniques, etc, 
left me not knowing which direction to turn let alone where to start, don't 
get me wrong some of my additions are quite simple to implement(or at least 
I hope they are) but there are somethings that I don't know where to start 
with as you will see below.

Original File: http://pastebin.com/AiAiWYdh

These are what I want to add into the relevant area's of the script:

Addition 1:

#define pwr_pin         0  // => physical pin 11 - bcm pin 17 ==>RF Module 
pin 5. turns off controllers and RPi.

Easy to add yeah! Additions 3/4/5 and 6 will explain more on my aim and why 
this is being added.

Addition 2:

unsigned char ply1_led[10] = {0,0,1,0,1,0,0,1,0,0}; //Illuminates RF Module 
Controller 1 LED ==> Lower Left
unsigned char ply2_led[10] = {0,0,1,0,1,0,0,0,0,1}; //Illuminates RF Module 
Controller 2 LED ==> Upper Left
unsigned char ply3_led[10] = {0,0,1,0,1,0,0,0,1,0}; //Illuminates RF Module 
Controller 3 LED ==> Upper Right
unsigned char ply4_led[10] = {0,0,1,0,1,0,1,0,0,0}; //Illuminates RF Module 
Controller 4 LED ==> Lower Right
unsigned char cont_err[10} = {0,0,1,1,0,1,0,0,0,1}; //Illuminates RF Module 
4 Flashing RED LEDS  ==> No Controller Warning. 

I want to have a pre stored values assigned to these five commands, then 
have the program look at etc/rc.local line 20 and send the command with 
values that match the first 24 characters on that line eg: ply1_cmd will 
initiate if it see's "xboxdrv --daemon --id 0 " on line 20, but if it does 
not,it checks against the next command and so on until it finds the command 
it belongs to and issues the command, something like read line 20 of this 
file store first 24 characters of line then check against stored cmd 
triggers. the big problem is I don't know hows best to do this or if its 
even possible Ive gotten myself all confused trying to find ways to do it, 
Any help to accomplish this would be greatly apprieciated as this is the 
bulk of what I set about to achieve in the first place due to the led's not 
lighting up on the module and realizing they did on the controller due to 
xboxdrv hence why I came here, basically my script cannot work without 
xboxdrv.

The triggers would be:

"xboxdrv --daemon --id 0 " ==> ply1_cmd.
"xboxdrv --daemon --id 1 " ==> ply1_cmd, ply2_cmd.
"xboxdrv --daemon --id 2 " ==> ply1_cmd, ply2_cmd, ply3_cmd. 
"xboxdrv --daemon --id 3 " ==> ply1_cmd, ply2_cmd, ply3_cmd, ply4_cmd.
line 20 contains no data.  ==> cont_err.

This part of the script also needs to keep checking the file at regular 
intervalS to check for changes and adjust Leds as necessary. 

Addition 3:

unsigned char cont_off[10] = {0,0,0,0,0,0,1,0,0,1}; //Shuts Down 
Controllers.

addition 4:

pinMode(pwr_pin, INPUT);

Again seems easy enough when triggered by pwr switch my problem is I don't 
know if I will be able to use the "void send_cmd(unsigned char * cmd)" part 
already in the script and just add another "while" which would be my 
Addition 5.

Addition 5:

while(1) {
// Wait For Event in pwr btn
wait_for(pwr_pin, 0);
send_cmd(cont_off);

or will I have to write a new section for this to work, Addition 6 goes on 
the next line after "send_cmd(cont_off)".

Addition 6:

       delay(2000);
                std::system("sudo shutdown -h now")
} 

Here I want it to have a short delay then send a system command as if in 
terminal to safely shut down the RPi, any advice here would be great 
whether its to suggest a alternative method or point out mistakes 
everything helps.

Many thanks for taking the time to read this, Sorry it became an essay but 
I wanted to make sure what I wanted to do was explained properly and make 
it much easier to move forward with my project under some guidance and help.
Mark.

-- 
You received this message because you are subscribed to the Google Groups 
"xboxdrv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/xboxdrv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to