@elektronix00:

Wenn Du Dir die Bascom-Hilfe anschaust, findest Du einen gut dokumentierten Beispielcode:

Code:
'-----------------------------------------------------------------------------------------

'name                     : ps2_kbdemul.bas

'copyright                : (c) 1995-2005, MCS Electronics

'purpose                  : PS2 AT Keyboard emulator

'micro                    : 90S2313

'suited for demo          : no, ADD ONE NEEDED

'commercial addon needed  : yes

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

 

$regfile = "2313def.dat"                                   ' specify the used micro

$crystal = 4000000                                         ' used crystal frequency

$baud = 19200                                               ' use baud rate

$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 space

 

$lib "mcsbyteint.lbx"                                     ' use optional lib since we use only bytes

 

'configure PS2 AT pins

Enable Interrupts                                         ' you need to turn on interrupts yourself since an INT is used

Config Atemu = Int1 , Data = Pind.3 , Clock = Pinb.0

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

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

'                                       ^-- pin connected to clock

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

 

 

Waitms 500                                                 ' optional delay

 

'rcall _AT_KBD_INIT

Print "Press t for test, and set focus to the editor window"

Dim Key2 As Byte , Key As Byte

Do

  Key2 = Waitkey()                                       ' get key from terminal

  Select Case Key2

    Case "t" :

    Waitms 1500

    Sendscankbd Mark                                     ' send a scan code

    Case Else

  End Select

Loop

Print Hex(key)

 

Mark:                                                     ' send mark

Data 12 , &H3A , &HF0 , &H3A , &H1C , &HF0 , &H1C , &H2D , &HF0 , &H2D , &H42 , &HF0 , &H42

'    ^ send 12 bytes

'           m                    a                   r                    k
Interessant für Dich wäre die Data-Sektion.
Die "12" gibt die Anzahl der Bytes an.
Die Anweisungen eine Taste zu drücken (make) und wieder loszulassen (break) werden in Hexadezimal angegeben. Deshalb steht vor jeder Anweisung ein "&H".
Um ein "m" auszugeben, muss es erst einmal "gedrückt" werden. Das macht man mit "3A".
Losgelassen wird das "m" dann mit "F0,3A".

Um die Hex-Angaben für die entsprechenden Tasten zu bekommen, kannst Du mal einen Blick auf einen Keyboard-Scancode werfen: http://www.marjorie.de/ps2/scancode-set2.htm

Wenn Du z.B. nur den Pfeil nach Links drücken möchtest, würde die Data-Sektion so aussehen:

Code:
Data 5 , &HE0 , &6B , &E0 , &HF0 , &H6B
Hier im Forum hat sich übrigens Rofo88 mal die Arbeit gemacht, einen Keyboard-Emulator direkt in Bascom zu schreiben (habe ich selber aber nicht getestet): https://www.roboternetz.de/phpBB2/viewtopic.php?t=38660