Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > SHIFT keys and SHIFT LOCK
2013-06-28 01:57
TWW

Registered: Jul 2009
Posts: 545
SHIFT keys and SHIFT LOCK

Hiho

I've read thourgh some old posts and instead of reviving them I figgured a new post was in order.

First off, the shift-keys el'weirdo bahaviour

Replicate as follows:

Start VICE
Shift to lower case characters (C= + SHIFT)
press "a" three times
press and hold left SHIFT
press "A" three times
press and hold right SHIFT
Release left SHIFT
Release Right SHIFT
press "a" three times

as you can see the last 3 "a"'s are still upper case and if you scan $dc00/$dc01 you will find that the shift status bi is still set in the keyboard matrix.

Is this a bug or will a real machine work the same way?

The second issue is the SHIFT LOCK detection trick outlined by Marco M. in C= Hacking #7:

Quote:

The difference between an input and an output is that an output uses more current to drive the signal to the desired level. An input and an output outputting logical '1' are equivalent for any other inputting chip. But if a chip is trying to drive a signal to ground level, it needs more current to sink an output than an input. You can even use outputs as inputs, i.e. read them in your program.

You can use this feature to distinquish between the left shift and the shift lock keys, although they are connected to same hardware lines. The shift lock key has smaller resistance than the left shift. If you make both CIA 1 ports to outputs (write $FF to $DC03 and $DC01) prior reading the left shift key, only shift lock can change the values you read from CIA 1 port B ($DC01).)


If this is the case, the following code snippet should be able to detect a SHIFT LOCK:

again:
    lda #$ff
    sta $dc03
    sta $dc01
    lda #%11111101
    sta $dc00
    lda $dc01
    asl
    ldx #$00
    bcs !no+
        ldx #$ff
!no:
    stx $0500
    jmp again


I can't get this to work in VICE so again, the same question really; Is it a un-supported feature?

EDIT: Actually I get the ecact same keyboard scan matrix readout when I press RUN-STOP (ESC) and SHIF LOCK (CAPS LOCK)...
 
... 1 post hidden. Click here to view all posts....
 
2013-06-28 20:40
chatGPZ

Registered: Dec 2001
Posts: 11386
1) please use a recent VICE
2) look at https://sourceforge.net/p/vice-emu/code/27475/tree/testprogs/CI.. - the shift-lock detection works on "most" real c64s, not all (because it depends on electric properties of the keys). VICE does emulate it correctly for a while though, including some nasty cornercases (more than two keys pressed at once)
2013-06-29 11:14
TWW

Registered: Jul 2009
Posts: 545
GPZ:

I was doing these tests on V2.4.4-27398. Fairly new but I'll try the latest build.

Interesting read on SF.
2013-06-29 13:41
chatGPZ

Registered: Dec 2001
Posts: 11386
then it should work.... dont forget that shift-lock is actually a different key than shift and must be mapped to a key of the pc keyboard - i dont know if the windows keymaps do this properly. pressing shift-lock doesnt work, because that isnt really a seperate key to the pc.
2013-06-30 23:53
TWW

Registered: Jul 2009
Posts: 545
If I understand you correctly, you're saying Windows have no means to detect Caps Lock from a regular left shift being held down?

EDIT:

CAPS is actually mapped up to Run Stop together with ESC. So this has to mean that Win can detect Caps;?

58 7 7 8               /*    Caps Lock -> Run/Stop     */

/EDIT



Either way, how do I add Shift Lock to the key-map file in VICE? I only found left/right shift in the map file (assume it's a code or some such for the C-64 side which has to be mapped up to a Windowze key)?

Then perhaps it will work after I get this done :-)
2013-07-01 17:10
chatGPZ

Registered: Dec 2001
Posts: 11386
# Shiftflag can have the values:
# 0      key is not shifted for this keysym/scancode
# 1      key is shifted for this keysym/scancode
# 2      left shift
# 4      right shift
# 8      key can be shifted or not with this keysym/scancode
# 16     deshift key for this keysym/scancode
# 32     another definition for this keysym/scancode follows
# 64     shift lock

look at the SDL or X11 keymaps (for x64), those are probably the most complete..... and post yours on the bugtracker if you make it work, so it can be included :)

in the x11 keymap the caps lock line looks like this:
# shift lock
Caps_Lock       1 7 64
2013-07-02 04:14
TWW

Registered: Jul 2009
Posts: 545
HiHo

I modified the Keymap Line for CAPS LOCK as follows:

58 1 7 64              /*    Caps Lock -> SHIFT LOCK   */


And suck me sideways, it works. My code can successfully detect SHIFT LOCK vs. Regular SHIFT.

There is however another issue. If I start up X64 and switch to lower case, then press CAPS, the printed characters are still lowercase regardless how the CAPS LOCK is pushed.

I tried adding the line from X11 but it made no difference even with keysymbol #58 Hashed out or not. I have no clue what causes this.

I also tried setting the Shift status to 66 instead of 64 but it only made it behave as a regular shift button.

Also the shift buttons are still strange as described in my initial post.
2013-07-02 11:28
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
I tried adding the line from X11 but it made no difference even with keysymbol #58 Hashed out or not. I have no clue what causes this.

that will not work, X11 uses these literal keycodes, windows doesnt =)

no idea about the other behaviour - it works fine here, so that could indeed be a windows problem :)
2013-07-03 02:44
TWW

Registered: Jul 2009
Posts: 545
Alrighy then, the conclusions are:

- Left/Right Shift behaves weird when VICE is run in Windows (The shift keys behave normal with other SW!).

- Shift Lock can be detected separately from left shift but will not switch shift status permanently on like on the real deal.


Can someone else with a Win setup confirm that this is the general case (Post #1 for testing shift buttons and post #8 for modification to the keymap file to enable shift-lock)?
2013-07-03 16:03
chatGPZ

Registered: Dec 2001
Posts: 11386
it this point you may want to make a proper bug report :)
2013-07-03 21:38
TWW

Registered: Jul 2009
Posts: 545
Okay then!

Done. Let me know if you need the test code if your can't replicate the issue.
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
csabanw
Alakran_64
Broti/DT/KRN
Yogibear/Protovision
Quetzal/Chrome
Exile/Anubis
Guests online: 89
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.067 sec.