Menu

PS/2 Keyboard

Help
2007-05-26
2013-05-30
  • Nobody/Anonymous

    One of the example projects uses the INKEY command to read a PS/2 keyboard.
    I cannot seem to find this command in any of the help files.
    Can someone shed a little more light on how to implement this command?

    Thanks,

    Dan

     
    • Hugh Considine

      Hugh Considine - 2007-05-27

      First, you need to add two lines at the start of the program to specify what pins the keyboard is connected to. For example,

      #define PS2Clock PORTB.1
      #define PS2Data PORTB.2

      Then, you use the INKEY function to read the ASCII code of the currently pressed key. To store the value of the pressed key in a variable called UserInput, you'd use this line:

      UserInput = INKEY

      If no key is pressed, then INKEY will be equal to 0.

      Not all keys are currently detected - the PS/2 routines are still a work in progress. However the letter, number/symbol, Enter, Backspace, Space and Esc keys should all work.

       
      • Nobody/Anonymous

        Curiously is there any method in GCBasic that would do the exact opposite of this function? Allowing a PIC device to emulate a PC Keyboard?

        I'm currently looking at implimenting keyboard emulation by writing up a subroutine in gcbasic, but if there's an existing facility i'd rather work with that :)

         
        • Hugh Considine

          Hugh Considine - 2007-06-21

          Sorry, there isn't currently anything in GCBASIC to simulate a PS/2 keyboard. If you do write some code to simulate a keyboard, I'd love to include it.

           
    • Nobody/Anonymous

      Great.. Thanks!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.