I am a translator by trade with a casual interest in free and open-source software. Over the years, I’ve explored various Linux distributions and even used one, elementary OS, for work for over a year with CafeTran. While I can’t consistently use Linux for work due to OS-dependent CAT tools like Trados and MemoQ, I always keep an eye on new releases on Distrowatch.com. I have a Lenovo ThinkBook dedicated to testing out these new distros.
Last month, another open-source project caught my eye—Haiku OS, which released its latest beta version: Haiku R1/beta5. Although it’s not a Linux distro per se, my curiosity got the better of me, and I decided to install it directly on my ThinkBook instead of just running the live version from a USB stick.
However, I encountered several issues. The touchpad didn’t work, forcing me to use a wired mouse. The Wi-Fi didn’t work either, and while I might as well connect via an ethernet cable, I prefer to avoid cables. Instead I make do with cloud services and a Wi-Fi connection. The camera was also non-functional, though I never use it, so that was no big deal. And lastly, Bluetooth doesn’t work either.
Of course, I turned to Google for solutions, hoping to find a fix for these issues, and I saw that other Haiku OS users had similar problems. Apparently, drivers are needed for these hardware, but Haiku’s small development team understandably can’t cover everything quickly. That’s when an idea struck me: how long would it take a tech layman like myself to learn how to write a driver?
I explained the issue to ChatGPT, and it provided the following guidance:
That’s an exciting challenge! Writing a touchpad driver involves understanding both the hardware (the touchpad) and the operating system (Haiku OS). I’ll guide you step by step through the process.
Step 1: Understanding Drivers and Hardware Interfaces
Drivers are essentially software that allows an OS to communicate with hardware. To write a touchpad driver, you’ll need to:
- Understand how the touchpad works and how it communicates with the system (e.g., via I2C, PS/2, or USB protocols).
- Learn how Haiku OS handles input devices.
What you need to learn:
- Basic C/C++ Programming: Drivers are usually written in these languages.
- Haiku OS Development Environment: Familiarize yourself with Haiku’s development tools and driver architecture. Haiku has an API for writing drivers.
- Touchpad Hardware Documentation: Identify the exact touchpad model and find its datasheet or protocol documentation (you can use lspci or lsusb to identify the device).
Step 2: Set Up Your Development Environment
- Install Haiku’s Development Tools: Haiku uses the GCC compiler. Install any additional development tools like git if necessary.
- Get Familiar with Haiku’s Input System: Start by exploring Haiku’s existing input device drivers. This will help you understand how Haiku OS interacts with hardware.
Step 3: Study Haiku’s Driver Model
Haiku drivers typically follow a specific structure:
- Initialization: Probing the hardware, setting up the device.
- Communication: Reading from and writing to the device (likely over I2C/PS2/USB).
- Handling Input: Interfacing with Haiku’s input subsystem to process touchpad gestures.
Step 4: Identify Your Touchpad’s Protocol
Most touchpads either use PS/2, USB, or I2C interfaces. Use tools like lspci (for PCI devices) or lsusb (for USB) in Linux or Haiku to identify your device. Once you have the touchpad model, look for its protocol documentation or try reverse-engineering the existing Linux driver if available.
Step 5: Start Small
- Begin with a minimal driver that can initialize the touchpad and detect input.
- Gradually expand it to handle gestures like clicks, scrolling, and multi-touch.
Resources:
- Haiku Developer Documentation: Check out Haiku’s documentation on writing drivers: Haiku Driver API.
- Touchpad Documentation: Search for hardware-specific documentation once you identify the model.
Next Steps:
- Do you want to start by setting up your Haiku development environment?
- Would you like help finding the touchpad protocol and figuring out what tools to use for development?
Let me know where you’d like to begin!
It’s a daunting challenge, and while I’m unsure how long it would take a professional developer to write this driver, I expect it would take me years. Yet, it’s not impossible—just difficult. In fact, the idea of diving into driver development feels like a new adventure, so I’ve decided to take the plunge.
I am starting off with familiarizing myself with the C language. I’ll document my progress on this blog as I encounter new issues and (hopefully) solutions. Stay tuned!