enabling led light in Keyboard

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
neoahead
Posts: 3
Joined: Tue Mar 31, 2009 12:57 pm

enabling led light in Keyboard

Post by neoahead »

i got little confused while coding keyboard handler,
i am sending 0xED( Set/Reset Mode Indicators) request to keyboard port 60h

then i want to set CAPSLOCK led- but according to keyboard datasheet-

ED Set/Reset Mode Indicators, keyboard responds with ACK then
waits for a following option byte. When the option byte is
received the keyboard again ACK's and then sets the LED's
accordingly. Scanning is resumed if scanning was enabled.
If another command is received instead of the option byte
(high bit set on) this command is terminated. Hardware
defaults to these indicators turned off.

|7-3|2|1|0| Keyboard Status Indicator Option Byte
| | | `--- Scroll-Lock indicator (0=off, 1=on)
| | `---- Num-Lock indicator (0=off, 1=on)
| `----- Caps-Lock indicator (0=off, 1=on)
`------- reserved (must be zero)

not sure whats that option byte means and how to set that
so could some help me out here...


here is piece of my code

Code: Select all

if((inp8(0x64)&2) == 0) break;
			outp8(0x60,0xED);
			outp8(0x60,0x04);
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: enabling led light in Keyboard

Post by Dex »

Use

Code: Select all

	mov   [keyBoardStatus],0xb0	 ; set like this on startup
	call  SetKeyBoardLeds		 
;;;;;;;;;;;;;;;;;;;;;;These will turn the cap lock leds on or off;;;;;;;;;;;;;;;;;;;;;;;;;;
	xor   [keyBoardStatus],4 
	call  SetKeyBoardLeds
;---------------------------------
	and   [keyBoardStatus],0xfb
	call  SetKeyBoardLeds
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;====================================================;
; Set keyboard leds                                  ;
;====================================================;

SetKeyBoardLeds:
	push  eax
	mov   al,0xed				     
	out   60h,al				      
KeyBoardWait:
	in    al,64h
	test  al,10b				      
	jne   KeyBoardWait			      
	mov   al,byte [keyBoardStatus]
	and   al,111b
	out   60h,al				      
	pop   eax
	ret
neoahead
Posts: 3
Joined: Tue Mar 31, 2009 12:57 pm

Re: enabling led light in Keyboard

Post by neoahead »

thanx alot dude....

u really saved me from bursting my head out :)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: enabling led light in Keyboard

Post by JamesM »

neoahead wrote:thanx alot dude....

u really saved me from bursting my head out :)
So you know what you were doing wrong? If you look at his code the only thing different is that he sends the 0xED command then polls for the status change, whereas you poll for a status change before sending the command.

Cheers,

James
Post Reply