SHIFT LOCK - how to recognize it?

Started by MIRKOSOFT, December 08, 2009, 05:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

Last days I tried to recognize every key on C128 keyboard, helps on forums were very useful.
I can recognize every key except...
SHIFT LOCK
I know that it's hard-wired to LEFT SHIFT, but it's last key which I don't know how to recognize...
Don't have any idea. Can anybody help me?

Thank you everybody very very much.

Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

Hydrophilic

Shift Lock is connected to the same wires as Left Shift.  There is no way to tell the difference, sorry.
I'm kupo for kupo nuts!

commodorejohn

Are we going to go through this for every key on the keyboard?

airship

I suppose you could do a loop to detect left-shift, which at some predetermined time (1 second?) decide that the shift lock key is actually engaged. Of course, you would get some false positives, but it might be good enough, depending on what you're trying to accomplish.
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine

MIRKOSOFT

Hi!

I had one answer on Forum64.de:

"It's not a flag, it's a procedure that's required to detect if the shift lock key is pressed. Note that shift lock is hardwired to the left shift key, so the "impossible"-answers are kind-of true. However, the switch-type key has different properties from the button-type key that can be taken advantage of.

Normally, you set one CIA port to output and the other CIA port to input for scanning the keys. This is the usual way, and it's the right way. Once you have detected that the left shift key is pressed, you need to do something that is "electrically wrong": Program both bits of the key matrix to OUTPUT and set the A side to 0, while you set the B side to 1. In essence, you're programming a short-circuit.

Now comes the electrical knowledge: Even when programmed to output, the CIA port-registers always reflect the true status of the physical pins. If programmed to 1, but pulled to GND on the outside, you read a 0. The behaviour of the "1"-bit is what lets you determine the status of the shift lock key: If the bit that you've programmed to "1" reads "0", then the shift lock key is pressed. If both bits read the value that you have written, then the normal left-shift key is pressed.

This procedure sounds much like the "killer-poke", because you're essentially programming a short-circuit, but it's not. The CIA's port bits are operated close to, but within limits using this technique.

Have fun implementing - it should only be a few lines of code!

Jens"

But when I tried to programming it, I don't understand it correctly and never it works.

Can you help me with this?

Thank you very much.

Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

MIRKOSOFT

Hi!

So, I tried an experiment and here's code:

test: lda #$fd //test l.shift(lock)
sta $dc00
lda $c001
and #$80
bne test
lda #$02 //set data registers to OUTPUT
sta $dc02
lda #$80
sta $dc03
lda #$00 //set A to 0
sta $dc00
lda #$ff //set B to 1
sta $dc01
lda $dc01 //test if bit is 1
and #$80
bne test //if yes test l.shift(lock) back
lda #$00 //set A & B to INPUT/OUTPUT
sta $dc03lda #$ff
sta $dc02
rts


So, that this is impossible is not truth...  ;)

Thanks. 

Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

Hydrophilic

That sounds unbelievable, but I tried it and it works! 

I guess the contacts between the key plungers and the exposed copper traces of the circuit board have more resistance than the internal wiring of SHIFT LOCK switch.  And also guessing the CIA is less sensitive reading the lines when in output mode.  So only a strong signal from SHIFT LOCK will register as 0.  I tried pressing really hard on Left Shift, but it would not register.

I stand corrected.
I'm kupo for kupo nuts!

airship

Great hack! I love this kind of stuff. :)
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine