Page 1 of 1

keyb leds

Posted: Wed Dec 10, 2003 3:13 pm
by Fukuda
Not so sure where did I wrong but I can not change kyb leds.

Code: Select all

unsigned int SetLedState(unsigned int LedNo, bool State)
{
    if(State == ON)
        KeyboardLeds |= LedNo;
    else if(State == OFF)
        KeyboardLeds &= ~LedNo;
    else if(State == LED_REVERSE)
        KeyboardLeds ^= LedNo;

    while(!(in(KEYBOARD_COMMAND_PORT) & 2));             <- stucks here!
    out(KEYBOARD_DATA_PORT, 0xED);

    while(!(in(KEYBOARD_COMMAND_PORT) & 2));
    out(KEYBOARD_DATA_PORT, KeyboardLeds);

    return KeyboardLeds;
}

Code: Select all



Re:keyb leds

Posted: Thu Dec 11, 2003 2:55 am
by mr. xsism
/ me digs up some old code...

Code: Select all

void SetLED(byte led)
{
   if(!led)
   {
      LED_STATUS=0;
   }else
   {
      LED_STATUS ^= led; // XOR the LED bit [XOR toggles the bit]
   }

   outportb(KEYDATA,0xED);
   while(inportb(0x64) &2); // wait for no keys pressed(Input Buffer Clear)[0x2 = 10 bin]
   outportb(KEYDATA, LED_STATUS);
   while(inportb(0x64) &2);
}
and...

Code: Select all

/*
 * LED light references
 */
#define LED_SCROLL  1
#define LED_NUM     2
#define LED_CAPS    4
There you go. Compare my code with yours. You may also be writing it to the wrong port. IIRC it should be 0x60. I think.