Changeset ff4dbfd in avrstuff for aktousb/code/main.c


Ignore:
Timestamp:
Aug 30, 2010, 7:39:44 PM (14 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
aeff83b
Parents:
49fd394
Message:

Gestion correcte de la touche capslock.

git-svn-id: svn://pulkomandy.tk/avrstuff@15 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aktousb/code/main.c

    r49fd394 rff4dbfd  
    4545        else
    4646                modifier = MOD_NONE;
     47
    4748        if (key != KEY_Reserved && reportIndex < 8) {
    4849                reportBuffer[reportIndex] = key; // set next available entry
     
    6465        else
    6566                modifier = MOD_NONE;
    66         if (key != KEY_Reserved) {
     67
     68        if (key == KEY_capslock) {
     69                if (reportIndex < 8) {
     70                        reportBuffer[reportIndex] = key; // set next available entry
     71                        reportIndex++;
     72                        pressingCaps = 1;
     73                }
     74        } else if (key != KEY_Reserved) {
    6775                for (i = 2; i < reportIndex; i++) {
    6876                        if (reportBuffer[i] == key) {
     
    9199        uint8_t idleCounter = 0;
    92100    uint8_t updateNeeded = 0;
     101        int capsDelay = 16;
    93102
    94103        wdt_enable(WDTO_2S);
     
    97106
    98107        //debug LED - output
    99         DDRC |= (1<<PC5);
    100         DDRC |= (1<<PC4);
     108        DDRD |= (1<<PD6);
    101109
    102110        // Keyboard
     
    117125                if (char_waiting) {
    118126                        key_code = ak_read_scancode();
    119                         PORTC ^= (1<<PC4);
    120                         PORTC ^= (1<<PC5);
    121127                        // if an update is needed, send the report
    122128                        if ((key_code & 1) == 0)
     
    128134                }
    129135
     136
    130137                // check timer if we need periodic reports
    131138                if (TIFR & (1 << TOV0)) {
    132139                        TIFR = (1 << TOV0); // reset flag
     140
     141                        // PORTD ^= (1<<PD6); // blink del : we are alive !
     142                        if (pressingCaps)
     143                                PORTD |= 1<<PD6;
     144                        else
     145                                PORTD &= ~(1<<PD6);
     146
     147                        if (pressingCaps) {
     148                                if (--capsDelay == 0) {
     149                                        capsDelay = 16;
     150                                        pressingCaps = 0;
     151
     152                                        int i;
     153                                        for (i = 2; i < reportIndex; i++) {
     154                                                if (reportBuffer[i] == KEY_capslock) {
     155                                                        for (; i < 7; i++)
     156                                                                reportBuffer[i] = reportBuffer[i+1];
     157                                                        reportBuffer[7] = 0;
     158                                                        reportIndex--;
     159                                                }
     160                                        }                               
     161                                }
     162                        }
     163
    133164                        if (idleRate != 0) { // do we need periodic reports?
    134165                                if(idleCounter > 4){ // yes, but not yet
Note: See TracChangeset for help on using the changeset viewer.