pic as ps/2 keyboard


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 50
    parity var word:sendthis var word:kbddata var GPIO.0:kbdclk var GPIO.1
    start:
    high kbddata:high kbdclk:pause 500:sendthis=$d6:gosub calsub:sendthis=$f0
    gosub calsub:sendthis=$d6:gosub calsub:goto start          
    
    calsub:    <---ADD COLON HERE
    
    parity=not(sendthis.0^^sendthis.1^^sendthis.2^^sendthis.3^^sendthis.4^^sendthis.5^^sendthis.6^^sendthis.7)
    sendthis=sendthis<<1:sendthis.0=1:sendthis.9=parity:sendthis.10=0:shiftout kbddata,kbdclk,4,[sendthis\11]:return
    goto start

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    what happen if your change NOT by ~ ?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    what happen if your change NOT by ~ ?
    Agh! Missed that one! And it was right below my comment!

  4. #4
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks mister_e & skimask for replying ...

    I will try the ~ this morning see what happens.

    Thank you !

  5. #5
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Mister_e & Skimask,

    I thought i figured it out:

    When googeling if found that the scancode for an "a" = 0x1C = 00011100, the key-scancode has to
    be send LSB first resulting in 00111000.

    Code:
    sendthis = %00111000 'LSB first "a"
    gosub calsub
    sendthis = %00001111 'LSB first 0xF0 'for release key
    gosub calsub
    sendthis = %00111000 'LSB first "a"
    gosub calsub
    goto start       
    
    
    calsub:
        parity = ~(sendthis.0 ^^ sendthis.1 ^^ sendthis.2 ^^ sendthis.3 ^^ sendthis.4 ^^ sendthis.5 ^^ sendthis.6 ^^ sendthis.7)
        sendthis = sendthis << 1 'move over to insert start bit  
        sendthis.0 = 0 'start bit
        sendthis.9 = parity
        sendthis.10 = 1 'stop bit
        shiftout kbddata,kbdclk,1,[sendthis\11]
    return
    Then i thought that the problem was the shiftout. I was sure that it had to be LSB first, clock idles high, because the clock is high to low. But a little experiment with setting this to 1 (Shift data out highest bit first. Clock idles low).

    Resulted in a perfect "a" on the laptop sceen !!

    But however, that was about the only character that i could generate, so i think this is not right also.
    Melanie has posted a scancode table, stating that the scancode for an "a" has to be 0x1E

    I can send characters, but they don't match any of the scancodes i input ? What is happening here ?

    Anyone ?

    Best Regards, UB
    Last edited by ultiblade; - 11th May 2007 at 12:40.

  6. #6
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Update:

    Ok messed up some of the scancode's. I can now send normal characters
    by sending the reversed scancode with shiftout

    For example : if i send 0x15 = 00010101, LSB first = 10101000 = "q" on screen, that's perfect. I tried other codes and they work also.

    There was an error with the parity calculator also, so i skipped that ....

    But now, i want to use Left-shift + q, which, when looking at the scancode
    table this would be 0x12 for left shift, 0x15 for "q", 0xF0 for release, 0x15 for release "q" and 0xF0 and 0x12 for release left shift.

    Doing this results in an F10 being received ??

    Here's the code :
    Code:
    sendthis = %01001000 'left shift       
    test = 1 'parity bit
    gosub calsub
                             
    sendthis = %10101000 'q 
    test = 0
    gosub calsub
                      
    sendthis = %00001111 'Release       
    test = 1
    gosub calsub
    
    sendthis = %10101000 'q
    test = 0
    gosub calsub
    
    sendthis = %00001111 'Release 
    test = 1
    gosub calsub  
      
    sendthis = %01001000 'left shift        
    test = 1
    gosub calsub
           
    goto start       
    
    
    calsub:
        sendthis = sendthis << 1 'move over to insert start bit  
        sendthis.0 = 0 'start bit
        sendthis.9 = test 'parity
        sendthis.10 = 1 'stop bit
        shiftout kbddata,kbdclk,1,[sendthis\11]
    return
    Best regards, UB

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    not sure but i think you have to send some other code(s) + sendthis as well.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. PS/2 keyboard emulation
    By CumQuaT in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th September 2009, 05:32
  2. I've made keyboard with pic, but i have a problem.
    By XErTuX in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th November 2008, 01:40
  3. Pic to PC AT keyboard caracters
    By sezgin05 in forum General
    Replies: 5
    Last Post: - 27th March 2007, 11:45
  4. PS/2 mouse and keyboard
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2006, 17:29
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14

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