Here is the method I came up with. Seems to work on my laptop. Let me know what you think.
//Attempt to detect when a user logs in.
void WaitForUserToLogin(uint16_t timeToLogin)
{
//Get value of keyboard leds just for caps lock.
uint8_t caps = keyboard_leds & 0b00000010; //Second bit is for caps lock
//If caps lock isn't on, turn it on.
if(caps == 0)
{
usb_keyboard_press(KEY_CAPS_LOCK, 0);
}
//Wait a second before we begin checking.
PDDelay(1000);
//Wait for caps to be turned off.
do
{
//Get value of keyboard leds just for caps lock.
caps = keyboard_leds & 0b00000010; //Second bit is for caps lock
}
while(caps == 2);
//Delay to allow time for the user to login.
PDDelay(timeToLogin);
}