[TARGET] Gestion DoubleClick et utiliser CHM comme Layer
Publié : lun. févr. 10, 2014 10:21 am
Bonjour, dans la suite des trucs et astuces pour la programmation TARGET, je soumets à votre sagacité le code suivant:
Ce code permet d'affecter le Layer U du HOTAS sur le doubleclick de la touche S4
le doubleclick agit comme une bascule et lorqu'il est activé j'allume la led 2
Cela permet d'augmenter le nombre de possibilité sans utiliser un autre bouton du HOTAS Thrustmaster
Ici dans mon exemple j'utilise la position Milieu du bouton CHINA (CHM) qui n'est pas utilisé, comme U layer et celui-ci est activé par la double pression/relachement de la gachette S4
Code : Tout sélectionner
include "target.tmh"
define USB_1 USB[0x1E] // [ 30] 1 or !
define USB_2 USB[0x1F] // [ 31] 2 or @
define USB_3 USB[0x20] // [ 32] 3 or #
define USB_4 USB[0x21] // [ 33] 4 or $
define USB_5 USB[0x22] // [ 34] 5 or %
define USB_6 USB[0x23] // [ 35] 6 or ^
define USB_7 USB[0x24] // [ 36] 7 or &
define USB_8 USB[0x25] // [ 37] 8 or *
define USB_9 USB[0x26] // [ 38] 9 or (
define USB_0 USB[0x27] // [ 39] 0 or )
int TG1_DI=0; int TG1_DO=0; int TG1_MI=0; int TG1_MO=0; int TG1_UI=0; int TG1_UO=0;
int S2_DI=0; int S2_DO=0; int S2_MI=0; int S2_MO=0; int S2_UI=0; int S2_UO=0;
int S3_DI=0; int S3_DO=0; int S3_MI=0; int S3_MO=0; int S3_UI=0; int S3_UO=0;
int S4_DI=0; int S4_DO=0; int S4_MI=0; int S4_MO=0; int S4_UI=0; int S4_UO=0;
int S1_DI=0; int S1_DO=0; int S1_MI=0; int S1_MO=0; int S1_UI=0; int S1_UO=0;
int APUON_DI =0; int APUON_DO =0; int APUON_MI =0; int APUON_MO =0; int APUON_UI =0; int APUON_UO =0;
int dbclk = 0;
int main()
{
Exclude(&HCougar); Exclude(&T16000); Exclude(&LMFD); Exclude(&RMFD);
if(Init(&EventHandle)) return 1;
SetShiftButton(&Joystick, S4, &Throttle, CHM, 0, 0); // Layers shift button
printf("INIT\xa");
TG1_MO = PULSE+ USB_1;
TG1_MI = PULSE+ USB_2;
TG1_UO = PULSE+ USB_3;
TG1_UI = PULSE+ USB_4;
APUON_MO = PULSE+ USB_5;
APUON_MI = PULSE+ USB_6;
APUON_UO = PULSE+ USB_7;
APUON_UI = PULSE+ USB_8;
MapKeyIOUMD(&Joystick, TG1, TG1_UI, TG1_UO, TG1_MI, TG1_MO, TG1_DI, TG1_DO);
MapKeyIOUMD(&Throttle, APUON , APUON_UI , APUON_UO , APUON_MI , APUON_MO , APUON_DI , APUON_DO);
printf("...ready\xa");
}
int EventHandle(int type, alias o, int x)
{
if (x == CHM & &o == &Throttle)o[x]=layer_sw[5];
if(&o==&Joystick & x == S4) // routine testant le doubleclik sur S4
{
if (!Joystick[S4] & dbclk == 1) dbclk = 2;
if (Joystick[S4]) { dbclk = dbclk + 1; if (dbclk==1) DeferCall(500, &RazFlag, &dbclk);}
if ((!Joystick[S4]) & (dbclk == 3))
{
Throttle[CHM]=!layer_sw[5];
LED_Light(2, Throttle[CHM]);
DefaultMapping(&Throttle, CHM);
}
}
DefaultMapping(&o, x);
}
int RazFlag(alias f){f=0;}
int LED_Light(int n, int state = 1)
{
GameOutput(&Throttle, n + OUT_ID_LED_1 - 1, state); //ON_OFF LED n = 1 to 5
}
le doubleclick agit comme une bascule et lorqu'il est activé j'allume la led 2
Cela permet d'augmenter le nombre de possibilité sans utiliser un autre bouton du HOTAS Thrustmaster
Ici dans mon exemple j'utilise la position Milieu du bouton CHINA (CHM) qui n'est pas utilisé, comme U layer et celui-ci est activé par la double pression/relachement de la gachette S4