Shop OBEX P1 Docs P2 Docs Learn Events
Anyone used the Insert key? — Parallax Forums

Anyone used the Insert key?

Dr_AculaDr_Acula Posts: 5,484
edited 2010-09-21 05:02 in Propeller 1
I thought I would add the insert key to a text editor but it is proving quite difficult and I've very much appreciate some help!

Ok, first thing was a small bug on the keyboard where I couldn't get the escape key to work. I think this might be a related problem so I'll describe the experiments so far:

This is the comment section from the keyboard object:
''      C0      Left Arrow
''      C1      Right Arrow
''      C2      Up Arrow
''      C3      Down Arrow
''      C4      Home
''      C5      End
''      C6      Page Up
''      C7      Page Down
''      C8      Backspace
''      C9      Delete
''      CA      Insert
''      CB      Esc
''      CC      Apps
''      CD      Power
''      CE      Sleep
''      CF      Wakeup

and it is supposed to send CB for escape and CA for insert. The code that does this is here
                        word    $C5E1   '69     End     (1)
                        word    $0000   '6A
                        word    $C0E4   '6B     Left    (4)
                        word    $C4E7   '6C     Home    (7)
                        word    $0000   '6D
                        word    $0000   '6E
                        word    $0000   '6F
                        word    $CAE0   '70     Insert  (0) 
                        word    $C9EA   '71     Delete  (.)
                        word    $C3E2   '72     Down    (2)
                        word    $00E5   '73             (5)
                        word    $C1E6   '74     Right   (6)
                        word    $C2E8   '75     Up      (8)
                        word    $00CB   '76             Esc 
                        word    $00DF   '77             NumLock
                        word    $00DA   '78             F11
                        word    $00EC   '79             (+)

but I seemed to get 02 for escape. So I changed this one little line to send 1B instead of CB and now escape works.
                        word    $001B   '76             Esc

Ok, if that works, then I figured the same thing should work for Insert. I took this line word $CAE0 '70 Insert (0) and changed it so it (I thought) would return a character A - word $0041

But it doesn't return anything. If I go back to $CAE0 it returns $02

I'm also confused by the codes that come back. Insert is CAE0 and the scancode for this key is E0,70 http://www.computer-engineering.org/ps2keyboard/scancodes2.html so I figured that because End is E0,69 on that website it would be in the code too, but it is $C5E1

Anyway, the comment code at the top of this thread makes it seem that it should be quite simple and should return some numbers C0 to CF depending on the key pressed. I can't seem to find any code that replicates this explicitly, and the closest is this table. But the table appears to only return C0 to C9. CA (Insert) and CB (Escape) don't seem to work.

Maybe the insert key is not used by most people so perhaps this has never come up as an issue. Any help here would be most appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-20 22:19
    I've used the Insert key before for a simple screen buffer-based editor. I tend to use the comboKey.spin driver, but the character table and the code that accesses it are unchanged.

    I get keycodes from the whole range of $C0..$CF although I don't use $CD..$CF

    Attached are the source files for the keyboard driver and window editor
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-21 00:47
    Ah, thanks for that. Something is working now - just need to narrow down the bug. Many thanks Mike

    Addit - I found a combo mouse key driver, and changing
    word $CAE0 '70 Insert (0)
    to $0041

    returns nothing, so I can replicate one part of the bug.

    Where would I get combokey.spin?

    I think the part that processes the table is here (though there are a few other calls to 'table')
    ' Lookup byte in table
    '
    look                    ror     data,#2                 'perform lookup
                            movs    :reg,data
                            add     :reg,#table
                            shr     data,#27
                            mov     x,data
    :reg                    mov     data,0
                            shr     data,x
    
                            jmp     #rand                   'isolate byte
    

    What I can't quite understand is how a 4 byte value in 'table' gets converted into a 4 byte value that is returned, where the returned value always is $00nn but the value in 'table' sometimes has 00nn and sometimes nnnn.

    There is something cunning going on here...
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-09-21 01:49
    I tried to shift the key mapping (German keyboard) around on the Nascom (etc) emulators that Pullmoll did. Some things happened as I expected but most things didn't. I must get back to it, before I forget what I had acheived.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-21 05:02
    Ah yes, the Nascom. I think I almost had space invaders working but the keys were all mixed up. So it could be handy to be able to remap the arrow keys to different things.

    I just found something
                            word    $0000   '6E
                            word    $0000   '6F
    '                        word    $CAE0   '70     Insert  (0)
                            word    $4100
                            word    $C9EA   '71     Delete  (.)
                            word    $C3E2   '72     Down    (2)
    

    This prints out 41 (ascii A) when you press Insert. I think what is happening is that for that group of 10 keys (insert/delete/home/end/pageup/pagedown/arrowup/arrowdown/arrowleft/arrowright), the high byte of the word is the value returned, and for most other keys it is the low byte. My working theory is that the values like 'EA' and 'E2' for the lower byte for delete and down, are red herrings.

    This theory could make sense because those 10 keys are different in that they return two byte codes (three on key up). It could also explain why the Insert key on the keypad works fine but not the Insert key in that group of 10.

    Back to debugging...

    Addit: yes, that is it. Change the high byte for that group of 10, change the low byte for pretty much every other key. Insert now works and I can map it to ^I for Wordstar or ^N for Vedit, or anything else as required.

    Thanks ++ for the help and words of encouragement. Where this is heading is a practical text editor on the propeller that is fast to load, fast to run, and can even do clever things like auto-indentation for C.
Sign In or Register to comment.