Accessible Script Requests for Disabled Users

GPC1 script programming for Titan One. Code examples, questions, requests.

Re: Accessible Script Requests for Disabled Users

Postby SpecialEffect » Sat Jun 13, 2015 11:55 am

Forget point 2, as I think I've fixed that now. Will share the scripts once I've double-checked. Just need that help with the filter on L3/R3 and the Blink Switch Inversion with filter.... Thanks again!
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Accessible Script Requests for Disabled Users

Postby SpecialEffect » Sat Jun 13, 2015 12:06 pm

This script now swallows the L3 and R3 controls, and seems to work well.

Code: Select all
// Script for Special Effect
// see the posts below as reference
// viewtopic.php?f=6&t=1210
// viewtopic.php?f=6&t=1795&p=12979#p12979

define forward_val = 70;
define side_val = 70;
define DeadZoneLeftStick = 20;

int ForwardToggleON = FALSE;
int LeftMovementToggle = FALSE; // FALSE = move right; TRUE = move left;
int timer, stop;


main {
  // Dead Zone Detection
  if ( get_val(PS3_LX) >= -DeadZoneLeftStick && get_val(PS3_LX) <= DeadZoneLeftStick) {set_val(PS3_LX,0);}
  if ( get_val(PS3_LY) >= -DeadZoneLeftStick && get_val(PS3_LY) <= DeadZoneLeftStick) {set_val(PS3_LY,0);}

  // Forward Movement
  if (event_press(PS3_L3)) {ForwardToggleON = !ForwardToggleON;} // Toggles forward movement on/off
  if (ForwardToggleON) {set_val(PS3_LY,-forward_val);set_val(PS4_L3, 0);} // -value is move forward; +value is move backwards     ; Swallow L3 button whilst turning on movement
  if (!ForwardToggleON) {set_val(PS4_L3, 0);} //                                                                                  ; Swallow L3 button whilst turning off movement

  // Side to Side Movement
  if (event_press(PS3_R3)) {LeftMovementToggle = !LeftMovementToggle;} // Toggles between left and right movements
  if (get_val(PS3_R3) && LeftMovementToggle) {set_val(PS3_RX,-side_val);set_val(PS4_R3, 0);} // -value is move left     ; Swallow R3 button whilst looking left.
  if (get_val(PS3_R3) && !LeftMovementToggle) {set_val(PS3_RX,side_val);set_val(PS4_R3, 0);} // +value is move right    ; Swallow R3 button whilst steering right.

}
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Accessible Script Requests for Disabled Users

Postby SpecialEffect » Sun Jun 14, 2015 7:58 pm

Could anyone help me build a loop to wait until a button is released, please, linked to the scripts below....


I thought this might work....

x = get_val(XB360_A);
while( x > 0 ) {
if(get_val(XB360_A)==0) {
break;


But it doesn't. It just crashes the Titan One.


The aim is to enable a person to hold the "A" button (a downwards blink), activate a combo, then do nothing until the user has released the "A" button. Seems so simple in BASIC, but I can't for the life of me work it out in GPC. Any help, hugely appreciated!! The two scripts I'd love for this to work on are below....

Code: Select all
// Blink Switch Filter


define BLINK = XB360_A;
define LED = 500; // Length of time for LED to be on.

int filter=500; // Deliberate Blink time
int pulse_time=500; // Time that "B" is pulsed.
int wait_time=4000; // Time to wait before checking for a blink again.

main
{

    if (get_val(BLINK) >0) set_ledx(LED_1,1);           // If any input is detected, flash LED 1.

    if (get_val(BLINK) && get_ptime(BLINK) > filter )   // Check for a deliberate blink
         combo_run(Blink_Accepted);


}


combo Blink_Accepted // Routine for pulsing the "B" button, flashing LED 2, rumbling motor gently and pausing before checking for input again.
    {
    set_val(XB360_B, 100);set_ledx(LED_2,6);set_rumble(RUMBLE_A, 20);
    wait(LED);wait (pulse_time);

    set_val(XB360_B, 0);set_rumble(RUMBLE_A, 0);
    wait (wait_time);
    }
   



and....

Code: Select all
// Blink Switch Filter (INVERTED - no blink filter)



define BLINK = XB360_A;
define LED = 500; // Length of time for LED to be on.

int filter=500; // Deliberate Blink time
int pulse_time=500; // Time that "B" is pulsed.
int wait_time=3000; // Time to wait before checking for a blink again.
int y = 0;


main
{
y = get_val(BLINK); // Check for a deliberate blink
if (  y<1 )
    {
        combo_run(Blink_Accepted);
    }
          set_ledx(LED_1,0);
         
}

combo Blink_Accepted
    {
    set_val(XB360_B, 100)
   
    set_ledx(LED_2,6);set_rumble(RUMBLE_A, 20);wait(LED);
             
    wait (pulse_time);

    set_val(XB360_B, 0);
    set_rumble(RUMBLE_A, 0);
    wait (wait_time);
   
   
    }
   
   
   
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Accessible Script Requests for Disabled Users

Postby UK_Wildcats » Mon Jun 15, 2015 3:48 pm

It seems that you have been making good progress. Let me give you some basics of the firmware that may help you. The main loop is constantly looping with a small wait time between, which is variable with the default at 10mS. Therefore, you can use simple if commands instead of the while loops.

Since you have a good grasp on programming and experience. Here is the documentation link for the GPC language reference. I suggest going through this and the various links to give you a better understand of what commands are allowed along with syntax.

http://www.consoletuner.com/kbase/gpc_language_reference.htm?mw=MjQw&st=MA==&sct=MA==&ms=AQAAEA==

x = get_val(XB360_A);
while( x > 0 ) {
if(get_val(XB360_A)==0) {
break;

if (get_val(XB360_A) > 0) { what you want to do there}

With the scripts in Gtuner GPC Compiler, make sure that you use F7 (menu Complier - Compile) to check for errors. If it passes the compile, it will usually work in the Titan 1.

I think the issue in the first script may be the logic getting confused. I think that you need extra parentheses around the logic (get_ptime(BLINK) > filter). This will divide the IF into two distinctive logics. If this does not work, try taking out taking the filer "(get_ptime(BLINK) > filter)" and try it with the basic commands first.

For the inverted, you can try use a similar code to the first one except use event_release(BLINK) vs get_val(BLINK)

if (event_release(BLINK) && (get_ptime(BLINK) > filter) )
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: Accessible Script Requests for Disabled Users

Postby J2Kbr » Mon Jun 15, 2015 4:48 pm

Hello SpecialEffect. Nice hear from you!! :)

While is not really recommended. What I did was create a control variable to make sure the combo only runs one time per each button press. Please let me know if it worked, then I implement in your second script!

Code: Select all
// Blink Switch Filter
define BLINK    = XB360_A;
define LED      = 500// Length of time for LED to be on.

int filter      = 500// Deliberate Blink time
int pulse_time  = 500// Time that "B" is pulsed.
int wait_time   = 4000; // Time to wait before checking for a blink again.

int run_combo_once = FALSE;

main {
    if (get_val(BLINK) > 0) { // If any input is detected, flash LED 1.
        run_combo_once = TRUE;
        set_ledx(LED_1, 1);
    }
    if(run_combo_once && get_val(BLINK) && get_ptime(BLINK) > filter) { // Check for a deliberate blink
        combo_run(Blink_Accepted);
    }
}
combo Blink_Accepted // Routine for pulsing the "B" button, flashing LED 2, rumbling motor gently and pausing before checking for input again.
{
    set_val(XB360_B, 100);
    set_ledx(LED_2, 6);
    set_rumble(RUMBLE_A, 20);
    wait(LED);
    wait(pulse_time);
    set_val(XB360_B, 0);
    set_rumble(RUMBLE_A, 0);
    wait(wait_time);
    run_combo_once = FALSE;
}

ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Accessible Script Requests for Disabled Users

Postby SpecialEffect » Mon Jun 15, 2015 5:16 pm

Thanks for looking at this. Much appreciated as always.

This doesn't seem to work. If you hold down the "A" button for a long time, you'll see the script cycling round and around repeatedly triggering "B". Ideally I'd like for there to be no noticeable "A" output, and only a single pulsed "B" output, until the user lets go of the "A" button. Then the process can work again.

Does that make any sense? Finding it hard to explain myself with this one.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Accessible Script Requests for Disabled Users

Postby UK_Wildcats » Mon Jun 15, 2015 5:43 pm

Because of the main loop, I think the process is repeating because of the get_val(BLINK) being used with holding the A button.

Code: Select all
// Blink Switch Filter
define BLINK    = XB360_A;
define LED      = 500// Length of time for LED to be on.

int filter      = 500// Deliberate Blink time
int pulse_time  = 500// Time that "B" is pulsed.
int wait_time   = 4000; // Time to wait before checking for a blink again.

int run_combo_once = FALSE;

main {
    if (event_press(BLINK)) { // If any input is detected, flash LED 1.
        run_combo_once = TRUE;
        set_ledx(LED_1, 1);
    }
    if(run_combo_once && event_press(BLINK) && get_ptime(BLINK) > filter) { // Check for a deliberate blink
        combo_run(Blink_Accepted);
    }
}
combo Blink_Accepted // Routine for pulsing the "B" button, flashing LED 2, rumbling motor gently and pausing before checking for input again.
{
    set_val(XB360_B, 100);
    set_ledx(LED_2, 6);
    set_rumble(RUMBLE_A, 20);
    wait(LED);
    wait(pulse_time);
    set_val(XB360_B, 0);
    set_rumble(RUMBLE_A, 0);
    wait(wait_time);
    run_combo_once = FALSE;
}
 


If you want it inverted, change it to event_release(BLINK)
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: Accessible Script Requests for Disabled Users

Postby UK_Wildcats » Mon Jun 15, 2015 5:46 pm

Option 2.

Code: Select all
// Blink Switch Filter
define BLINK    = XB360_A;
define LED      = 500// Length of time for LED to be on.

int filter      = 500// Deliberate Blink time
int pulse_time  = 500// Time that "B" is pulsed.
int wait_time   = 4000; // Time to wait before checking for a blink again.

int run_combo_once = FALSE;

main {

    if(event_press(BLINK) && (get_ptime(BLINK) > filter)) { // Check for a deliberate blink
        set_ledx(LED_1, 1);
        combo_run(Blink_Accepted);
    }
}
combo Blink_Accepted // Routine for pulsing the "B" button, flashing LED 2, rumbling motor gently and pausing before checking for input again.
{
    set_val(XB360_B, 100);
    set_ledx(LED_2, 6);
    set_rumble(RUMBLE_A, 20);
    wait(LED);
    wait(pulse_time);
    set_val(XB360_B, 0);
    set_rumble(RUMBLE_A, 0);
    wait(wait_time);
    run_combo_once = FALSE;
}
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: Accessible Script Requests for Disabled Users

Postby J2Kbr » Mon Jun 15, 2015 7:35 pm

Thank you UK_Wildcats_Fans, your first option corrected the loop issue.

SpecialEffect, below is a version with the correction plus a code to suppress the A button:

Code: Select all
// Blink Switch Filter
define BLINK    = XB360_A;
define LED      = 500// Length of time for LED to be on.

int filter      = 500// Deliberate Blink time
int pulse_time  = 500// Time that "B" is pulsed.
int wait_time   = 4000; // Time to wait before checking for a blink again.

int run_combo_once = FALSE;

main {
    if(event_press(BLINK)) { // If any input is detected, flash LED 1.
        run_combo_once = TRUE;
        set_ledx(LED_1, 1);
        combo_stop(Blink_Accepted);
    }
    if(run_combo_once && get_val(BLINK) && get_ptime(BLINK) > filter) { // Check for a deliberate blink
        combo_run(Blink_Accepted);
    }
    // Suppressing A.
    set_val(BLINK, 0);
}
combo Blink_Accepted // Routine for pulsing the "B" button, flashing LED 2, rumbling motor gently and pausing before checking for input again.
{
    set_val(XB360_B, 100);
    set_ledx(LED_2, 6);
    set_rumble(RUMBLE_A, 20);
    wait(LED);
    wait(pulse_time);
    set_val(XB360_B, 0);
    set_rumble(RUMBLE_A, 0);
    wait(wait_time);
    run_combo_once = FALSE;
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Accessible Script Requests for Disabled Users

Postby SpecialEffect » Mon Jun 15, 2015 8:15 pm

Thanks UK_Wildcats_Fans and J2Kbr for the advice and help. That's brilliant!

I'll try to get my head round the inverted version.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

PreviousNext

Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 98 guests