IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Optimisation clavier Virtuel


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    plombier
    Inscrit en
    Décembre 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : plombier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Décembre 2012
    Messages : 31
    Par défaut Optimisation clavier Virtuel
    Bonjour a tous .
    Petite précision, j'apprend le C pas moi même, donc pas de mots trop technique

    Je viens de finir de programmer un clavier virtuel en C. Il fonctionne avec la sourie, et le clavier. Mon objectif est d'en faire une bibliothèque pour pouvoir le réutiliser .
    Je ne pense pas avoir de bug, du moins j'espère

    Mon programme fonctionne, bien quand je suis sur mon PC fix qui a un pros I7.
    J'ai voulu testé, sur mon netbook. La la catastrophe .

    Mon programme lag...
    Je fais donc appelle a vous pour me dire d'ou peut venir ces lags

    Je vous remercie d'avance

    je vais vous donné juste le minimum de code

    pause.c ( c'est ici que j'appelle les fonctions de mon clavier
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    #include <stdlib.h>
    #include <stdio.h>
    #include "clavier.h"
    #include "pause.h"
    #include "utile.h"
    #include <SDL/SDL_ttf.h>
     
    void        pause(SDL_Surface *ecran)
    {
        int c = 1, tailleTexteClavier = 15;
        SDL_Event e;
        FILE *doc = NULL;
        char texte[TAILLE_TAB_TEXTE] = "";
        SDL_Color colorKey = {255, 255, 255};
     
        doc = fopen("teste.txt", "w+");
     
        Touche *touche;
        Uint32 noir = SDL_MapRGB(ecran->format, 0, 0, 0);
     
        touche = CLAVIER__Init(NB_TOUCHE, noir, colorKey, tailleTexteClavier);
     
        CLAVIER__Blit(touche, ecran, e);
     
        while(c)
        {
            SDL_WaitEvent(&e);
            switch(e.type)
            {
                case SDL_QUIT: c = 0; break;
                case SDL_KEYDOWN:  CLAVIER__keyDown(e, touche, texte, TAILLE_TAB_TEXTE); break;
                case SDL_KEYUP: CLAVIER__keyUp(e, touche); break;
                case SDL_MOUSEBUTTONDOWN: CLAVIER__MouseDown(e, touche, texte, TAILLE_TAB_TEXTE); break;
                case SDL_MOUSEBUTTONUP: CLAVIER__MouseUp(e, touche); break;
                default: break;
            }
            CLAVIER__Blit(touche, ecran, e);
        }
        CLAVIER__Quit(touche);
     
        fprintf(doc, texte);
        fclose(doc);
    }
    clavier.c(toutes les fonctions de mon clavier)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    #include <stdlib.h>
    #include <stdio.h>
    #include "clavier.h"
    #include <SDL_image.h>
    #include <ctype.h>
    #include <string.h>
    #include <SDL/SDL_ttf.h>
     
    static int maj = 0, verMaj = 0, circonflexe = 0, alt = 0, ctrl = 0;
    static int nbT;
    static TTF_Font *police = NULL;
    static SDL_Color couleurTexteTouche;
    static Uint32 couleurFond;
     
    // PARTIE GENERALE
    static void CLAVIER__blitClavier(SDL_Surface* source, SDL_Surface* dest,int x, int y)
    {
        SDL_Rect R;
     
        R.x = x;
        R.y = y;
        SDL_SetColorKey(source, SDL_SRCCOLORKEY, SDL_MapRGB(source->format, 255, 153, 204));
        SDL_BlitSurface(source,NULL,dest,&R);
    }
    static void CLAVIER__saveToucheImage(Touche t[],const int i)
    {
        char sUp[TAILLE_TAB] = "", sDown[TAILLE_TAB] = "";
     
        if(i <= 53 || i == 57)
            switch(i)
            {
                case 13:
                    sprintf(sUp,"clavier/kRetUp.png");
                    sprintf(sDown,"clavier/kRetDown.png");
                break;
                case 14:
                    sprintf(sUp,"clavier/kTabUp.png");
                    sprintf(sDown,"clavier/kTabDown.png");
                break;
                case 27:
                    sprintf(sUp,"clavier/kEntreeUp.png");
                    sprintf(sDown,"clavier/kEntreeDown.png");
                break;
                case 28:
                    sprintf(sUp,"clavier/kVermajUp.png");
                    sprintf(sDown,"clavier/kVermajDown.png");
                break;
                case 41:
                    sprintf(sUp,"clavier/kMajUp.png");
                    sprintf(sDown,"clavier/kMajDown.png");
                break;
                case 53:
                    sprintf(sUp,"clavier/kVermajUp.png");
                    sprintf(sDown,"clavier/kVermajDown.png");
                break;
                case 57:
                    sprintf(sUp,"clavier/kEspUp.png");
                    sprintf(sDown,"clavier/kEspDown.png");
                break;
                default:
                    sprintf(sUp,"clavier/kVUp.png");
                    sprintf(sDown,"clavier/kVDown.png");
                break;
            }
        else
        {
            sprintf(sUp,"clavier/kMajUp.png");
            sprintf(sDown,"clavier/kMajDown.png");
        }
     
        t[i].keyUp = IMG_Load(sUp);
        t[i].keyDown = IMG_Load(sDown);
        t[i].p.h = t[i].keyUp->h;
        t[i].p.w = t[i].keyUp->w;
     
        if(t[i].keyUp == NULL || t[i].keyDown == NULL)
        {
            fprintf(stderr, "Erreur touche %i.", i);
            exit(EXIT_FAILURE);
        }
    }
    static void CLAVIER__returnChaineTouche(char sTexte[], const int j)//ok
    {
        switch(j)
        {
            case 0: sprintf(sTexte,"²"); break;//0 min
            case 1: sprintf(sTexte,"&"); break;//1 min
            case 2: sprintf(sTexte,"1"); break;//1 maj
            case 3: sprintf(sTexte,"é"); break;//2 min
            case 4: sprintf(sTexte,"2"); break;//2 maj
            case 5: sprintf(sTexte,"~"); break;//2 altGr
            case 6: sprintf(sTexte,"\""); break;//3 min
            case 7: sprintf(sTexte,"3"); break;//3 maj
            case 8: sprintf(sTexte,"#"); break;//3 altGr
            case 9: sprintf(sTexte,"'"); break;//4 min
            case 10: sprintf(sTexte,"4"); break;//4 maj
            case 11: sprintf(sTexte,"{"); break;//4 altGr
            case 12: sprintf(sTexte,"("); break;//5 min
            case 13: sprintf(sTexte,"5"); break;//5 maj
            case 14: sprintf(sTexte,"["); break;//5 altGr
            case 15: sprintf(sTexte,"-"); break;//6 min
            case 16: sprintf(sTexte,"6"); break;//6 maj
            case 17: sprintf(sTexte,"|"); break;//6 altGr
            case 18: sprintf(sTexte,"è"); break;//7 min
            case 19: sprintf(sTexte,"7"); break;//7 maj
            case 20: sprintf(sTexte,"`"); break;//7 altGr
            case 21: sprintf(sTexte,"_"); break;//8 min
            case 22: sprintf(sTexte,"8"); break;//8 maj
            case 23: sprintf(sTexte,"\\"); break;//8 altGr
            case 24: sprintf(sTexte,"ç"); break;//9 min
            case 25: sprintf(sTexte,"9"); break;//9 maj
            case 26: sprintf(sTexte,"^"); break;//9 alrGr
            case 27: sprintf(sTexte,"à"); break;//10 min
            case 28: sprintf(sTexte,"0"); break;//10 maj
            case 29: sprintf(sTexte,"@"); break;//10 altGr
            case 30: sprintf(sTexte,")"); break;//11 min
            case 31: sprintf(sTexte,"°"); break;//11 maj
            case 32: sprintf(sTexte,")"); break;//11 altGr
            case 33: sprintf(sTexte,"="); break;//12 min
            case 34: sprintf(sTexte,"+"); break; //12 maj
            case 35: sprintf(sTexte,"}"); break;//12 altGr
            case 36: sprintf(sTexte,"RetArr"); break;//13 min
            case 37: sprintf(sTexte,"Tab"); break;//14 min
            case 38: sprintf(sTexte,"a"); break;//15 min
            case 39: sprintf(sTexte,"A"); break;//15 maj
            case 40: sprintf(sTexte,"â"); break;//15 circonflexeMin
            case 41: sprintf(sTexte,"ä"); break;//15 circonflexeMaj
            case 42: sprintf(sTexte,"z"); break;//16 min
            case 43: sprintf(sTexte,"Z"); break;//16 maj
            case 44: sprintf(sTexte,"e"); break;//17 min
            case 45: sprintf(sTexte,"E"); break;//17 Maj
            case 46: sprintf(sTexte,"€"); break;//17 altGr
            case 47: sprintf(sTexte,"ê"); break;//17 circonflexeMin
            case 48: sprintf(sTexte,"ë"); break;//17 circonflexeMaj
            case 49: sprintf(sTexte,"r"); break;//18 min
            case 50: sprintf(sTexte,"R"); break;//18 maj
            case 51: sprintf(sTexte,"t"); break;//19 min
            case 52: sprintf(sTexte,"T"); break;//19 maj
            case 53: sprintf(sTexte,"y"); break;//20 min
            case 54: sprintf(sTexte,"Y"); break;//20 maj
            case 55: sprintf(sTexte,"y"); break;//15 circonflexeMaj
            case 56: sprintf(sTexte,"ÿ"); break;//15 circonflexeMaj
            case 57: sprintf(sTexte,"u"); break;//21 min
            case 58: sprintf(sTexte,"U"); break;//21 maj
            case 59: sprintf(sTexte,"û"); break;//21 circonflexeMin
            case 60: sprintf(sTexte,"ü"); break;//21 circonflexeMaj
            case 61: sprintf(sTexte,"i"); break;//22 min
            case 62: sprintf(sTexte,"I"); break;//22 maj
            case 63: sprintf(sTexte,"î"); break;//22 circonflexeMin
            case 64: sprintf(sTexte,"ï"); break;//22 circonflexeMaj
            case 65: sprintf(sTexte,"o"); break;//23 min
            case 66: sprintf(sTexte,"O"); break;//23 maj
            case 67: sprintf(sTexte,"ô"); break;//23 circonflexeMin
            case 68: sprintf(sTexte,"ö"); break;//23 circonflexeMaj
            case 69: sprintf(sTexte,"p"); break;//24 min
            case 70: sprintf(sTexte,"P"); break;//24 maj
            case 71: sprintf(sTexte,"^"); break;//25 min
            case 72: sprintf(sTexte,"¨"); break;//25 maj
            case 73: sprintf(sTexte,"$"); break;//26 min
            case 74: sprintf(sTexte,"£"); break;//26 maj
            case 75: sprintf(sTexte,"¤"); break;//26 altGr
            case 76: sprintf(sTexte,"Entrée"); break;//27 min
            case 77: sprintf(sTexte,"VerMaj"); break;//28 min
            case 78: sprintf(sTexte,"q"); break;//29 min
            case 79: sprintf(sTexte,"Q"); break;//29  maj
            case 80: sprintf(sTexte,"s"); break;//30 min
            case 81: sprintf(sTexte,"S"); break;//30 maj
            case 82: sprintf(sTexte,"d"); break;//31 min
            case 83: sprintf(sTexte,"D"); break;//31 maj
            case 84: sprintf(sTexte,"f"); break;//32 min
            case 85: sprintf(sTexte,"F"); break;//32 maj
            case 86: sprintf(sTexte,"g"); break;//33 min
            case 87: sprintf(sTexte,"G"); break;//33 maj
            case 88: sprintf(sTexte,"h"); break;//34 min
            case 89: sprintf(sTexte,"H"); break;//34 maj
            case 90: sprintf(sTexte,"j"); break;//35 min
            case 91: sprintf(sTexte,"J"); break;//35 maj
            case 92: sprintf(sTexte,"k"); break;//36 min
            case 93: sprintf(sTexte,"K"); break;//36 maj
            case 94: sprintf(sTexte,"l"); break;//37 min
            case 95: sprintf(sTexte,"L"); break;//37 maj
            case 96: sprintf(sTexte,"m"); break;//38 min
            case 97: sprintf(sTexte,"M"); break;//38 maj
            case 98: sprintf(sTexte,"ù"); break;//39 min
            case 99: sprintf(sTexte,"%%"); break;//39 maj
            case 100: sprintf(sTexte,"*"); break;//40 min
            case 101: sprintf(sTexte,"µ"); break;//40 maj
            case 102: sprintf(sTexte,"Maj"); break;//41 min
            case 103: sprintf(sTexte,"<"); break;//42 min
            case 104: sprintf(sTexte,">"); break;//42 maj
            case 105: sprintf(sTexte,"w"); break;//43 min
            case 106: sprintf(sTexte,"W"); break;//43 maj
            case 107: sprintf(sTexte,"x"); break;//44 min
            case 108: sprintf(sTexte,"X"); break;//44 maj
            case 109: sprintf(sTexte,"c"); break;//45min
            case 110: sprintf(sTexte,"C"); break;//45 maj
            case 111: sprintf(sTexte,"v"); break; //46 min
            case 112: sprintf(sTexte,"V"); break;//46 maj
            case 113: sprintf(sTexte,"b"); break;//47 min
            case 114: sprintf(sTexte,"B"); break;//47 maj
            case 115: sprintf(sTexte,"n"); break;//48 min
            case 116: sprintf(sTexte,"N"); break;//48 maj
            case 117: sprintf(sTexte,","); break;//49 min
            case 118: sprintf(sTexte,"?"); break;//49 maj
            case 119: sprintf(sTexte,";"); break;//50 min
            case 120: sprintf(sTexte,"."); break;//50 maj
            case 121: sprintf(sTexte,":"); break;//51 min
            case 122: sprintf(sTexte,"/"); break;//51 maj
            case 123: sprintf(sTexte,"!"); break;//52 min
            case 124: sprintf(sTexte,"§"); break;//52 maj
            case 125: sprintf(sTexte, "Maj"); break;//53 min
            case 126: sprintf(sTexte,"Ctrl"); break;//54 min
            case 127: sprintf(sTexte," "); break;//55 min
            case 128: sprintf(sTexte,"Alt"); break;//56 min
            case 129: sprintf(sTexte," "); break;//57 min
            case 130: sprintf(sTexte,"Alt Gr"); break;//58 min
            case 131: sprintf(sTexte," "); break;//59 min
            case 132: sprintf(sTexte,"Ctrl"); break;// 60 min
            default: break;
        }
    }
    static void CLAVIER__saveToucheTexteKey(Touche t[])//ok
    {
        char sTexte[100] = "";
        int i = 0, j = 0, loop;
     
        for(; i < nbT; i ++)
        {
    //save le caractère minuscule
            CLAVIER__returnChaineTouche(sTexte, j);
            t[i].keyMin = TTF_RenderText_Blended(police, sTexte, couleurTexteTouche);
            if(t[i].keyMin == NULL)
            {
                fprintf(stderr, "Erreur: T[%d].keyMin introuvable.\n", i);
                exit(EXIT_FAILURE);
            }
            t[i].pMin.x = t[i].keyUp->w / 2 - t[i].keyMin->w / 2;
            t[i].pMin.y = t[i].keyUp->h / 2 - t[i].keyMin->h / 2;
            j ++;
    //save les majuscules
            switch(i)
            case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 15:case 16:case 17:case 18:case 19:case 20:
            case 21:case 22:case 23:case 24:case 25:case 26:case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:
            case 40:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:
            {
                CLAVIER__returnChaineTouche(sTexte, j);
                t[i].keyMaj = TTF_RenderText_Blended(police, sTexte, couleurTexteTouche);
                if(t[i].keyMaj == NULL)
                {
                    fprintf(stderr, "Erreur: T[%d].keyMaj introuvable.\n", i);
                    exit(EXIT_FAILURE);
                }
                t[i].pMaj.x = t[i].keyUp->w / 2 - t[i].keyMaj->w / 2;
                t[i].pMaj.y = t[i].keyUp->h / 2 - t[i].keyMaj->h / 2;
                j ++;
            }
    //save les altGr
            switch(i)
            case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 17:case 26:
            {
                CLAVIER__returnChaineTouche(sTexte, j);
                t[i].keyAltGr = TTF_RenderText_Blended(police, sTexte, couleurTexteTouche);
                if(t[i].keyAltGr == NULL)
                {
                    fprintf(stderr, "Erreur: T[%d].keyAltGr introuvable.\n", i);
                    exit(EXIT_FAILURE);
                }
                t[i].pAltGr.x = t[i].keyUp -> w / 2 - t[i].keyAltGr->w / 2;
                t[i].pAltGr.y = t[i].keyUp -> h / 2 - t[i].keyAltGr->h / 2;
                j ++;
     
            }
    //save les circonflexes
            switch(i)
            case 15:case 17:case 20:case 21:case 22:case 23:
            {
                for(loop = 0; loop < 2; loop ++, j ++)
                {
                    CLAVIER__returnChaineTouche(sTexte, j);
                    if(loop == 0)
                    {
                        t[i].keyCirconflexeMin = TTF_RenderText_Blended(police, sTexte, couleurTexteTouche);
                        if(t[i].keyCirconflexeMin == NULL)
                        {
                            fprintf(stderr, "Erreur loop %d: T[%d].keyCirconflexeMin introuvable.\n", loop, i);
                            exit(EXIT_FAILURE);
                        }
                        t[i].pCirconflexeMin.x = t[i].keyUp -> w / 2 - t[i].keyCirconflexeMin->w / 2;
                        t[i].pCirconflexeMin.y = t[i].keyUp -> h / 2 - t[i].keyCirconflexeMin->h / 2;
                    }
                    else
                    {
                        t[i].keyCirconflexeMaj = TTF_RenderText_Blended(police, sTexte, couleurTexteTouche);
                        if(t[i].keyCirconflexeMaj == NULL)
                        {
                            fprintf(stderr, "Erreur loop %d: T[%d].keyCirconflexeMaj introuvable.\n", loop, i);
                            exit(EXIT_FAILURE);
                        }
                        t[i].pCirconflexeMaj.x = t[i].keyUp -> w / 2 - t[i].keyCirconflexeMaj->w / 2;
                        t[i].pCirconflexeMaj.y = t[i].keyUp -> h / 2 - t[i].keyCirconflexeMaj->h / 2;
                    }
                }
            }
        }
    }
    static void CLAVIER__savePTouche(Touche t[])
    {
        int i, x, y, xMax = t[0].keyUp->w * 13 + t[13].keyUp->w;
     
        for(i = 0, x = 0, y = 0; i < nbT; i ++)
        {
            t[i].p.x = x;
            t[i].p.y = y;
            t[i].xFin = x + t[i].keyUp->w - 1;
            t[i].yFin = y + t[i].keyUp->h - 1;
     
    //gère les décalages
            x += t[i].p.w;
            if(x > xMax - 1 || i == 40)
            {
                x = 0;
                y += t[0].p.h;
            }
            if(i == 53)
            {
                x = t[0].p.w * 0,17;
                y += t[0].p.h;
            }
        }
    }
    static void CLAVIER__supCaractere(char s[])
    {
        int i = 0;
     
        for(; s[i] != '\0'; i ++)
            ;
        if(i > 0)
            s[i-1] = '\0';
    }
    void        CLAVIER__Blit(Touche  T[], SDL_Surface *S, SDL_Event E)
    {
        int i = 0, majuscule = (maj || verMaj)? 1: 0;
        if(maj)
            majuscule = (verMaj)? 0 : 1;
     
        SDL_FillRect(S, NULL, couleurFond);
     
        for(i = 0; i < nbT; i ++)
        {
    //initialise de touche
            SDL_FillRect(T[i].keyUp, NULL, couleurFond);
            SDL_FillRect(T[i].keyDown, NULL, couleurFond);
     
    // save la touche en focntion de i
            CLAVIER__saveToucheImage(T, i);
    //circonflexe
            if(circonflexe && T[i].up && (i == 15 || i == 17 || (i >= 20 && i <= 23)))
            {
                if(circonflexe == 1)
                    SDL_BlitSurface(T[i].keyCirconflexeMin, NULL, T[i].keyUp, &T[i].pCirconflexeMin);
                else
                    CLAVIER__blitClavier(T[i].keyCirconflexeMaj, T[i].keyUp, T[i].pCirconflexeMaj.x, T[i].pCirconflexeMaj.y);
                CLAVIER__blitClavier(T[i].keyUp, S, T[i].p.x, T[i].p.y);
            }
            else if(circonflexe && (i == 15 || i == 17 || (i >= 20 && i <= 23)))
            {
                if(circonflexe == 1)
                    CLAVIER__blitClavier(T[i].keyCirconflexeMin, T[i].keyDown, T[i].pCirconflexeMin.x, T[i].pCirconflexeMin.y);
                else
                    CLAVIER__blitClavier(T[i].keyCirconflexeMaj, T[i].keyDown, T[i].pCirconflexeMaj.x, T[i].pCirconflexeMaj.y);
                CLAVIER__blitClavier(T[i].keyDown, S, T[i].p.x, T[i].p.y);
            }
    //altGr
            else if(alt && ctrl && T[i].up && ((i >= 2 && i <= 12) || i == 17 || i == 26))
            {
                CLAVIER__blitClavier(T[i].keyAltGr,T[i].keyUp, T[i].pAltGr.x, T[i].pAltGr.y);
                CLAVIER__blitClavier(T[i].keyUp, S,T[i].p.x, T[i].p.y);
            }
            else if(alt && ctrl && ((i >= 2 && i <= 12) || i == 17 || i == 26))
            {
                CLAVIER__blitClavier(T[i].keyAltGr,T[i].keyDown, T[i].pAltGr.x, T[i].pAltGr.y);
                CLAVIER__blitClavier(T[i].keyDown, S,T[i].p.x, T[i].p.y);
            }
    //majuscule
            else if(majuscule && T[i].up && i != 0 && i != 13 && i != 14 && i != 27 && i != 28 && i != 41 && i < 53)
            {
                CLAVIER__blitClavier(T[i].keyMaj, T[i].keyUp, T[i].pMaj.x, T[i].pMaj.y);
                CLAVIER__blitClavier(T[i].keyUp, S,T[i].p.x, T[i].p.y);
            }
            else if(majuscule && i != 0 && i != 13 && i != 14 && i != 27 && i != 28 && i != 41 && i < 53)
            {
                CLAVIER__blitClavier(T[i].keyMaj, T[i].keyDown, T[i].pMaj.x, T[i].pMaj.y);
                CLAVIER__blitClavier(T[i].keyDown, S,T[i].p.x, T[i].p.y);
            }
    //minuscule
            else if(T[i].up)
            {
                SDL_BlitSurface(T[i].keyMin, NULL, T[i].keyUp, &T[i].pMin);
                CLAVIER__blitClavier(T[i].keyUp, S, T[i].p.x, T[i].p.y);
            }
            else
            {
                CLAVIER__blitClavier(T[i].keyMin, T[i].keyDown, T[i].pMin.x, T[i].pMin.y);
                CLAVIER__blitClavier(T[i].keyDown, S, T[i].p.x, T[i].p.y);
            }
        }
        SDL_Flip(S);
    }
    Touche*     CLAVIER__Init(const int nombreTouche, Uint32 colorFond, SDL_Color colorTexte, const int tailleTexte)
    {
        Touche *t;
        int i;
     
    // initialise les variables globales
        couleurFond = colorFond;
        couleurTexteTouche = colorTexte;
        nbT = nombreTouche;
    // controle le nombre de touches
        if(nbT > 61 || nbT < 59)
        {
            fprintf(stderr,"nbTouche trop gros, ou trop petit.\nNe pas dépasser 61 et ne pas etre en dessous de 59 touches!\n");
            exit(EXIT_FAILURE);
        }
    // initialise TTF
        if(TTF_Init() < 0)
        {
            fprintf(stderr, "Erreur d'initiation TTF. %s", TTF_GetError());
            exit(EXIT_FAILURE);
        }
     
        if((police = TTF_OpenFont("arial.ttf", tailleTexte)) == NULL)
        {
            fprintf(stderr, "Erreur police TTF. %s", TTF_GetError());
            exit(EXIT_FAILURE);
        }
    // allocation dynamique en focntion de touche
        if((t = malloc(sizeof(Touche) * nbT)) == NULL)
        {
            fprintf(stderr,"Erreur d'allocation dynamique Touche.\n");
            exit(EXIT_FAILURE);
        }
    // initialisation de Touche t[]
        for(i = 0; i < nbT; i ++)
        {
            t[i].up = 1;
            t[i].keyCirconflexeMin = t[i].keyCirconflexeMaj = t[i].keyDown = t[i].keyUp = t[i].keyAltGr = NULL;
            t[i].p.x = t[i].p.y = t[i].pAltGr.x = t[i].pAltGr.y = t[i].pCirconflexeMin.x = t[i].pCirconflexeMin.y = t[i].pCirconflexeMaj.x =
            t[i].pCirconflexeMaj.y = t[i].pMaj.x = t[i].pMaj.y = t[i].pMin.x = t[i].pMin.y = 0;
        }
     
        for(i = 0; i < nbT; i ++)
    // enregistre l'image de la touche i
            CLAVIER__saveToucheImage(t, i);
    // enregistre le caractère sur la touche i
            CLAVIER__saveToucheTexteKey(t);
    //enregistre la position de toutes les touches
            CLAVIER__savePTouche(t);
        return &t[0];
    }
    void        CLAVIER__Quit(Touche t[])
    {
        int i;
     
        for(i = 0; i < nbT; i ++)
        {
            SDL_FreeSurface(t[i].keyUp);
            SDL_FreeSurface(t[i].keyDown);
            SDL_FreeSurface(t[i].keyAltGr);
            SDL_FreeSurface(t[i].keyCirconflexeMin);
            SDL_FreeSurface(t[i].keyCirconflexeMaj);
     
        }
        TTF_CloseFont(police);
        TTF_Quit();
        free(t);
    }
     
    // PARTIE CLAVIER
    void        CLAVIER__keyDown(SDL_Event e, Touche t[], char s[], const int tailleTab)
    {
        char c = 0;
        int taille = 0, m  = (maj || verMaj)? 1: 0, i = ((taille = strlen(s)) > 0 )? taille : 0;
     
        if(e.key.keysym.mod == KMOD_CAPS)
            verMaj = (verMaj)? 1: 0;
     
        if(maj)
            m = (maj == verMaj)? 0: 1;
     
        switch(e.key.keysym.sym)
        {
            case SDLK_BACKQUOTE: t[0].up = 0; break;//petit 2
            case SDLK_1: t[1].up = 0; c = (m)? '1': '&'; break;//1
            case SDLK_2: t[2].up = 0;
                if(alt && ctrl)
                    alt = ctrl = 0;
                else
                    c = (m)? '2': 'é';break;//2
            case SDLK_3: t[3].up = 0;
                if(alt && ctrl)
                    c = '#';
                else
                    c = (m)? '3': '\"';break;//3
            case SDLK_4: t[4].up = 0;
                if(alt && ctrl)
                    c = '{';
                else
                    c = (m)? '4': '\'';break;//4
            case SDLK_5: t[5].up = 0;
                if(alt && ctrl)
                    c = '[';
                else
                    c = (m)? '5': '(';break;//5
            case SDLK_6: t[6].up = 0;
                if(alt && ctrl)
                    c = '|';
                else
                    c = (m)? '6': '-';break;//6
            case SDLK_7: t[7].up = 0;
                if(alt && ctrl)
                    c = '`';
                else
                    c = (m)? '7': 'è';break;//7
            case SDLK_8: t[8].up = 0;
                if(alt && ctrl)
                    c = '\\';
                else
                    c = (m)? '8': '_';break;//8
            case SDLK_9: t[9].up = 0;
                if(alt && ctrl)
                    c = '^';
                else
                    c = (m)? '9': 'ç';break;//9
            case SDLK_0: t[10].up = 0;
                if(alt && ctrl)
                    c = '@';
                else
                    c = (m)? '0': 'à';break;//0
            case SDLK_MINUS: t[11].up = 0;
                if(alt && ctrl)
                    c = ']';
                else
                    c = (m)? '°': ')';break;//)
            case SDLK_EQUALS: t[12].up = 0;
                if(alt && ctrl)
                    c = '}';
                else
                    c = (m)? '+': '=';break;//=
            case SDLK_BACKSPACE: t[13].up = 0; CLAVIER__supCaractere(s); break;//supprimer
            case SDLK_TAB: t[14].up = 0; c = '\t'; break;//tab
            case SDLK_q: t[15].up = 0;
                if(!(circonflexe) || m)
                    c = (m)? 'A': 'a';
                else
                    c = ((circonflexe) == 2)? 'ä': 'â';
            break;//a
            case SDLK_w: t[16].up = 0; c = (m)? 'Z': 'z';break;//z
            case SDLK_e: t[17].up = 0;
                if(alt && ctrl)
                    c = '';
                else if(!(circonflexe) || m)
                    c = (m)? 'E': 'e';
                else
                    c = ((circonflexe) == 2)? 'ë': 'ê';
            break;//e
            case SDLK_r: t[18].up = 0; c = (m)? 'R': 'r';break;//r
            case SDLK_t: t[19].up = 0; c = (m)? 'T': 't';break;//t
            case SDLK_y: t[20].up = 0;
                if(!(circonflexe) || m)
                    c = (m)? 'Y': 'y';
                else
                    c = (circonflexe == 2)? 'ÿ': 'y';
            break;//y
            case SDLK_u: t[21].up = 0;
                if(!(circonflexe) || m)
                    c = (m)? 'U': 'u';
                else
                    c = (circonflexe == 2)? 'ü': 'û';
            break;//u
            case SDLK_i: t[22].up = 0;
                if(!(circonflexe) || m)
                    c = (m)? 'I': 'i';
                else
                    c = (circonflexe == 2)? 'ï': 'î';
            break;//i
            case SDLK_o: t[23].up = 0;
                if(!(circonflexe) || m)
                    c = (m)? 'O': 'o';
                else
                    c = (circonflexe == 2)? 'ö': 'ô';
            break;//o
            case SDLK_p: t[24].up = 0; c = (m)? 'P': 'p';break;//p
            case SDLK_LEFTBRACKET: t[25].up = 0; circonflexe = (m)? 2: 1; maj = 0;break;//^
            case SDLK_RIGHTBRACKET: t[26].up = 0;
                if(alt && ctrl)
                    c = '¤';
                else
                    c = (m)? '£': '$';break;//$
            case SDLK_RETURN: t[27].up = 0; c = '\n'; break;//\n
            case SDLK_CAPSLOCK: t[28].up = (t[28].up)? 0 : 1;
                verMaj = (verMaj)? 0: 1; break;//VerMaj
            case SDLK_a: t[29].up = 0; c = (m)? 'Q': 'q';break;//q
            case SDLK_s: t[30].up = 0; c = (m)? 'S': 's';break;//s
            case SDLK_d: t[31].up = 0; c = (m)? 'D': 'd';break;//d
            case SDLK_f: t[32].up = 0; c = (m)? 'F': 'f';break;//f
            case SDLK_g: t[33].up = 0; c = (m)? 'G': 'g';break;//g
            case SDLK_h: t[34].up = 0; c = (m)? 'H': 'h';break;//h
            case SDLK_j: t[35].up = 0; c = (m)? 'J': 'j';break;//j
            case SDLK_k: t[36].up = 0; c = (m)? 'K': 'k';break;//k
            case SDLK_l: t[37].up = 0; c = (m)? 'L': 'l';break;//l
            case SDLK_SEMICOLON: t[38].up = 0; c = (m)? 'M': 'm';break;//m
            case SDLK_QUOTE: t[39].up = 0;  c = (m)? '%': 'ù';break;//%
            case SDLK_BACKSLASH: t[40].up = 0; c = (m)? 'µ': '*';break;//*
            case SDLK_LSHIFT: t[41].up = t[53].up = (t[41].up)? 0: 1;
                maj = (t[41].up)? 0 : 1; break;//majGauche
            case SDLK_LESS: t[42].up = 0; c = (m)? '>': '<';break;//<
            case SDLK_z: t[43].up = 0; c = (m)? 'W': 'w';break;//w
            case SDLK_x: t[44].up = 0; c = (m)? 'X': 'x';break;//x
            case SDLK_c: t[45].up = 0; c = (m)? 'C': 'c';break;//c
            case SDLK_v: t[46].up = 0; c = (m)? 'V': 'v';break;//v
            case SDLK_b: t[47].up = 0; c = (m)? 'B': 'b';break;//b
            case SDLK_n: t[48].up = 0; c = (m)? 'N': 'n';break;//n
            case SDLK_m: t[49].up = 0; c = (m)? '?': ',';break;//,
            case SDLK_COMMA: t[50].up = 0; c = (m)? '.': ';';break;//;
            case SDLK_PERIOD: t[51].up = 0; c = (m)? '/': ':';break;//:
            case SDLK_SLASH: t[52].up = 0; c = (m)? '§': '!';break;//!
            case SDLK_RSHIFT: maj = t[53].up = t[41].up = (t[41].up)? 0: 1;
                maj = (t[41].up)? 0 : 1; break;//majDroit
            case SDLK_LCTRL: ctrl = 1; t[54].up = 0; break;//CtrlGauche
            case SDLK_LSUPER: t[55].up = 0; break;//Windows
            case SDLK_LALT: alt = 1 ; t[56].up = 0; break;//alt
            case SDLK_SPACE: t[57].up = 0; c = ' '; break;//espace
            case SDLK_RALT: ctrl = alt = 1; t[58].up = 0; t[54].up = 1; break;//Alt Gr
            case SDLK_MENU: t[59].up = 0; break;//vide
            case SDLK_RCTRL: ctrl = 1; t[60].up = 0; break;//CtrlDroite
            default: break;
        }
     
        if(c != 0)
        {
            alt = ctrl = circonflexe = maj = 0;
            t[41].up = t[53].up = 1;
        }
     
        if(i < tailleTab-1)
        {
            s[i] = c;
            s[++i] = '\0';
        }
    }
    void        CLAVIER__keyUp(SDL_Event e, Touche t[])
    {
        switch(e.key.keysym.sym)
        {
            case SDLK_BACKQUOTE: t[0].up = 1; break;
            case SDLK_1: t[1].up = 1; break;
            case SDLK_2: t[2].up = 1; break;
            case SDLK_3: t[3].up = 1; break;
            case SDLK_4: t[4].up = 1; break;
            case SDLK_5: t[5].up = 1; break;
            case SDLK_6: t[6].up = 1; break;
            case SDLK_7: t[7].up = 1; break;
            case SDLK_8: t[8].up = 1; break;
            case SDLK_9: t[9].up = 1; break;
            case SDLK_0: t[10].up = 1; break;
            case SDLK_MINUS: t[11].up = 1; break;
            case SDLK_EQUALS: t[12].up = 1; break;
            case SDLK_BACKSPACE: t[13].up = 1; break;
            case SDLK_TAB: t[14].up = 1; break;
            case SDLK_q: t[15].up = 1; break;
            case SDLK_w: t[16].up = 1; break;
            case SDLK_e: t[17].up = 1; break;
            case SDLK_r: t[18].up = 1; break;
            case SDLK_t: t[19].up = 1; break;
            case SDLK_y: t[20].up = 1; break;
            case SDLK_u: t[21].up = 1; break;
            case SDLK_i: t[22].up = 1; break;
            case SDLK_o: t[23].up = 1; break;
            case SDLK_p: t[24].up = 1; break;
            case SDLK_LEFTBRACKET: t[25].up = 1; break;
            case SDLK_RIGHTBRACKET: t[26].up = 1; break;
            case SDLK_RETURN: t[27].up = 1; break;
            case SDLK_CAPSLOCK: t[28].up = 1; verMaj = (verMaj)? 0: 1; break;
            case SDLK_a: t[29].up = 1; break;
            case SDLK_s: t[30].up = 1; break;
            case SDLK_d: t[31].up = 1; break;
            case SDLK_f: t[32].up = 1; break;
            case SDLK_g: t[33].up = 1; break;
            case SDLK_h: t[34].up = 1; break;
            case SDLK_j: t[35].up = 1; break;
            case SDLK_k: t[36].up = 1; break;
            case SDLK_l: t[37].up = 1; break;
            case SDLK_SEMICOLON: t[38].up = 1; break;
            case SDLK_QUOTE: t[39].up = 1; break;
            case SDLK_BACKSLASH: t[40].up = 1; break;
            case SDLK_LSHIFT: maj = 0; t[53].up = t[41].up = 1; break;
            case SDLK_LESS: t[42].up = 1; break;
            case SDLK_z: t[43].up = 1; break;
            case SDLK_x: t[44].up = 1; break;
            case SDLK_c: t[45].up = 1; break;
            case SDLK_v: t[46].up = 1; break;
            case SDLK_b: t[47].up = 1; break;
            case SDLK_n: t[48].up = 1; break;
            case SDLK_m: t[49].up = 1; break;
            case SDLK_COMMA: t[50].up = 1; break;
            case SDLK_PERIOD: t[51].up = 1; break;
            case SDLK_SLASH: t[52].up = 1; break;
            case SDLK_RSHIFT: maj = 0; t[53].up = t[41].up = 1;break;
            case SDLK_LCTRL: ctrl = 0; t[54].up = 1; break;
            case SDLK_LSUPER: t[55].up = 1; break;
            case SDLK_LALT: alt = 0; t[56].up = 1; break;
            case SDLK_SPACE: t[57].up = 1; break;
            case SDLK_RALT: alt = ctrl = 0; t[58].up = 1; break;
            case SDLK_MENU: t[59].up = 1; break;
            case SDLK_RCTRL: ctrl = 0; t[60].up = 1; break;
            default: break;
        }
    }
     
    //PARTIE SOURIS
    void        CLAVIER__MouseDown(SDL_Event e, Touche t[], char s[], const int tailleTab)
    {
        char c = 0;
        int taille = 0, m  = (maj || verMaj)? 1: 0, i = 0;
     
        if(maj)
            m = (maj == verMaj)? 0: 1;
     
        for(; i < nbT; i ++)
            if(e.motion.x >= t[i].p.x && e.motion.x <= t[i].xFin && e.motion.y >= t[i].p.y && e.motion.y <= t[i].yFin)
                switch(i)
                {
                    case 0: t[0].up = 0; break;//petit 2
                    case 1: t[1].up = 0; c = (m)? '1': '&'; break;//1
                    case 2: t[2].up = 0;
                        if(alt && ctrl)
                            c = '~';
                        else
                            c = (m)? '2': 'é'; break;//2
                    case 3: t[3].up = 0;
                        if(alt && ctrl)
                            c = '#';
                        else
                            c = (m)? '3': '\"'; break;//3
                    case 4: t[4].up = 0;
                        if(alt && ctrl)
                            c = '{';
                        else
                            c = (m)? '4': '\'';break;//4
                    case 5: t[5].up = 0;
                        if(alt && ctrl)
                            c = '[';
                        else
                            c = (m)? '5': '(';break;//5
                    case 6: t[6].up = 0;
                        if(alt && ctrl)
                            c = '|';
                        else
                            c = (m)? '6': '-';break;//6
                    case 7: t[7].up = 0;
                        if(alt && ctrl)
                            c = '`';
                        else
                            c = (m)? '7': 'è';break;//7
                    case 8: t[8].up = 0;
                        if(alt && ctrl)
                            c = '\\';
                        else
                            c = (m)? '8': '_';break;//8
                    case 9: t[9].up = 0;
                        if(alt && ctrl)
                            c = '^';
                        else
                            c = (m)? '9': 'ç';break;//9
                    case 10: t[10].up = 0;
                        if(alt && ctrl)
                            c = '@';
                        else
                            c = (m)? '0': 'à';break;//0
                    case 11: t[11].up = 0;
                        if(alt && ctrl)
                            c = ']';
                        else
                            c = (m)? '°': ')';break;//)
                    case 12: t[12].up = 0;
                        if(alt && ctrl)
                            c = '}';
                        else
                            c = (m)? '+': '=';break;//=
                    case 13: t[13].up = 0; CLAVIER__supCaractere(s); break;//supprimer
                    case 14: t[14].up = 0; c = '\t'; break;//tab
                    case 15: t[15].up = 0;
                        if(!(circonflexe) || m)
                            c = (m)? 'A': 'a';
                        else
                            c = ((circonflexe) == 2)? 'ä': 'â'; break;//a
                    case 16: t[16].up = 0; c = (m)? 'Z': 'z';break;//z
                    case 17: t[17].up = 0;
                        if(alt && ctrl)
                        {
                            c = '';
                            alt = ctrl = 0;
                        }
                        else if(!(circonflexe) || m)
                            c = (m)? 'E': 'e';
                        else
                            c = (circonflexe == 2)? 'ë': 'ê'; break;//e
                    case 18: t[18].up = 0; c = (m)? 'R': 'r';break;//r
                    case 19: t[19].up = 0; c = (m)? 'T': 't';break;//t
                    case 20: t[20].up = 0;
                        if(!(circonflexe) || m)
                            c = (m)? 'Y': 'y';
                        else
                            c = (circonflexe == 2)? 'ÿ': 'y'; break;//y
                    case 21: t[21].up = 0;
                        if(!(circonflexe) || m)
                            c = (m)? 'U': 'u';
                        else
                            c = (circonflexe == 2)? 'ü': 'û'; break;//u
                    case 22: t[22].up = 0;
                        if(!(circonflexe) || m)
                            c = (m)? 'I': 'i';
                        else
                            c = (circonflexe == 2)? 'ï': 'î'; break;//i
                    case 23: t[23].up = 0;
                        if(!(circonflexe) || m)
                            c = (m)? 'O': 'o';
                        else
                            c = (circonflexe == 2)? 'ö': 'ô'; break;//o
                    case 24: t[24].up = 0; c = (m)? 'P': 'p';break;//p
                    case 25: t[25].up = 0;
                        if(circonflexe == 0)
                        {
                            circonflexe = (m)? 2: 1;
                            maj = 0;
                        }
                        else
                            maj = circonflexe = 0;
                    break;//^
                    case 26: t[26].up = 0;
                        if(alt && ctrl)
                            c = '¤';
                        else
                            c = (m)? '£': '$';break;//$
                    case 27: t[27].up = 0; c = '\n'; break;//\n
                    case 28: t[28].up = (t[28].up)? 0 : 1;
                        verMaj = (verMaj)? 0: 1; break;//VerMaj
                    case 29: t[29].up = 0 ; c = (m)? 'Q': 'q';break;//q
                    case 30: t[30].up = 0 ; c = (m)? 'S': 's';break;//s
                    case 31: t[31].up = 0 ; c = (m)? 'D': 'd';break;//d
                    case 32: t[32].up = 0 ; c = (m)? 'F': 'f';break;//f
                    case 33: t[33].up = 0 ; c = (m)? 'G': 'g';break;//g
                    case 34: t[34].up = 0 ; c = (m)? 'H': 'h';break;//h
                    case 35: t[35].up = 0 ; c = (m)? 'J': 'j';break;//j
                    case 36: t[36].up = 0 ; c = (m)? 'K': 'k';break;//k
                    case 37: t[37].up = 0; c = (m)? 'L': 'l';break;//l
                    case 38: t[38].up = 0; c = (m)? 'M': 'm';break;//m
                    case 39: t[39].up = 0; c = (m)? '%': 'ù';break;//%
                    case 40: t[40].up = 0; c = (m)? 'µ': '*';break;//*
                    case 41: t[41].up = t[53].up = (t[41].up)? 0: 1;
                        maj = (t[41].up)? 0 : 1; break;//majGauche
                    case 42: t[42].up = 0; c = (m)? '>': '<';break;//<
                    case 43: t[43].up = 0; c = (m)? 'W': 'w';break;//w
                    case 44: t[44].up = 0; c = (m)? 'X': 'x';break;//x
                    case 45: t[45].up = 0; c = (m)? 'C': 'c';break;//c
                    case 46: t[46].up = 0; c = (m)? 'V': 'v';break;//v
                    case 47: t[47].up = 0; c = (m)? 'B': 'b';break;//b
                    case 48: t[48].up = 0; c = (m)? 'N': 'n';break;//n
                    case 49: t[49].up = 0; c = (m)? '?': ',';break;//,
                    case 50: t[50].up = 0; c = (m)? '.': ';';break;//;
                    case 51: t[51].up = 0; c = (m)? '/': ':';break;//:
                    case 52: t[52].up = 0; c = (m)? '§': '!';break;//!
                    case 53: maj = t[53].up = t[41].up = (t[41].up)? 0: 1;
                        maj = (t[41].up)? 0 : 1; break;//majDroit
                    case 54: t[60].up = t[54].up = 0; ctrl = (ctrl)? 0: 1; break;//CtrlGauche
                    case 55: t[55].up = 0; break;//Windows
                    case 56: t[56].up = 0; alt = (alt)? 0 : 1; break;//alt
                    case 57: t[57].up = 0; c = ' '; break;//espace
                    case 58: t[58].up = (t[58].up)? 0: 1; ctrl = alt = (alt)? 0 : 1; break;//Alt Gr
                    case 59: t[59].up = 0; break;//vide
                    case 60: t[60].up = t[54].up = 0; ctrl = (ctrl)? 0: 1; break;//CtrlDroite
                    default: break;
                }
     
    //met fin a altGr ou maj si un caractère est utilisé
        if(c != 0 || t[25].up == 0)
        {
    //suprime le maj 1 quand '^' est utilisé
            if(t[25].up)
                circonflexe = 0;
     
            alt = ctrl = maj = 0;
            t[54].up = t[60].up = t[56].up = t[41].up = t[53].up = 1;
        }
    //gere altGr
        if(ctrl && alt && t[58].up == 0)
        {
            t[54].up = t[60].up = t[56].up = 1;
     
        }
        else if(t[54].up == 0 && t[56].up == 0)
        {
            t[60].up = ctrl = alt = t[54].up = t[56].up = 1;
            t[58].up = 0;
        }
        else
            t[58].up = 1;
     
    //controle si il y a assé de place dans le tableau et ajoute le caractère
        i = ((taille = strlen(s)) > 0 )? taille : 0;
        if(i < tailleTab-1)
        {
            s[i] = c;
            s[++i] = '\0';
        }
    }
    void        CLAVIER__MouseUp(SDL_Event e, Touche t[])
    {
        int i = 0;
        for(; i < nbT; i ++)
            if(e.motion.x >= t[i].p.x && e.motion.x <= t[i].xFin && e.motion.y >= t[i].p.y && e.motion.y <= t[i].yFin)
                switch(i)
                {
                    case 0: t[0].up = 1; break;
                    case 1: t[1].up = 1; break;
                    case 2: t[2].up = 1; break;
                    case 3: t[3].up = 1; break;
                    case 4: t[4].up = 1; break;
                    case 5: t[5].up = 1; break;
                    case 6: t[6].up = 1; break;
                    case 7: t[7].up = 1; break;
                    case 8: t[8].up = 1; break;
                    case 9: t[9].up = 1; break;
                    case 10: t[10].up = 1; break;
                    case 11: t[11].up = 1; break;
                    case 12: t[12].up = 1; break;
                    case 13: t[13].up = 1; break;
                    case 14: t[14].up = 1; break;
                    case 15: t[15].up = 1; break;
                    case 16: t[16].up = 1; break;
                    case 17: t[17].up = 1; break;
                    case 18: t[18].up = 1; break;
                    case 19: t[19].up = 1; break;
                    case 20: t[20].up = 1; break;
                    case 21: t[21].up = 1; break;
                    case 22: t[22].up = 1; break;
                    case 23: t[23].up = 1; break;
                    case 24: t[24].up = 1; break;
                    case 25: t[25].up = 1; break;
                    case 26: t[26].up = 1; break;
                    case 27: t[27].up = 1; break;
                    case 28: t[28].up = (verMaj)? 0: 1;break;
                    case 29: t[29].up = 1; break;
                    case 30: t[30].up = 1; break;
                    case 31: t[31].up = 1; break;
                    case 32: t[32].up = 1; break;
                    case 33: t[33].up = 1; break;
                    case 34: t[34].up = 1; break;
                    case 35: t[35].up = 1; break;
                    case 36: t[36].up = 1; break;
                    case 37: t[37].up = 1; break;
                    case 38: t[38].up = 1; break;
                    case 39: t[39].up = 1; break;
                    case 40: t[40].up = 1; break;
                    case 41: t[53].up = t[41].up = (maj)? 0: 1;break;
                    case 42: t[42].up = 1; break;
                    case 43: t[43].up = 1; break;
                    case 44: t[44].up = 1; break;
                    case 45: t[45].up = 1; break;
                    case 46: t[46].up = 1; break;
                    case 47: t[47].up = 1; break;
                    case 48: t[48].up = 1; break;
                    case 49: t[49].up = 1; break;
                    case 50: t[50].up = 1; break;
                    case 51: t[51].up = 1; break;
                    case 52: t[52].up = 1; break;
                    case 53: t[53].up = t[41].up = (maj)? 0: 1;break;
                    case 55: t[55].up = 1; break;
                    case 57: t[57].up = 1; break;
                    case 59: t[59].up = 1; break;
                    default: break;
                }
    }
    clavier.h (mes prototypes)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    #include <SDL/SDL.h>
     
    #define TAILLE_TAB 100
     
    #define FALSE 0
    #define TRUE 1
     
    typedef struct
    {
        SDL_Surface *keyUp, *keyDown, *keyAltGr, *keyCirconflexeMin, *keyCirconflexeMaj, *keyMaj, *keyMin;
        SDL_Rect p, pAltGr, pCirconflexeMin, pCirconflexeMaj, pMaj, pMin;
        int up, xFin, yFin;
    }Touche;
     
    // PARTIE GENERALE
    Touche*     CLAVIER__Init(const int nombreTouche, Uint32 colorFond, SDL_Color colorTexte, const int tailleTexte);
    void        CLAVIER__Quit(Touche t[]);
    void        CLAVIER__Blit(Touche  t[], SDL_Surface *s, SDL_Event e);
     
    // PARTIE CLAVIER
    void        CLAVIER__keyDown(SDL_Event e, Touche t[], char s[], const int tailleTab);
    void        CLAVIER__keyUp(SDL_Event e, Touche t[]);
     
    // PARTIE SOURIS
    void        CLAVIER__MouseDown(SDL_Event e, Touche t[], char s[], const int tailleTab);
    void        CLAVIER__MouseUp(SDL_Event e, Touche t[]);
    Avec ca, ca devrai aller

    Si il y a des curieux, voici un lien, pour tout le code source, images...
    https://mega.co.nz/#!jBEHDQRT!A-ULzH...NUticCKLxozwlw

    Je pense vraiment pouvoir mieux gérer les switch, et aussi je pense pouvoir gagner au niveau de la fonction "CLAVIER__Blit". Je vous remerci d'avoir regardé mon code, tout le monde a débuté un jour

    Bonne soirée

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    Salut,

    Je pense que le problème est que tu n'as pas mis de sleep(...) dans ta boucle while (le code dans la boucle est donc exécuté plein de fois pour rien)

  3. #3
    Membre averti
    Homme Profil pro
    plombier
    Inscrit en
    Décembre 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : plombier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Décembre 2012
    Messages : 31
    Par défaut
    Boboss123 Merci de ta réponse.
    SDL_Waitevent, ma pas besoin de sleep()
    SDL_PollEvent, est la même boucle sauf qu'elle n'attend pas d’évènement pour être exécutée .

    Mon erreur venait du fait que j'utilisais IMG_Load dans chaque boucle.
    Ce que j'ai fait, c'est crée une variable baseUp, et baseDown dans ma structure Touche, et je blit cette image sur la touche.

    Mon explication n'est pas top...en gros, voici les fonctions que j'ai changées

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    static void CLAVIER__saveToucheImage(Touche T[])
    {
    //charge les 16 images différentes qui compose le clavier. en fonction de i.
        char sUp[TAILLE_TAB] = "", sDown[TAILLE_TAB] = "";
        int i = 0;
     
        for(i = 0; i < nbT; i ++)
        {
            if(i <= 53 || i == 57)
                switch(i)
                {
                    case 13:
                        sprintf(sUp,"clavier/kRetUp.png");
                        sprintf(sDown,"clavier/kRetDown.png");
                    break;
                    case 14:
                        sprintf(sUp,"clavier/kTabUp.png");
                        sprintf(sDown,"clavier/kTabDown.png");
                    break;
                    case 27:
                        sprintf(sUp,"clavier/kEntreeUp.png");
                        sprintf(sDown,"clavier/kEntreeDown.png");
                    break;
                    case 28:
                        sprintf(sUp,"clavier/kVermajUp.png");
                        sprintf(sDown,"clavier/kVermajDown.png");
                    break;
                    case 41:
                        sprintf(sUp,"clavier/kMajUp.png");
                        sprintf(sDown,"clavier/kMajDown.png");
                    break;
                    case 53:
                        sprintf(sUp,"clavier/kVermajUp.png");
                        sprintf(sDown,"clavier/kVermajDown.png");
                    break;
                    case 57:
                        sprintf(sUp,"clavier/kEspUp.png");
                        sprintf(sDown,"clavier/kEspDown.png");
                    break;
                    default:
                        sprintf(sUp,"clavier/kVUp.png");
                        sprintf(sDown,"clavier/kVDown.png");
                    break;
                }
            else
            {
                sprintf(sUp,"clavier/kMajUp.png");
                sprintf(sDown,"clavier/kMajDown.png");
            }
    //save l'image en cour
            T[i].baseUp = IMG_Load(sUp);
            T[i].keyUp = IMG_Load(sUp);
            T[i].baseDown = IMG_Load(sDown);
            T[i].keyDown = IMG_Load(sDown);
            if(T[i].baseUp == NULL || T[i].baseDown == NULL || T[i].keyUp == NULL || T[i].keyDown == NULL)
            {
                fprintf(stderr, "Erreur touche %i.", i);
                exit(EXIT_FAILURE);
            }
     
            T[i].p.h = T[i].baseUp->h;
            T[i].p.w = T[i].baseUp->w;
        }
    }
     
    void        CLAVIER__Blit(Touche  T[], SDL_Surface *S, SDL_Event E)
    {
    /* - 1: Blitte le texte sur la touche
       - 2: Blitte la touche sur S
    */
        int i = 0, majuscule = (maj || verMaj)? 1: 0;
     
        if(maj)
            majuscule = (verMaj)? 0 : 1;
     
        SDL_FillRect(S, NULL, couleurFond);
     
        for(i = 0; i < nbT; i ++)
        {
    //circonflexe
            if(circonflexe && T[i].up && (i == 15 || i == 17 || (i >= 20 && i <= 23)))
            {
            //initialise de touche
                SDL_FillRect(T[i].keyUp, NULL, couleurFond);
            // blitte la base, qui est l'image de la touche, sur la touche
                CLAVIER__blitClavier(T[i].baseUp, T[i].keyUp, 0, 0);
            //blitte sur la touche, le caractère
                if(circonflexe == 1)
                    SDL_BlitSurface(T[i].keyCirconflexeMin, NULL, T[i].keyUp, &T[i].pCirconflexeMin);
                else
                    CLAVIER__blitClavier(T[i].keyCirconflexeMaj, T[i].keyUp, T[i].pCirconflexeMaj.x, T[i].pCirconflexeMaj.y);
            //ajoute la touche sur la surface
                CLAVIER__blitClavier(T[i].keyUp, S, T[i].p.x, T[i].p.y);
            }
            else if(circonflexe && (i == 15 || i == 17 || (i >= 20 && i <= 23)))
            {
                SDL_FillRect(T[i].keyDown, NULL, couleurFond);
                CLAVIER__blitClavier(T[i].baseDown, T[i].keyUp, 0, 0);
                if(circonflexe == 1)
                    CLAVIER__blitClavier(T[i].keyCirconflexeMin, T[i].keyDown, T[i].pCirconflexeMin.x, T[i].pCirconflexeMin.y);
                else
                    CLAVIER__blitClavier(T[i].keyCirconflexeMaj, T[i].keyDown, T[i].pCirconflexeMaj.x, T[i].pCirconflexeMaj.y);
                CLAVIER__blitClavier(T[i].keyDown, S, T[i].p.x, T[i].p.y);
            }
    //altGr
            else if(alt && ctrl && T[i].up && ((i >= 2 && i <= 12) || i == 17 || i == 26))
            {
                SDL_FillRect(T[i].keyUp, NULL, couleurFond);
                CLAVIER__blitClavier(T[i].baseUp, T[i].keyUp, 0, 0);
                CLAVIER__blitClavier(T[i].keyAltGr,T[i].keyUp, T[i].pAltGr.x, T[i].pAltGr.y);
                CLAVIER__blitClavier(T[i].keyUp, S,T[i].p.x, T[i].p.y);
            }
            else if(alt && ctrl && ((i >= 2 && i <= 12) || i == 17 || i == 26))
            {
                SDL_FillRect(T[i].keyDown, NULL, couleurFond);
                CLAVIER__blitClavier(T[i].baseDown, T[i].keyDown, 0, 0);
                CLAVIER__blitClavier(T[i].keyAltGr,T[i].keyDown, T[i].pAltGr.x, T[i].pAltGr.y);
                CLAVIER__blitClavier(T[i].keyDown, S,T[i].p.x, T[i].p.y);
            }
    //majuscule
            else if(majuscule && T[i].up && i != 0 && i != 13 && i != 14 && i != 27 && i != 28 && i != 41 && i < 53)
            {
                SDL_FillRect(T[i].keyUp, NULL, couleurFond);
                CLAVIER__blitClavier(T[i].baseUp, T[i].keyUp, 0, 0);
                CLAVIER__blitClavier(T[i].keyMaj, T[i].keyUp, T[i].pMaj.x, T[i].pMaj.y);
                CLAVIER__blitClavier(T[i].keyUp, S,T[i].p.x, T[i].p.y);
            }
            else if(majuscule && i != 0 && i != 13 && i != 14 && i != 27 && i != 28 && i != 41 && i < 53)
            {
                SDL_FillRect(T[i].keyDown, NULL, couleurFond);
                CLAVIER__blitClavier(T[i].baseDown, T[i].keyDown, 0, 0);
                CLAVIER__blitClavier(T[i].keyMaj, T[i].keyDown, T[i].pMaj.x, T[i].pMaj.y);
                CLAVIER__blitClavier(T[i].keyDown, S,T[i].p.x, T[i].p.y);
            }
    //minuscule
            else if(T[i].up)
            {
            //initialise de touche
                SDL_FillRect(T[i].keyUp, NULL, couleurFond);
     
                CLAVIER__blitClavier(T[i].baseUp, T[i].keyUp, 0, 0);
                CLAVIER__blitClavier(T[i].keyMin, T[i].keyUp, T[i].pMin.x, T[i].pMin.y);
                CLAVIER__blitClavier(T[i].keyUp, S, T[i].p.x, T[i].p.y);
            }
            else
            {
            //initialise de touche
                SDL_FillRect(T[i].keyDown, NULL, couleurFond);
     
                CLAVIER__blitClavier(T[i].baseDown, T[i].keyDown, 0, 0);
                CLAVIER__blitClavier(T[i].keyMin, T[i].keyDown, T[i].pMin.x, T[i].pMin.y);
                CLAVIER__blitClavier(T[i].keyDown, S, T[i].p.x, T[i].p.y);
            }
        }
        SDL_Flip(S);
    }
     
    typedef struct
    {
        SDL_Surface *keyUp, *keyDown, *keyAltGr, *keyCirconflexeMin, *keyCirconflexeMaj, *keyMaj, *keyMin, *baseUp, *baseDown;
        SDL_Rect p, pAltGr, pCirconflexeMin, pCirconflexeMaj, pMaj, pMin;
        int up, xFin, yFin;
    }Touche;
    Maintenant, j'ai une question

    Avez vous une idée, pour optimiser mes switch, ....

    Je trouve ca vraiment moche un switch de 130 lignes, et 2 de 61 lignes

    Merci

  4. #4
    Membre expérimenté Avatar de moins1
    Homme Profil pro
    Autre
    Inscrit en
    Février 2013
    Messages
    85
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Autre
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2013
    Messages : 85
    Par défaut
    Pour ta fonction CLAVIER__returnChaineTouche() tu pourrais te faire une table de correspondance.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    struct tablec
    {
        int code;
        char ch[10];
    };
    Que tu déclares un peu comme ça
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    struct tablec cor[] = 
        {{2, "a"},
         {3, "g"},
         {117, "ctrl"}};
    Ensuite il ne te reste qu'à faire une petite fonction qui cherche le code.



    Note: Pour trouver le nombre d'éléments dans la table
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     int taillec = sizeof(cor) / sizeof(cor[0]);

  5. #5
    Expert confirmé
    Avatar de Mat.M
    Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2006
    Messages
    8 528
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2006
    Messages : 8 528
    Par défaut
    salut oui une table de correspondance serait appropriée.
    Sinon une solution sophistiquée me semble-t-il car je n'ai pas tout décortiqué le code c'est d'utiliser des listes chainées.
    Ainsi si tu appuies sur une touche du clavier, tu effectues une recherche dans la liste et tu te positionnes sur le bon élément qui va te retourner l'image voulue

  6. #6
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    1 855
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 1 855
    Par défaut
    C'est quoi l’intérêt d'utiliser une liste chainer a part perdre de l'espace mémoire inutilement et réduire la vitesse de ton programme ?

    Pour accélérer tes recherches, tu peux faire des recherches par dichotomie dans ton tableau.

    Sinon tu peux utiliser l'index du tableau comme valeur d'entrée mais tu perdra de l'espace mémoire (est-ce vraiment gênant ?).
    => c'est peut-être plus rapide que d'utiliser de la dichotomie (est-ce utile ?) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
     
    typedef struct{
    	char *sUp;
    	char *sDown;
    } STRUCT_IMG_TAB;
     
    char stdStr_sUp[] = "clavier/kVUp.png";
    char stdStr_sDown[] = "clavier/kVDown.png";
     
    static STRUCT_IMG_TAB imgTab[] = {
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 00
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 01
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 02
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 03
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 04
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 05
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 06
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 07
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 08
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 09
     
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 10
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 11
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 12
    	{.sUp = "clavier/kRetUp.png", .sDown = "clavier/kRetDown.png"}, // 13
    	{.sUp = "clavier/kTabUp.png", .sDown = "clavier/kTabDown.png"}, // 14
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 15
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 16
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 17
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 18
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 19
     
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 20
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 21
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 22
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 23
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 24
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 25
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 26
    	{.sUp = "clavier/kEntreeUp.png", .sDown = "clavier/kEntreeDown.png"}, // 27
    	{.sUp = "clavier/kVermajUp.png", .sDown = "clavier/kVermajDown.png"}, // 28
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 29
     
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 30
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 31
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 32
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 33
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 34
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 35
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 36
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 37
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 38
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 39
     
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 40
    	{.sUp = NULL, .sDown = NULL}, // 41
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 42
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 43
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 44
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 45
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 46
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 47
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 48
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 49
     
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 50
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 51
    	{.sUp = stdStr_sUp, .sDown = stdStr_sDown}, // 52
    	{.sUp = "clavier/kVermajUp.png", .sDown = "clavier/kVermajDown.png"}, // 53
    	{.sUp = NULL, .sDown = NULL}, // 54
    	{.sUp = NULL, .sDown = NULL}, // 55
    	{.sUp = NULL, .sDown = NULL}, // 56
    	{.sUp = "clavier/kEspUp.png", .sDown = "clavier/kEspDown.png"}  // 57
    };
     
     
    static void CLAVIER__saveToucheImage(Touche t[],const int i){
     
     
    	char *sUp = NULL, *sDown = NULL;
     
        if((i <= 53) || (i == 57)){
    		STRUCT_IMG_TAB *ptTab;
     
    		ptTab = &imgTab[i];
    		sUp = ptTab->sUp;
    		sDown = ptTab->sDown;
        }
     
     
    	if(sUp == NULL){
    		sUp = "clavier/kMajUp.png";
    		sDown = "clavier/kMajDown.png";
    	}
     
     
        t[i].keyUp = IMG_Load(sUp);
        t[i].keyDown = IMG_Load(sDown);
        t[i].p.h = t[i].keyUp->h;
        t[i].p.w = t[i].keyUp->w;
     
        if(t[i].keyUp == NULL || t[i].keyDown == NULL)
        {
            fprintf(stderr, "Erreur touche %i.", i);
            exit(EXIT_FAILURE);
        }
     
    }

Discussions similaires

  1. clavier virtuel sur Formulaire
    Par db48752b dans le forum IHM
    Réponses: 9
    Dernier message: 01/03/2017, 11h30
  2. clavier virtuel =)
    Par Ludo_360 dans le forum Delphi
    Réponses: 2
    Dernier message: 27/04/2007, 15h45
  3. Lancement du clavier virtuel
    Par rzayani dans le forum Windows
    Réponses: 1
    Dernier message: 21/08/2006, 16h16
  4. Programmer un clavier virtuel
    Par juvamine dans le forum Windows
    Réponses: 1
    Dernier message: 30/07/2006, 17h47
  5. Clavier virtuel
    Par ouquoi dans le forum MFC
    Réponses: 2
    Dernier message: 22/02/2006, 11h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo