Skip to main content
Dev Portfolio
All projects

Linux Loadable Kernel Module (C)

A loadable kernel module implementing a character device for an 8BitDo Micro gamepad, paired with a userspace application that reads gamepad signals and executes terminal commands.

Type
Team
Team
4 people

Problem

Reading and acting on gamepad input required kernel-space character device handling rather than a userspace-only driver.

Role

Built with a team of four for Operating Systems coursework. I owned the kernel-space side — the character device driver that registers with the kernel and exposes gamepad input to userspace.

How it works

The project is a two-part driver: a kernel module and a userspace application either side of a single character device. lkm_char_driver registers the device with the kernel — this is the part I built. Once loaded with insmod, it exposes itself as a character device node that userspace can open and read from like any other file, which is what lets a normal C program talk to kernel-space code without touching the kernel itself. dmesg -W shows the module's log output live, which is how we watched the driver register and respond to reads while it ran. userspace_app is a small C program that opens that device, reads the gamepad state through it, and maps button presses to actions. The target hardware is an 8BitDo Micro Bluetooth gamepad, configured in D-input mode and connected either over Bluetooth or wired. The mapped actions are a set of pre-saved terminal commands — things like lspci and lsmod — so pressing a button on the gamepad runs a shell command without a keyboard, effectively a controller-driven terminal mode.
user spaceuserspace appsyscall boundarykernel space/dev char device8BitDo pad
Fig. — the userspace app reaches the gamepad through a character device in the kernel.

Stack

  • C
  • Linux kernel modules

Result

A working character device registered in the kernel, with a userspace application reading gamepad signals over it and executing pre-saved terminal commands based on them.