Hi @ all,

ich konnte die Tage meinen Tastaturemulator erfolgreich testen. Wie man im Code sieht ist das eigentliche Programm recht klein, nur die Datensätze für die Scancodes im unteren Teil füllen den Code aus. Ich habe mir die Arbeit gemacht und die gebräuchlichsten Scancodes eingegeben. Nach Bedarf kann man die Datensätze erweitern. So kann man schnell mal im Programm Tasten ändern oder hinzufügen. Den Quartz konnte ich sogar weglassen und den ATMEGA intern mit 8 MHz takten. Für alle hier noch den Code.

Gruß Michael



Code:
' Tastaturemulator
' mit ATMEGA 8
'11-04-2009

$regfile = "m8def.dat"
$crystal = 8000000

$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               ' default use 10 for the SW stack
$framesize = 40                                             ' default use 40 for the frame

$lib "at_emulator.lib"

Config Portb = Output                                       ' PortB als Ausgang definiert und auf High gesetzt
Portb = 255
Config Portc = Input                                        ' PC.0 bis PC.4 / Tasteranschlüsse
Portc = 255

Enable Interrupts                                           ' you need to turn on interrupts yourself since an INT is used
Config Atemu = Int1 , Data = Pind.3 , Clock = Pind.7

'                 ^------------------------ used interrupt

'                              ^----------- pin connected to DATA

'                                       ^-- pin connected to clock

'Note that the DATA must be connected to the used interrupt pin

Do

Waitms 150

      If Pinc.0 = 0 Then
      'Sendscankbd Pfeil_hoch
      Sendscankbd Taste_a
      Else

      If Pinc.1 = 0 Then
      'Sendscankbd Pfeil_runter
      Sendscankbd Taste_b
      Else

      If Pinc.2 = 0 Then
      'Sendscankbd Pfeil_rechts
      Sendscankbd Taste_c
      Else

      If Pinc.3 = 0 Then
      'Sendscankbd Pfeil_links
      Sendscankbd Taste_d
      Else

      If Pinc.4 = 0 Then
      Sendscankbd Enter
      Else

   End If
   End If
   End If
   End If
   End If

      Loop

'einige Tastatur - Scancodes / wird noch ergänzt
'------------------------------------------------

Pfeil_hoch:
Data 5 , &HE0 , &H75 , &HE0 , &HF0 , &H75

Pfeil_runter:
Data 5 , &HE0 , &H72 , &HE0 , &HF0 , &H72

Pfeil_rechts:
Data 5 , &HE0 , &H74 , &HE0 , &HF0 , &H74

Pfeil_links:
Data 5 , &HE0 , &H6B , &HE0 , &HF0 , &H6B

Enter:
Data 3 , &H5A , &HF0 , &H5A

Taste_esc:
Data 3 , &H76 , &HF0 , &H76

Taste_space:
Data 3 , &H29 , &HF0 , &H29

'------------------------------------------------

Taste_f1:
Data 3 , &H05 , &HF0 , &H05

Taste_f2:
Data 3 , &H06 , &HF0 , &H06

Taste_f3:
Data 3 , &H04 , &HF0 , &H04

Taste_f4:
Data 3 , &H0C , &HF0 , &H0C

Taste_f5:
Data 3 , &H03 , &HF0 , &H03

Taste_f6:
Data 3 , &H0B , &HF0 , &H0B

Taste_f7:
Data 3 , &H83 , &HF0 , &H83

Taste_f8:
Data 3 , &H0A , &HF0 , &H0A

Taste_f9:
Data 3 , &H01 , &HF0 , &H01

Taste_f10:
Data 3 , &H09 , &HF0 , &H09

Taste_f11:
Data 3 , &H78 , &HF0 , &H78

Taste_f12:
Data 3 , &H07 , &HF0 , &H07

'------------------------------------------

Taste_a:
Data 3 , &H1C , &HF0 , &H1C

Taste_b:
Data 3 , &H32 , &HF0 , &H32

Taste_c:
Data 3 , &H21 , &HF0 , &H21

Taste_d:
Data 3 , &H23 , &HF0 , &H23

Taste_e:
Data 3 , &H24 , &HF0 , &H24

Taste_f:
Data 3 , &H2B , &HF0 , &H2B

Taste_g:
Data 3 , &H34 , &HF0 , &H34

Taste_h:
Data 3 , &H33 , &HF0 , &H33

Taste_i:
Data 3 , &H43 , &HF0 , &H43

Taste_j:
Data 3 , &H3B , &HF0 , &H3B

Taste_k:
Data 3 , &H42 , &HF0 , &H42

Taste_l:
Data 3 , &H4B , &HF0 , &H4B

Taste_m:
Data 3 , &H3A , &HF0 , &H3A

Taste_n:
Data 3 , &H31 , &HF0 , &H31

Taste_o:
Data 3 , &H44 , &HF0 , &H44

Taste_p:
Data 3 , &H4D , &HF0 , &H4D

Taste_q:
Data 3 , &H15 , &HF0 , &H15

Taste_r:
Data 3 , &H2D , &HF0 , &H2D

Taste_s:
Data 3 , &H1B , &HF0 , &H1B

Taste_t:
Data 3 , &H2C , &HF0 , &H2C

Taste_u:
Data 3 , &H3C , &HF0 , &H3C

Taste_v:
Data 3 , &H2A , &HF0 , &H2A

Taste_w:
Data 3 , &H1D , &HF0 , &H1D

Taste_x:
Data 3 , &H22 , &HF0 , &H22

Taste_y:
Data 3 , &H35 , &HF0 , &H35

Taste_z:
Data 3 , &H1A , &HF0 , &H1A

Taste_0:
Data 3 , &H45 , &HF0 , &H45

Taste_1:
Data 3 , &H16 , &HF0 , &H16

Taste_2:
Data 3 , &H1E , &HF0 , &H1E

Taste_3:
Data 3 , &H26 , &HF0 , &H26

Taste_4:
Data 3 , &H25 , &HF0 , &H25

Taste_5:
Data 3 , &H2E , &HF0 , &H2E

Taste_6:
Data 3 , &H36 , &HF0 , &H36

Taste_7:
Data 3 , &H3D , &HF0 , &H3D

Taste_8:
Data 3 , &H3E , &HF0 , &H3E

Taste_9:
Data 3 , &H46 , &HF0 , &H46