Jump to content

Linux Input Device KEY= Bitmaps??? Solved

Go to solution Solved by BobVonBob,
9 hours ago, 1.618Tesseracts said:

Well I've done that before (used input libraries to get input events) but I was intrigued when I did:

cat /proc/bus/input/devices

because one line has a bitmap given in hex that supposedly contains all the keys on the device, but I couldn't find anything on how to use/understand/decode it manually or otherwise...

 

But, Thank you so much! I'd found that article but I guess my brain was so fried and tired that I completely missed that ioctl will decode the properties of the device.🤦‍♂️ Oh well. 

Ah, the key value is a giant bitmask of the keys from this file:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

I was looking at input devices and noticed there is a field that reports what keys are available on the device(when applicable). However I have been unable to figure out how to use the hex number given to tell me what keys it has. It says it's stored as a bit map, but I've been unable to find anywhere the map of values. This article is helpful and explains how it works, but it's for another field: https://unix.stackexchange.com/questions/74903/explain-ev-in-proc-bus-input-devices-data

 

I tried googling it to no avail, I can't find any documentation on it, and even reading through some of the source code I've been unable to find a way to understand the hex bit map. Granted I don't know C, nor do I have a deep understanding of the intricacies of linux, so it's possible even likely that I've missed something, but I don't know where else to go.

 

Does anyone know how I can find the map of values or how I can decode the value given?

Specifically this:

B: KEY=20000 200 20 0 0 0 0 500f 2100002 3803078 f900d401 feffffdf ffefffff ffffffff fffffffe

Thanks for any pointers or help!

Edited by 1.618Tesseracts
Solved
Link to comment
Share on other sites

Link to post
Share on other sites

I'm not sure what exactly you're trying to accomplish, but you almost certainly don't need to bother with any of this yourself. Other people have written input libraries and/or utilities to get keys from input devices. Take advantage of them.

This SE post has some additional detail similar to the one you linked, and it mentions some tools to avoid dealing with it.:
https://unix.stackexchange.com/questions/94322/is-it-possible-for-a-daemon-i-e-background-process-to-look-for-key-presses-fr

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, BobVonBob said:

I'm not sure what exactly you're trying to accomplish, but you almost certainly don't need to bother with any of this yourself. Other people have written input libraries and/or utilities to get keys from input devices. Take advantage of them.

This SE post has some additional detail similar to the one you linked, and it mentions some tools to avoid dealing with it.:
https://unix.stackexchange.com/questions/94322/is-it-possible-for-a-daemon-i-e-background-process-to-look-for-key-presses-fr

Well I've done that before (used input libraries to get input events) but I was intrigued when I did:

cat /proc/bus/input/devices

because one line has a bitmap given in hex that supposedly contains all the keys on the device, but I couldn't find anything on how to use/understand/decode it manually or otherwise...

 

But, Thank you so much! I'd found that article but I guess my brain was so fried and tired that I completely missed that ioctl will decode the properties of the device.🤦‍♂️ Oh well. 

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, 1.618Tesseracts said:

Well I've done that before (used input libraries to get input events) but I was intrigued when I did:

cat /proc/bus/input/devices

because one line has a bitmap given in hex that supposedly contains all the keys on the device, but I couldn't find anything on how to use/understand/decode it manually or otherwise...

 

But, Thank you so much! I'd found that article but I guess my brain was so fried and tired that I completely missed that ioctl will decode the properties of the device.🤦‍♂️ Oh well. 

Ah, the key value is a giant bitmask of the keys from this file:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×