keyb leds

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
Fukuda

keyb leds

Post 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


mr. xsism

Re:keyb leds

Post 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.
Post Reply