Usb keyboard driver linux
Hello there! Here is a blog of a kite.
Welcome to communicate with me.
The KERNEL version is 4.4.17.
Writing USB keyboard driver, you can refer to the Kernel usbkbd.c in this file.
I have more effort to drive all the routine . The process is almost the same.
In this document, the most important is to see usb_kbd_probe usb_kbd_irq function and the function.
There are the most beginning in the file:
This is the code table of the USB keyboard, which needs to be used when reporting the button event.
Then there is the usb_kbd_probe function, and it is a little bit of content, I have used the written comments, it is quite simple (in fact, the comment is also copied to me, /////// Cover
It feels that there is a main thing, that is:
Get a descriptor.
Set the endpoint to the interrupt IN endpoint.
Assign KBD, Input_DEV space.
Fill the USB device structure and the input device structure.
To «vendor name product name» format writes kbd-> name.
Set the type of event reporting the input subsystem.
Setting what is reported to report the input subsystem.
Set the process of registering, open, and close the function portfolio.
Initialization interrupt URB.
Initialization control URB.
It feels almost.
The main still USB_KBD_IRQ interrupt function.
Among them, each interrupt received value is 8 bytes, which is like this:
data0 data1 data2 data3 data4 data5 data6 data7
Generally, when only one key is pressed, the key value will appear on DATA2.
When the keyboard is pressed as a, data: 0,000,040,000,000,000.
When a key is released data: 0,000,000,000,000,000.
At the same time, press two keys, the key value of the second key will appear on DATA3.
B press key while pressing a, data: 0,000,040,500,000,000.
So you can press 6 buttons at the same time.
Next, it is very good to analyze the interrupt function:
This sentence is used to detect modified keys, although I do not make any modification key is .
Wherein, kbd-> new buffer is urb, there in a probe function: usb_kbd_alloc_mem (dev, kbd), function as kbd-> new 8 bytes of memory allocated: kbd-> new = usb_buffer_alloc (dev, 8, GFP_ATOMIC, & KBD-> New_DMA),
and interrupt initialization function urb usb_fill_int_urb (kbd-> irq, dev, pipe, kbd-> new, (maxp> 8 8:? Maxp), usb_kbd_irq, kbd, endpoint-> Binterval);
data that is acquired from the new end point will be placed in memory inside, up to 8 bytes.
is the real next common key detection:
Because the key is located in data2 and after, so the for loop i = 2 from the beginning query.
for if there are two, if the first determination is whether the key is released, if the second determination is whether the key has been pressed.
Wherein MemScan function is to determine whether the key equal, kbd-> old key is stored in the previous data, kbd-> new keystroke data which is, in string.c MemScan function, as follows:
Very simple C language function, mainly judging whether it is equal. By the previous data and the comparison of this data, you know if the button is pressed. Then report the button event.
Finally, memcpy (kbd-> old, kbd-> new, 8); members of the assignment is to kbd-> new to kbd-> old, old and new data storage realized.
All right. Next, write the driver will be scoop on the hoist:
kbd in which I did not use, do not write, you can achieve a button.
Finally, Make compiled, insmod my_keyboard.ko
Plug in the keyboard, the USB keyboard is hot and plugged, and it is fine.
You can see the data pressed on the keyboard.
Oh, forgot, I am a 4.4.17 kernel, the driver of the USB keyboard is not compiled into the kernel, so INSMOD does not have problems when I write it yourself. Other kernel needs to pay attention to it, avoid loading conflicts.
If you want to drive with kernel,
Device Drivers —> HID support —> USB HID support —> USB HID transport layer
Select USB HID TRANSPORT LAYER.
It is estimated that the previous kernel is
Device Drivers —> HID support —> USB Human Interface Device (full HID) suppoort
By default, it is selected. Anyway, my current Kernel is USB Human Interface Device (Full Hid) Suppoon No, it is estimated to become USB HID TRANSPORT LAYER.
Источник
Keyboards
Driver and Tools
Downloads
WinProgrammer Version 2.5 Build20213
Use this full package to create key assignments and key labels for all our programmable keyboards. This latest release contains many improvements and new templates. Details and further information about installation are listed in the Readme , a portable version is available on request. For getting started programming our keyboards, please consult the Quickstart manual which will be installed accordingly. Latest version of this document is available in the Manuals section. (2020 May 20)
MapMyKey for Windows
For our USB devices you also can use our Windows software «MapMyKey» in addition or as an alternative. This way flexible, application-dependent key sequences and shortcuts can be sent, applications can be started or web pages can be opened. User Manual is included in installation, latest changes are listed in the changelog. For general information and instruction videos please see our overview page «Your Keyboard». (2020 Sep 02)
C2K — Download Utility for Windows — Portable ZIP
C2K («Copy to Keyboard») utility downloads an existing keytable (MWF or MWX file) into your PrehKeyTec keyboard. C2K can also read out the keytable (as binary MWX file). C2K is also integrated in above WinProgrammer installation package and will be installed accordingly.
Use this «Portable ZIP» archive a s an alternative — e.g. for deploying only the C2K utility to target machines.
Important note: For PS2 keyboards, you must install the necessary driver support «DriverPack» in addition. Please see Readme for details. (2020 May 20)
Copy2mci — Download Utility for Linux OS
This command line utility configures our MCI family USB keyboards on Linux (kernel 2.6.x or newer). Package is available on request — please contact support[at]prehkeytec.de .
DOS-Programmer — Version 4.1.09
Use this tool to program PS2 keyboards of MWX, MC and PC-POS family under DOS and Windows 3x/95/98. Alternative download packed as MWX4109.ZIP . (06/17/2005, archived*)
Important note: For programming newer PS2 keyboards models like the MCI family only use the updated download utility copy2mwx.exe V4.11 included in this package.
Our APIs and OPOS/JavaPOS packages help you to implement PrehKeyTec devices into your customer application:
PKTUSBAPI, V5.1.0.13 (USB)
Our new PKTUSBAPI enables direct communication with our USB devices and their modules (MSR, Keylock, OCR, LCD, etc.) within your own applications. Our API supports multiple devices and event handling. This package is for Windows, other packages for Linux and Android are available on request.
View Readme for details — full documentation is included in the ZIP archive. (Jan 20 2020 )
OPOS Service Objects Version 1.10.007.18343
Using our OPOS service objects you can control the following keyboard modules: PosKeyboard , MSR, Keylock and ToneIndicator. Updated SO installer — view Readme for details. (Aug. 22 2018)
Complete OPOS Package 1.10.007b (OPOS_20080822.EXE)
In addition to an older SO installer, the CCOs V1.10.001 from C. Monroe and sample applications are included in this complete package. View Readme for details. (Aug. 22. 2008)
JavaPOS Package for Windows, Version 1.12.086
The latest Windows version of our JavaPOS service is able to control the following keyboard modules: Keyboard (POS keys), MSR (integrated in keyboard), keylock and tone indicator. View Readme for details. (09/23/2009)
JavaPOS Package for Linux
The Linux version of our JavaPOS service is able to control the following keyboard modules: Keyboard (POS keys), MSR (integrated in keyboard), keylock and tone indicator. Package is available on request — please contact support[at]prehkeytec.de .
MWXUSB.DLL API, V4.16.0.0 (USB)
This API enables direct communication with our USB keyboards and their modules (MSR, Keylock, etc.) within your own MS Windows applications. Documentation included in the ZIP archive (Sep. 16 2016, archived*)
MWX Function DLL Version 4.01 (PS/2)
This API helps you to directly communicate with our PS/2 keyboard hardware and integrated modules (MSR, Keylock, etc.) within your own MS Windows applications. (11/30/2001, archived*)
DriverPack Version 1.6.0 Build18282
In the meantime, the DriverPack is mostly obsolete. Installation is only required to send commands to PS/2 keyboards and for using older Windows packages like OPOS/JavaPOS!
But here it installs all necessary components for communicating with our keyboards. It is required for all packages like WinProgrammer, OPOS and JavaPOS. It is always included in those packages, but here you always will find the latest version. Operating systems supported: Windows NT4/2000/XP/7 or newer (for PS/2 only 32bit!). View Readme for details. (July 10 2018)
Px — Passport/OCR Reader Module
OCR/MSR/AUX Wedge-Module «P2» / «P4» (included in Airline-Devices MCI 111 A / ML 2 A):
Our software «CheckinPackage» is usually provided by your software integrator. This package includes a configuration utility, VirtualCOM drivers for USB, manuals and additional information. Of course we also can provide these on request — please contact support[at]prehkeytec.de.
OCR/Passport Reader Module «P1»
ZIP package including drivers and demo application for the OCR reader module — product code «P1» (e.g. used in MCI 111 and ML 2). Regarding installation please refer to included instruction sheet and Readme. (April 29 2013)
OCRWedge 2.1a — for OCR/Passport Reader Module «P1»
Software keyboard wedge for above OCR module «P1» (e.g. used in MCI 111 and ML 2). Regarding installation please refer to the included Readme. (April 15 2010)
Sx — Smartcard Module
Cardman SmartCard Reader «S1/S2/S3»
Installation instructions for the smart card reader module integrated in the new keyboard families MC147 or MCI series. Product code «S1» (CardMan 3e20 USB), «S2» (CardMan 3e10 RS232) and «S3» (CardMan 3121 USB). (Feb. 08 2011)
Dx — Display Module
VFD LineDisplay Modul «DM02» (90328-90x/0800)
ZIP package including manuals, drivers and configuration tools — please see included readme.txt for details. (Feb. 08 2011)
T1 — TouchKey-Modul
TouchKey Programmer V2.0 (Build 110406) (Apr. 06 2011)
TKDemo_(Build 110406) (Apr. 06 2011)
Both packages require Windows XP and .NET framework 2.0 — Download here.
Software keyboard wedge OCRWedge21a.EXE
WinProgrammer Version 2.3.2 (July 31 2009)
WinProgrammer Version 2.2 (Aug. 16 2006)
WinProgrammer Version 2.1.1 (Apr. 04 2005)
WinProgrammer Version 2.0 (May 05 2004)
WinProgrammer Version 1.8 (Nov. 12 2002)
Standalone package C2k_20090731.ZIP (July 31 2009)
Standalone package C2K_V4020.ZIP (June 14 2006)
Standalone package C2K_V4011.ZIP (Sept. 29 2005)
OPOS Service Objects Version 1.10.007a (Nov. 20 2007)
OPOS Service Objects Version 1.10.007 (Feb. 2007)
OPOS Service Objects Version 1.4.0.56_1 (Sep. 21 2005)
JavaPOS package for Windows, Version 1.6.0.64 (09/17/2003)
DriverPack Version 1.4.0.0 (Aug. 22 2008)
DriverPack Version 1.3.0.1 (Nov. 20 2007)
DriverPack Version 1.2.0.0 (Feb. 2007)
DriverPack Version 1.1.0.1 (Mar. 03 2005)
DriverPack Version 1.0.0.3 (July 05 2004)
PS/2 Keyboard Driver for Windows2000 / XP
The PS/2 keyboard driver for Windows 2000/XP is already included in the installation of the DriverPack. View Readme for details. (Mar. 08 2004, archived*)
Programmer for DOS Version 4.0.32
Only to be used for keyboards manufactured before 1996. The first digit of the four-character Datecode on the keyboard represents the production year. Does not support DOS box under Win9x.
Programmer for the old keyboard type AT-3.
Only to be used for DOS and Windows3.x. Driver does not work on Windows9x, WinNT or newer!
T1 — TouchKey-Module
TouchKey Programmer V2.0 (Build 110406) (Apr. 06 2011)
TKDemo_(Build 110406) (Apr. 06 2011)
Both packages require Windows XP and .NET framework 2.0 — Download here.
Источник