Retry a few times if opening keyboard fails in consoled.
I'm using consoled at the moment without input_server having been run, so when it starts the input drivers will not have been loaded. Have to retry a few times with delays so that the input devices have a chance to appear.
This commit is contained in:
@@ -223,9 +223,18 @@ stop_keyboards(struct console* con)
|
|||||||
static struct keyboard*
|
static struct keyboard*
|
||||||
open_keyboards(int target, const char* start, struct keyboard* previous)
|
open_keyboards(int target, const char* start, struct keyboard* previous)
|
||||||
{
|
{
|
||||||
DIR* dir = opendir(start);
|
// Wait for the directory to appear, if we're loaded early in boot
|
||||||
if (dir == NULL)
|
// it may take a while for it to appear while the drivers load.
|
||||||
return NULL;
|
DIR* dir;
|
||||||
|
int32 tries = 0;
|
||||||
|
while (true) {
|
||||||
|
dir = opendir(start);
|
||||||
|
if (dir != NULL)
|
||||||
|
break;
|
||||||
|
if(++tries == 10)
|
||||||
|
return NULL;
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
struct keyboard* keyboard = previous;
|
struct keyboard* keyboard = previous;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user