Author Topic: SHIFT LOCK - how to recognize it?  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
SHIFT LOCK - how to recognize it?
« on: December 08, 2009, 05:59 PM »
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!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: SHIFT LOCK - how to recognize it?
« Reply #1 on: December 09, 2009, 02:43 PM »
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!

Offline commodorejohn

  • VIC 20 user
  • ****
  • Posts: 149
  • Location: Minnesota, USA
  • Activity:
    0%
  • Reputation: 61
  • With us since: 25/05/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • Commodorejohn's Projects Page
Re: SHIFT LOCK - how to recognize it?
« Reply #2 on: December 09, 2009, 03:05 PM »
Are we going to go through this for every key on the keyboard?

Offline airship

  • 128D user
  • *******
  • Posts: 1605
  • Age: 61
  • Location: Iowa, USA
  • Activity:
    0%
  • Country: us
  • Reputation: 113
  • Gender: Male
  • Former Editor, INFO Magazine
  • With us since: 28/07/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • Atomic Airship
Re: SHIFT LOCK - how to recognize it?
« Reply #3 on: December 11, 2009, 04:26 AM »
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

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
Re: SHIFT LOCK - one idea?!
« Reply #4 on: December 11, 2009, 05:15 AM »
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!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
Re: SHIFT LOCK - how to recognize it?
« Reply #5 on: December 15, 2009, 04:01 PM »
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!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: SHIFT LOCK - how to recognize it?
« Reply #6 on: December 19, 2009, 10:53 AM »
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!

Offline airship

  • 128D user
  • *******
  • Posts: 1605
  • Age: 61
  • Location: Iowa, USA
  • Activity:
    0%
  • Country: us
  • Reputation: 113
  • Gender: Male
  • Former Editor, INFO Magazine
  • With us since: 28/07/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • Atomic Airship
Re: SHIFT LOCK - how to recognize it?
« Reply #7 on: December 22, 2009, 02:25 AM »
Great hack! I love this kind of stuff. :)
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine

 



Back to top