News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How turn on and off keyboard leds?

Started by l0stb1t, January 28, 2005, 11:18:24 PM

Previous topic - Next topic

l0stb1t

How can I turn on and off the keyboard led's using asm, I always wanted to know if that was possible?

Thanks a lot for your time.

-l

asmGhost

I do believe you can use keyb_event or the SendInput functions to synthesize keystrokes.

l0stb1t

Thanks a lot for your time..I really apreciate it. But what Im looking for is how to do it straigh in asm, I dont want to call a function, instead write it myself.Thanks a lot.


-l

BogdanOntanu

That is not going to be possible under Windows XP and Win2k as you do not have direct access to hardware ports.
You should write an Kernel Mode Driver ;)

Here is the code form Solar OS:



key_led_status dd 0

;=============================================
; procedure that deals with Keyboard LEDs
; aka writes them
;=============================================
Write_LED_Status PROC STDCALL

@@wait_cmd_ready:
in al,64h
and al,02h
jnz @@wait_cmd_ready

;-------------------------
;write LED command
;-------------------------
mov al,0EDh
out 60h,al

@@wait_ready2:
in al,64h
and al,02
jnz @@wait_ready2

mov eax,[key_led_status]
out 60h,al

ret
ENDP
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

thomasantony

Hmmph!! Bogdan, you posted exactly when I was going to post a reply and SMF asked me to refresh to see the new post!! I was about to tell him he will have to code an OS with his own keyboard driver to turn LEDS on and off with his own proc. Thats a great aim for an OS. :lol

Thomas Antony :bdg :lol
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

MichaelW

This DOS program should run under any version of Windows, but it should be able to control the keyboard LEDs only under Windows 9x, or Windows 9x MS-DOS mode, or under DOS. This code doesn't call a function to control the LEDs, but it also doesn't directly control the hardware, as it depends on the system BIOS (or Windows emulating the system BIOS) to respond to changes in the keyboard flags and program the LEDs accordingly.

    .model small
    .486
    .stack
.data
.code
    .startup
    push  40h
    pop   es     ;set ES to segment address of BIOS data area
    mov   bx,17h ;set BX to offset address of keyboard flags
  @@:
    mov   BYTE PTR es:[bx], 10h ;set bit4, ScrollLock active
    mov   ah, 0                 ;BIOS Get Keystroke function
    int   16h                   ;wait for any key
    cmp   ah, 1                 ;check for Escape scan code
    je    fini                  ;exit if equal
    mov   BYTE PTR es:[bx], 20h ;set bit5, NumLock active
    mov   ah, 0
    int   16h
    cmp   ah, 1
    je    fini
    mov   BYTE PTR es:[bx], 40h ;set bit6, CapsLock active
    mov   ah, 0
    int   16h
    cmp   ah, 1
    je    fini
    jne   @B                    ;continue looping
  fini:
    .exit
end



eschew obfuscation

vitsoft

The same approach used by MichaelW is employed in my TSR skeleton at  http://www.vitsoft.info/tsrup.htm .

petezl

Hi Vit$oft,
I must congratulate you on your website. Very functional, easy to read and navigate and very well formatted.
A real change from the norm.  Did you use an application or write it directly in html ?
Peter. :cheekygreen:
Cats and women do as they please
Dogs and men should realise it.

Opcode

Take a look in the KbdGarland source inside
the Four-F KmdKit at
http://wasm.ru/baixado.php?mode=tool&id=221

Regards,
Opcode

vitsoft

Quote from: petezl on January 29, 2005, 10:07:14 AM
Did you use an application or write it directly in html ?

I use assembly language for everything I wrote recently,
including amorous letters :=)