Jump to content

[Version 1] Detecting When Someone Logs In


Recommended Posts

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);
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...