raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
21.58k stars 2.19k forks source link

[core] Mouse and keyboard detection on plug/unplug #1238

Closed gezzuzz closed 4 years ago

gezzuzz commented 4 years ago

im running raylib in native mode..

When i start my program with mouse and keyboard plugged in at boot.. they work fine.

if i disconnect and reinsert them.. they do not come back.. also if i dont have a keyboard plugged in when i start my program they will not work.

how does raylib detect input devices?

thank you

raysan5 commented 4 years ago

is it on Raspberry Pi?

gezzuzz commented 4 years ago

is it on Raspberry Pi?

yes..

at command prompt it detects the mouse and keyboard if plugged in after boot... or it removed and replugged in..

gezzuzz commented 4 years ago

it seem what ever you have when you start the program works.. as long as you dont disconnect it

raysan5 commented 4 years ago

@gezzuzz inputs processing in RPI native is different than other platforms, actually, it has been reviewed several times... Current implementation uses dev events in separate threads to detect inputs...

gezzuzz commented 4 years ago

There is a function in core.c.. InitEvdevInput if i call it. the keyboard starts to work fine. Since its not in raylib.h by default i can not access it.

i was able to make it work by removing Static then i added it to raylib.h RLAPI void InitEvdevInput(void);

Im not sure it this is the proper way.. But i would like to make InitEvdevInput public. Is there is a reason not to make this function public?

i figured i could call this function on a timer so that i can redetect input devices..

gezzuzz commented 4 years ago

Better yet i can check for changes to "/dev/input/" if any devices get added to removed it shows here.. then i call InitEvdevInput to reset everything. (only need for linux)

            #if !defined(__x86_64__)            
            GetDirectoryFiles("/dev/input/",&fileCount);
            if(fileCount != lastDeviceCount){
                InitEvdevInput();
                lastDeviceCount = fileCount;
            }
            #endif
raysan5 commented 4 years ago

@gezzuzz that's nice... but for the moment no plans to expose that function...

raysan5 commented 4 years ago

Closing this issue.