If there is an existing hardware that you can use, such as a mouse as a simple example, then all you need to do is communicate with the driver via it is API. If you plan to make your own hardware, then depending on your budget, you may be able to create a custom device and create your own driver and API.