Changeset 87ab18e in avrstuff


Ignore:
Timestamp:
Jul 31, 2014, 11:00:37 PM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
0010058
Parents:
ea32107
Message:

Drop hacked "shift" handling from libps2.

  • It's up to clients to do that if they wish so (useful if you're converting

to ASCII, for example, but not for a regular keyboard adapter)

Improve callback system to handle release events.

  • The callback would only be called for pressed keys, not for releases, leading

to weird results. Things work much better now in XTK.

  • Also ignore the E0 byte for extended keys in XTK. This avoids apps going

crazy as the Turbo XT BIOS doesn't handle it right.

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

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kbd/xtk/code/Makefile

    rea32107 r87ab18e  
    1 MCU=atmega48p
     1# Board settings
     2
     3# K4KUSB
     4MCU=attiny2313
     5F_CPU=12000000
     6
     7# Generic settings
     8BAUD=9600
     9
    210
    311include ../../common.mk
    412
    5 all: keyboard.hex
    6 
    7 keyboard.bin: keyboard.o main.o
     13$(MCU).bin: $(MCU)/keyboard.o $(MCU)/main.o
    814        $(CC) $^ -o $@ -mmcu=$(MCU) -Os
    915
    10 main.o: main.c $(LIBS)/ps2_keyboard/ps2_keyboard.h
    11         $(CC) -std=c99 -c $< -mmcu=$(MCU) -Os -o $@ -Os
     16$(MCU)/main.o: main.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(MCU)
     17        $(CC) $(CFLAGS) -std=c99 -c $< -o $@
    1218
    13 keyboard.o: $(LIBS)/ps2_keyboard/ps2_keyboard.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(LIBS)/ps2_keyboard/keymap.h
    14         $(CC) -DCALLBACK="callback();" -c $< -mmcu=$(MCU) -Os -o $@
    15 
    16 clean:
    17         rm *.o *.bin *.hex
    18 
    19 flash: keyboard.hex
    20         $(AVRDUDE) -c usbasp -p $(MCU) -Uflash:w:$^
     19$(MCU)/keyboard.o: $(LIBS)/ps2_keyboard/ps2_keyboard.c $(LIBS)/ps2_keyboard/ps2_keyboard.h $(LIBS)/ps2_keyboard/keymap.h $(MCU)
     20        $(CC) $(CFLAGS) -DCALLBACK="callback();" -c $< -o $@
  • kbd/xtk/code/main.c

    rea32107 r87ab18e  
    2424void callback()
    2525{
    26         uint8_t key_code = 0;
    27         key_code = read_char(); // TODO this function is blocking. Can it disturb main?
    28 
    29         key = pgm_read_byte(&(at2xt[key_code]));
    30         if(release)
    31                 key |= 0x80;
     26        // Ignore all keys above 0x80, and importantly ignore 0xE0 from extended keys.
     27        if (kbd_data < 0x80) {
     28                key = pgm_read_byte(&(at2xt[kbd_data]));
     29                if(release)
     30                        key |= 0x80;
     31        }
    3232}
    3333
     
    5252#endif
    5353
    54         static const int delay = 25;
     54        static const int delay = 12;
    5555
    5656        // XT init - configure pins directions
     
    5858        DDRXT &= ~(PCLK | PDAT); // both pins as inputs (floating)
    5959
    60         DDRB |= (1<<PB2); // LED
    61 
    6260        uint8_t k;
    6361        while(1) {
    64                 PORTB ^= (1<<PB2); // LED
    65 
    6662                while ((PINXT & (PDAT|PCLK)) != (PDAT|PCLK))
    6763                        ; // Wait for PC to be ready to receive data
  • libs/ps2_keyboard/ps2_keyboard.c

    rea32107 r87ab18e  
    3030#endif
    3131
    32 static volatile uint8_t kbd_data;
    3332static volatile uint8_t char_waiting;
    3433static uint8_t started;
    3534static uint8_t bit_count;
    36 static uint8_t caps_lock;
    3735static uint8_t extended;
    3836
    39 uint8_t shift;
     37volatile uint8_t kbd_data;
    4038uint8_t release;
    4139
     
    7977    kbd_data = 0;
    8078    return;
    81   } else if (kbd_data == 0x12) { //hanlde shift key
    82     if(release == 0){
    83       shift = 1;
    84     } else {
    85       shift = 0;
    86       release = 0;
    87     }
    88     return;
    8979  } else { //not a special character
    90     if(release){ //we were in release mode - exit release mode
    91       release = 0;
    92       //ignore that character
    93     } else {
    94       char_waiting = 1;
    9580#ifdef CALLBACK
    9681          CALLBACK
    9782#endif
     83    if(release){ //we were in release mode - exit release mode
     84      release = 0;
     85    } else {
     86          // Notify callback that there's a new char waiting
     87      char_waiting = 1;
    9888    }
    9989  }
  • libs/ps2_keyboard/ps2_keyboard.h

    rea32107 r87ab18e  
    99        // Convert a keycode to a printable ASCII char
    1010
    11 extern uint8_t shift;
     11extern volatile uint8_t kbd_data;
    1212extern uint8_t release;
Note: See TracChangeset for help on using the changeset viewer.