Recent

Author Topic: USB keyboard  (Read 1614 times)

fuzzy1985

  • Newbie
  • Posts: 2
USB keyboard
« on: June 23, 2019, 11:47:01 am »
Hi,

I'm trying to make a program for a local club. The program needs to be used for judging.

Now i have multiple keyboard. How can i know from whick keyboard the key is pressed?

I already saw some documentation on codeprojects for c#, but i do not understand it.

Can someone help me?

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: USB keyboard
« Reply #1 on: June 23, 2019, 01:04:44 pm »
On which OS? Either way, this is not easy.

fuzzy1985

  • Newbie
  • Posts: 2
Re: USB keyboard
« Reply #2 on: June 23, 2019, 01:52:15 pm »
Windows 10

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: USB keyboard
« Reply #3 on: June 24, 2019, 07:52:11 am »
Could you elaborate on this unusual setup where Windows 10 has multiple keyboards? Perhaps describe the use case?

I know Windows 10 _can_ have multiple keyboards plugged in, but the keystrokes from all of them end up in the same place, as does the mouse pointer. I'm failing to see how multiple people can use their keyboard/mouse all at the same time...

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: USB keyboard
« Reply #4 on: June 24, 2019, 08:43:47 am »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: USB keyboard
« Reply #5 on: June 24, 2019, 09:02:43 am »
I know Windows 10 _can_ have multiple keyboards plugged in, but the keystrokes from all of them end up in the same place, as does the mouse pointer. I'm failing to see how multiple people can use their keyboard/mouse all at the same time...
Well, there certainly are possibilities as the remastered versions of the games Settler I and II (released November '18) support split screen multiplayer with two mice (as they did back on DOS ;) ).

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: USB keyboard
« Reply #6 on: June 24, 2019, 09:19:21 am »
You need to install a keyboard hook.

See: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v=vs.85)

But it doesn't say if you have to do that once (and how you determine the keyboard), or if you can select the keyboard.

And if that doesn't work, you have to write an USB HID driver.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: USB keyboard
« Reply #7 on: June 24, 2019, 10:04:00 am »
I'm trying to make a program for a local club. The program needs to be used for judging.

Now i have multiple keyboard. How can i know from whick keyboard the key is pressed?
I would prefer hardware way to solve such a problem. Like using some embedded microcontroller (like Arduino) via RS485, Bluetooth, or USB to provide custom buttons for each judge. If sticking with USB, then you can either emulate a HID gamepad/joystick, or give each judge a different set of HID keyboard keys.

Some related links:
https://www.obdev.at/products/vusb/prjhid.html
https://github.com/MHeironimus/ArduinoJoystickLibrary
https://github.com/Amadiro/arcade-joystick
https://github.com/menczel/avrhid
https://www.engineersgarage.com/contribution/atmega-32u4-based-gamepad
https://www.engineersgarage.com/contribution/atmega-32u4-based-generic-usb-keyboard
http://www.fourwalledcubicle.com/LUFA.php
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: USB keyboard
« Reply #8 on: June 25, 2019, 05:27:43 am »
I already saw some documentation on codeprojects for c#, but i do not understand it.

Can someone help me?

Perhaps a link to the article would help.

 

TinyPortal © 2005-2018