Detect Multiple Keyboards?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Detect Multiple Keyboards?

Post by dizzykiwi3 »

I understand that this is very likely unable to be done, however I thought I'd ask:

If I have two keyboards plugged into my computer, would it be possible to differentiate a keypress on one keyboard from that of another? I was hoping to use this to allow people to do a quick cheap workaround for multiplayer if they don't have two controllers but have a keyboard lying around. Presently I can do this as is so long as they keybindings don't overlap, but I was wondering if there was another way.

Thanks a million all
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Detect Multiple Keyboards?

Post by zorg »

dizzykiwi3 wrote: Wed Apr 19, 2017 4:18 am I understand that this is very likely unable to be done, however I thought I'd ask:

If I have two keyboards plugged into my computer, would it be possible to differentiate a keypress on one keyboard from that of another? I was hoping to use this to allow people to do a quick cheap workaround for multiplayer if they don't have two controllers but have a keyboard lying around. Presently I can do this as is so long as they keybindings don't overlap, but I was wondering if there was another way.

Thanks a million all
Windows itself is able to differentiate between multiple mouses and multiple keyboards.
Don't know about OS X or the many Linuces though.
And as far as i know, SDL (sadly) doesn't expose this kind of information, probably because either it can't be coded to function on all platforms, or that no one wanted to hassle with it; in other words, since SDL doesn't support it, löve can't do it either.

(But, if you're willing to mess with the FFI, then maybe, just maybe, depending on the OS, you might find ways to accomplish this -in paralell- to löve's own keyboard (and mouse) methods that go through the SDL, so making it interoperate will be another hassle...)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Re: Detect Multiple Keyboards?

Post by dizzykiwi3 »

Gotcha gotcha... I figured as much, thanks for sincerely indulging me in this speculation though haha
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Detect Multiple Keyboards?

Post by raidho36 »

What is the use case of multiple keyboards anyway? Can you, like, have two windows opened at one time and use keyboard A to type in window A and keyboard B to type in window B, without switching focus?
MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: Detect Multiple Keyboards?

Post by MasterLee »

raidho36 wrote: Wed Apr 19, 2017 8:25 am What is the use case of multiple keyboards anyway? Can you, like, have two windows opened at one time and use keyboard A to type in window A and keyboard B to type in window B, without switching focus?
In split screen or by games with more than player on screen you can have multiple players using his own keyboard. Maybe he has an game where players compete against each other simultaneously by entering text or something.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Detect Multiple Keyboards?

Post by raidho36 »

Yes I can see that, I meant the OS support. If OS doesn't naturally support multiple keyboards, people wouldn't use more than one. Expecting people to use input mode more obscure than those 2000's 3d controllers is wishful.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Detect Multiple Keyboards?

Post by zorg »

raidho36 wrote: Wed Apr 19, 2017 9:42 am Yes I can see that, I meant the OS support. If OS doesn't naturally support multiple keyboards, people wouldn't use more than one. Expecting people to use input mode more obscure than those 2000's 3d controllers is wishful.
zorg wrote: Wed Apr 19, 2017 5:15 am Windows itself is able to differentiate between multiple mouses and multiple keyboards.
Don't know about OS X or the many Linuces though.
Source: Me being able to get that information in Delphi 7. But as i said, even if unix/linux/osx supported this too in one form or another, as long as someone doesn't fold themselves 6 times, this won't be supported in SDL... but hey, one can always design a controller with 100+ buttons or one with 2 axes and 3-5 buttons, right? Controllers CAN be differentiated :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Detect Multiple Keyboards?

Post by raidho36 »

Nix supported multiple prime input devices ages before Windows ever did. But yeah that's OS-specific, as far as I'm aware every OS uses its own interface for that.

With that in mind, I think my last question should be paraphrased as "do window managers support using multiple keyboards and how".
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Detect Multiple Keyboards?

Post by zorg »

That said, we're not really talking about multiple simultaneous pointers/keyboard input with multiple active windows, only that a löve project would be one active process, and the input devices, keyboards and mice, could be differentiated so that local multiplayer could work with multiple keyboards/mice instead of just controller devices.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Detect Multiple Keyboards?

Post by raidho36 »

Either way that would require SDL patching. On Windows there's MultiPoint Mouse SDK RawInput, as part of Windows SDK. On Nix systems, you can grab information from /dev/input/* corresponding to keyboards and mice, and read from it like from file. It outputs a few bytes that encode position of the mouse and buttons depressed, very easy to use, same with keyboards.
Post Reply

Who is online

Users browsing this forum: No registered users and 70 guests