PS/2 keyboard emulation


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by CumQuaT View Post
    Has anyone had a play around with this before?
    I did ! (-Played-) several yrs ago....
    look at this i dont remember but it's part off a bigger program... any way I hope you can find it useful...
    Code:
     'ps2 emu-sw betomax
     DEFINE SHIFT_PAUSEUS 15
     char        var Word  'character
     datpin      var porta.0   'Keyboard Data ' 10k pull up
     clkpin      var porta.1   'Keyboard Clock ' 10k pull up
     col         VAR   BYTE     ' Keypad column
     row         VAR   BYTE     ' Keypad row
     key         VAR   BYTE     ' Key value
     delayer con 100    'delay btw chars
     CMCON = 7
     trisa =0
     datpin = 1
     clkpin = 1
     OPTION_REG.7 =    0        ' Enable PORTB pull-ups
     h var word : h = %11001100110
     o var word : o = %11010001000 
     l var word : l = %11010010110
     a var word : a = %10000111000
     b var word : b = %10001100100
     c var word : c = %11001000010
     d var word : d = %10001000110
     uno var word  : uno =  %10000101100
     dos var word : dos =  %11000111100
     tres var word : tres =  %10001001100 
     cuatro var word : cuatro =  %10001001010
     extcode var word : extcode = %10111000000 'e0
     berak var word : berak  =%11111100000 'f0
     intro var word : intro = %11010110100 '5a
    
    Start:
    
     GOSUB Getkey ' from switch / keypad
    
     Select CASE Key ' wich key ??
      case 1
       char = uno : GOSUB sendchar : pause 500
      case 2
       char = dos :GOSUB sendchar : pause 500
      case 3
       char = tres :GOSUB sendchar: pause 500
      case 4
       char = cuatro: GOSUB sendchar: pause 500
      case 5
       char = a : GOSUB sendchar: pause 500
      case 6
       char = b: GOSUB sendchar: pause 500
      case 7
       char = c : GOSUB sendchar: pause 500
      case 8
       char = d :  GOSUB sendchar: pause 500
      case 9
       char =h:GOSUB sendchar: pause 500
         case 10
       char =o:GOSUB sendchar: pause 500
      case 11
       char = l:GOSUB sendchar: pause 500
     END SELECT
      pause 500
      goto start
    
    'actually make ps2 tx !
    
    sendchar:
      shiftout datpin,clkpin,0,[char\11] : pauseus 50
      shiftout datpin,clkpin,0,[berak\11] : pauseus 50
      shiftout datpin,clkpin,0,[char\11]: pauseus 50
      return

  2. #2
    Join Date
    Sep 2009
    Location
    Brisbane, Australia
    Posts
    10


    Did you find this post helpful? Yes | No

    Default reply

    This looks neat! I'll have a crack at it!

    I was wondering though, do you have more of the keyboard codes? The application I plan on using will make use of 21 keys in the end...

Similar Threads

  1. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 17:10
  2. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 09:14
  3. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 01:04
  4. pic as ps/2 keyboard
    By mischl in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 15th May 2007, 17:53
  5. PS/2 mouse and keyboard
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2006, 17:29

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts