Skip to content

Commit

Permalink
Corrected some errors in less than and keypressing
Browse files Browse the repository at this point in the history
  • Loading branch information
zeplintwo committed Jul 17, 2021
1 parent b6c308d commit 191a4f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
29 changes: 10 additions & 19 deletions Analog_WSAD_Pre-Axis_Macros.ttm
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@

int OnDutyTime = 0;

int DeltaPitch = 0;
int DeltaYaw = 0;
int DeltaRoll = 0;
int LastPitch = 0;
int LastYaw = 0;
int LastRoll = 0;

//----------
// Arrays
//----------

int LastJoy1[] = {-1,0,-1,0,-1,0}; //pos 1 joy1y negative,pos 2 joy1y positve, pos 3 Joy1x negative, pos 4 joy1x positive, pos 5 joy1z negative, pos 6 joy1z positve
int LastJoy1[] = {-1,0,-1,0,-1,0}; //pos 0 joy1y negative,pos 1 joy1y positve, pos 2 Joy1x negative, pos 3 joy1x positive, pos 4 joy1z negative, pos 5 joy1z positve

//---------------------------------------------------------------------------
// CUSTOM FUNCTIONS
Expand Down Expand Up @@ -56,30 +49,28 @@ int AxisToKeySet(){

int AxisToKey(int DC,short PKey){// Application of Dutycycle call to keypress
ActKey(LOCK+KEYON+PKey);
DeferCall(DC,&ActKey,PKey);
//printf("Duty Cycle : %i \xa",DC);
DeferCall(PWMTimeLenght,&ActKey,LOCK);
DeferCall((DC+TouchDelay),&ActKey,PKey);
printf("Duty Cycle : %i \xa",DC);
//DeferCall(PWMTimeLenght,&ActKey,LOCK);
}

int PWMPress (int mag){// Math to convert Joystick Value to duty cycle in ms of a keypress. Dutycycle time is 100ms
int PWMPress (int mag,int pos1,int pos2){// Math to convert Joystick Value to duty cycle in ms of a keypress. Dutycycle time is 100ms
float fduty = 0.0;
int duty = 0;
fduty = (abs(mag)/Joy1HalfRange)*PWMTimeLenght;
duty = fduty-fduty%1;
if (mag > 0){
fduty = (abs(mag)/Joy1HalfRange)*PWMTimeLenght;
duty = fduty-fduty%1;
//printf("PW Mag Cal Y+: %i, %i \xa",mag,duty);
return(DutyGreater(duty,1));
return(DutyGreater(duty,pos1));
}
if (mag < 0){
fduty = -((abs(mag)/Joy1HalfRange)*PWMTimeLenght);
duty = fduty-fduty%1;
//printf("PW Mag Cal Y-: %i, %i \xa",mag,duty);
return(DutyLess(duty,0));
return(DutyLess(duty,pos2));
}
}

int DutyLess (int duty,int pos){// Math to dampen return to zero values
if (LastJoy1[pos] >= duty){
if (LastJoy1[pos] <= duty){
LastJoy1[pos] = duty;
//printf("Duty Less Ret: %i \xa",duty);
return duty;
Expand Down
12 changes: 6 additions & 6 deletions Analog_WSAD_Profile.tmc
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ int EventHandle(int type, alias o, int x)
AxisToKeySet(); //Call to set Vars for Axis->Key

if (Joy1YValue < (-MinRange1) | Joy1YValue > MinRange1){//Joystick Y axis
OnDutyTime = PWMPress(Joy1YValue);
OnDutyTime = PWMPress(Joy1YValue,0,1);
if (OnDutyTime > 0){
AxisToKey (OnDutyTime, PitchUp);
//printf("Point 1 > %i, %i \xa",JoyYValue,OnDutyTime);
//printf("Point 1 > %i, %i \xa",Joy1YValue,OnDutyTime);
}
if (OnDutyTime < 0){
AxisToKey (abs(OnDutyTime), PitchDown);
//printf("Point 1 > %i, %i \xa",JoyYValue,OnDutyTime);
//printf("Point 1 > %i, %i \xa",Joy1YValue,abs(OnDutyTime));
}
}

if (Joy1XValue < (-MinRange1) | Joy1XValue > MinRange1){//Joystick X axis
OnDutyTime = PWMPress(Joy1XValue);
OnDutyTime = PWMPress(Joy1XValue,3,4);
if (OnDutyTime > 0){
AxisToKey (OnDutyTime, RollRight);
//printf("Point 1 > %i, %i \xa",JoyXValue,OnDutyTime);
//printf("Point 1 > %i, %i \xa",Joy1XValue,OnDutyTime);
}
if (OnDutyTime < 0){
AxisToKey (abs(OnDutyTime), RollLeft);
//printf("Point 1 > %i, %i \xa",JoyXValue,OnDutyTime);
//printf("Point 1 > %i, %i \xa",Joy1XValue,OnDutyTime);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Analog_WSAD_User_Settings.ttm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Part of Analog_WSAD_Profile#.# keybinds packages
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
// Settings Storage for Script Values
//---------------------------------------------------------------------------
Expand Down

0 comments on commit 191a4f1

Please sign in to comment.