Skip to content

Instantly share code, notes, and snippets.

View TriceHelix's full-sized avatar
⌨️
coding

Trice Helix TriceHelix

⌨️
coding
View GitHub Profile
@TriceHelix
TriceHelix / linux_evdev_capabilities.md
Last active March 29, 2025 07:25
Decoding Input Device (evdev) Capabilities on Linux (alternative to EVIOCGBIT ioctl)

Decoding Input Device (evdev) Capabilities on Linux

Introduction

Input devices (whether physically present, or emulated) may produce any "kind" of input. In other words there is no clear distinction between a keyboard and a mouse, other than the data they (i.e., their drivers) write to their corresponding /dev/input/eventX file (where X is an integer). That can be problematic sometimes, for example if a program in userspace consumes input data from a device and expects that data to only contain certain keycodes, event types, etc. Another example could be a video game which displays different sprites/text when a gamepad is used instead of a keyboard, like key/button prompts in a tutorial or a settings menu. Luckily, most devices only write a strict set of event types and codes to their eventX file, because well, most hardware is only a keyboard, or mouse, or gamepad, or touchscreen, etc. and not a wild combination. The kernel calls these the input device's capabilities, as documented [here](ht

@TriceHelix
TriceHelix / float16.c
Last active November 13, 2022 11:34 — forked from neshume/float16.c
Super Fast Conversion Between Half-Precision and Single-Precision Floating Point Numbers in C
// float32
// Martin Kallman
//
// Fast half-precision to single-precision floating point conversion
// - Supports signed zero and denormals-as-zero (DAZ)
// - Does not support infinities or NaN
// - Few, partially pipelinable, non-branching instructions,
// - Core opreations ~6 clock cycles on modern x86-64
void float32(float* __restrict out, const uint16_t in) {
uint32_t t1;