[comp.sys.ibm.pc] Kbd. LED Indicator Lights?

jborza%burgundy@Sun.COM (Jim_Borza) (12/10/88)

It's simple to toggle NumLock, ScrolLock, etc via software but does
anyone know how to manipulate the LED Indicator lights on the Key-
board to reflect the state of the system?  Particularly, a means of
doing so that'll be applicable for PC/XT/AT/PS-2 across the board.

I'm pretty certain the XT keyboard's LEDs are inaccessible except
to the controller in the Kbd. but is it possible to simply reset
them to an OFF state?  Thanks for any help.  BTW, C or MASM source
(or just helpful hints) will do.


Jim Borza
Communication Factors - Fremont, CA (415) 797-3039
Sun Microsystems - Milpitas, CA

bkliewer@iuvax.cs.indiana.edu (Bradley Dyck Kliewer) (12/10/88)

In article <80810@sun.uucp> jborza%burgundy@Sun.COM (Jim_Borza) writes:
>I'm pretty certain the XT keyboard's LEDs are inaccessible except
>to the controller in the Kbd. but is it possible to simply reset
>them to an OFF state?  Thanks for any help.  BTW, C or MASM source
>(or just helpful hints) will do.

On IBM machines, the LED's toggle when the status bit in the BIOS data
area changes.  I'm not sure of the exact address, but it's somewhere in
segment 40h.  As for non-IBM machines and add-on keyboards, I don't think
there are any standards.

Bradley Dyck Kliewer                Hacking...
bkliewer@iuvax.cs.indiana.edu       It's not just an adventure
                                    It's my job!

Ralf.Brown@B.GP.CS.CMU.EDU (12/10/88)

In article <15711@iuvax.cs.indiana.edu>, bkliewer@iuvax.cs.indiana.edu (Bradley Dyck Kliewer) writes:
}On IBM machines, the LED's toggle when the status bit in the BIOS data
}area changes.  I'm not sure of the exact address, but it's somewhere in
}segment 40h.  As for non-IBM machines and add-on keyboards, I don't think
}there are any standards.

They only toggle because the BIOS checks for changed bits each time the
keyboard sends a scan code, and updates the LEDs if necessary.  There is a
specific command that you send the keyboard controller at I/O port 64h which
sets the LEDs, but I can't find it off-hand.

So, if the program changes the status bits, but no keys are pressed, held
down, or released afterwards, the LEDs will not change.  Makes for a bit of an
unusual effect to have the NumLock LED change when you press Shift, for
example....

--
UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=- Voice: (412) 268-3053 (school)
ARPA: ralf@cs.cmu.edu  BIT: ralf%cs.cmu.edu@CMUCCVMA  FIDO: Ralf Brown 1:129/31
Disclaimer? I     |Ducharm's Axiom:  If you view your problem closely enough
claimed something?|   you will recognize yourself as part of the problem.

cewallace@dahlia.waterloo.edu (Chris Wallace) (12/11/88)

In article <80810@sun.uucp> jborza%burgundy@Sun.COM (Jim_Borza) writes:
>It's simple to toggle NumLock, ScrolLock, etc via software but does
>anyone know how to manipulate the LED Indicator lights on the Key-
>board to reflect the state of the system?  Particularly, a means of
>doing so that'll be applicable for PC/XT/AT/PS-2 across the board.
>
>Jim Borza

In PC Magazine, I believe about May or June of this year, there was an 
assembler program published which did exactly that.  It was called TOGGLE.
I'm sure it's available on PC-MagNet, if you have access.  If not, perhaps
someone could upload it...

Chris Wallace
Waterloo, Ontario, Canada

bkliewer@iuvax.cs.indiana.edu (Bradley Dyck Kliewer) (12/12/88)

In article <23a131e9@ralf> Ralf.Brown@B.GP.CS.CMU.EDU writes:
>They only toggle because the BIOS checks for changed bits each time the
>keyboard sends a scan code, and updates the LEDs if necessary.  There is a
>specific command that you send the keyboard controller at I/O port 64h which
>sets the LEDs, but I can't find it off-hand.
>
>So, if the program changes the status bits, but no keys are pressed, held
>down, or released afterwards, the LEDs will not change.  Makes for a bit of an
>unusual effect to have the NumLock LED change when you press Shift... 

Not on IBM machines.  Toggling the bits in the BIOS data area immediately
update the LED's (I just tried it to make sure I remembered correctly).
I have always assumed some type of interrupt generates the change, but it's
not the keyboard interrupt.  Could it be the timer interrupt? 

As for the command at port 64h, EDh is Set/Reset Mode Indicators.  The next
byte sets the LED's bit 2=Caps Lock, bit 1=Num Lock, bit 0=Scroll Lock.

Bradley Dyck Kliewer                Hacking...
bkliewer@iuvax.cs.indiana.edu       It's not just an adventure
                                    It's my job!>

leonard@bucket.UUCP (Leonard Erickson) (12/16/88)

In article <15736@iuvax.cs.indiana.edu> bkliewer@iuvax.UUCP (Bradley Dyck Kliewer) writes:
<In article <23a131e9@ralf> Ralf.Brown@B.GP.CS.CMU.EDU writes:
<>They only toggle because the BIOS checks for changed bits each time the
<>keyboard sends a scan code, and updates the LEDs if necessary.  There is a
<>specific command that you send the keyboard controller at I/O port 64h which
<>sets the LEDs, but I can't find it off-hand.
<>
<>So, if the program changes the status bits, but no keys are pressed, held
<>down, or released afterwards, the LEDs will not change.  Makes for a bit of an
<>unusual effect to have the NumLock LED change when you press Shift... 
<
<Not on IBM machines.  Toggling the bits in the BIOS data area immediately
<update the LED's (I just tried it to make sure I remembered correctly).
<I have always assumed some type of interrupt generates the change, but it's
<not the keyboard interrupt.  Could it be the timer interrupt? 
<
<As for the command at port 64h, EDh is Set/Reset Mode Indicators.  The next
<byte sets the LED's bit 2=Caps Lock, bit 1=Num Lock, bit 0=Scroll Lock.

Sorry, but the question was talking about *XT* class machines. Not even IBM XT
type machines will update keyboard LEDs (except maybe on PS/2 machines). This
should come as no surprise because there weren't any LEDs on keyboards back
then so the keyboards didn't expect to be told what to do with them...

-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."