Listen for any I/O on T2 for Macro Record?
7 posts
• Page 1 of 1
Listen for any I/O on T2 for Macro Record?
This is my first time using macro record and I want it to function like the one in the online resources where it has an indicator letting you know that once you make a move it starts recording. I thought leaving check_active() open would listen for any input. Trying to create my own Macro Recorder and want to go standby until any input is hit at which point macro_rec("<filename>.gmk"); starts. I want to know how to listen for any input. Any help would be appreciated. Thanks
- Code: Select all
if(check_active(XB1_RB,2000) && check_active(XB1_LB,2000)) { //Start Macro recorder standby
if(standby || check_active()){standby = FALSE;}
else{standby = TRUE;}
}
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
Re: Listen for any I/O on T2 for Macro Record?
- Code: Select all
#include <xb1.gph>
main {
if(macro_time() == -1) {
if(check_active(XB1_RB,2000) && check_active(XB1_LB,2000)) {
if(check_for_active_buttons()) {
macro_rec("<filename>.gmk");
}
}
}
else {
// if( Conditon to end the macro recording ) {
// macro_stop();
// }
}
}
bool check_for_active_buttons(){
int i = 21;
// Checks if any Button I/O, (1 thru 21) are active.
while(i--){
// Ignores RB and LB.
if(i == XB1_RB | i == XB1_LB) --i;
// Does not check any IO after BUTTON_21.
if(get_actual(i)) return TRUE;
}
return FALSE;
}
Is this what you were trying to do?
-
Sillyasskid - Captain
- Posts: 574
- Joined: Sat May 14, 2016 3:07 am
Re: Listen for any I/O on T2 for Macro Record?
Oh hell yeah!!! Thank you so much.
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
Re: Listen for any I/O on T2 for Macro Record?
I am trying to implement your code but it does not seem to work. Any idea why on the T2? Could it be that "i" has to match the actual GPC Designators? Like BUTTON_5 instead of just 5. I even tried #include <titanone.gph> just to see if. If I replace (activity) with (event_active(XB1_B) for example the LED does change color when I press B.
- Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
#include "ColorLED.gph"
#include <xb1.gph>
bool activity(){ // Checks if any buttons I/O, (1 thru 24) are active.
uint8 i = 24;
while(i--){
if(get_actual(i)) return TRUE;
}
return FALSE;
}
/* ////////////////////////
//Section 8: MAIN CODE//
////////////////////////
*/
main {
if(activity){ // Check if any button is being pressed.
ColorLED(CW);
}
}
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
Re: Listen for any I/O on T2 for Macro Record?
Fixed.
if(activity)
It should have been
if(activity())
I also changed the
if(get_actual(i))
to
if(is_active(i))
Because I noticed you were also checking for stick movements.
When the sticks reach 20% in either direction, it will be considered active, with the is_active() function.
If you used the get_actual() function, it would return true, for any value thats not 0.
- Code: Select all
#include "ColorLED.gph"
#include <xb1.gph>
bool activity(){ // Checks if any buttons I/O, (1 thru 24) are active.
uint8 i = 25;
while(i--){
if(is_active(i)) return TRUE;
}
return FALSE;
}
/* ////////////////////////
//Section 8: MAIN CODE//
////////////////////////
*/
main {
if(activity()){ // Check if any button is being pressed.
ColorLED(CW);
}
}
if(activity)
It should have been
if(activity())
I also changed the
if(get_actual(i))
to
if(is_active(i))
Because I noticed you were also checking for stick movements.
When the sticks reach 20% in either direction, it will be considered active, with the is_active() function.
If you used the get_actual() function, it would return true, for any value thats not 0.
-
Sillyasskid - Captain
- Posts: 574
- Joined: Sat May 14, 2016 3:07 am
Re: Listen for any I/O on T2 for Macro Record?
I only started a few days ago and I am learning based on examples. I almost have a solid product and thanks to you I am learning even more! You are awesome and thanks for the quick feedback!
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
7 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 100 guests