Home > Mobile >  Emulate keyboard event arrow keys in C
Emulate keyboard event arrow keys in C

Time:10-12

Short: help emulate keyboard events (arrow keys, enter) in C code under linux.

Long: I am working at interfacing iPod clickwheel with Raspberry Pi. At the moment i can printf to terminal something like "button 1 pressed". But i need system-wide event, just like a keypress from real keyboard. My other code is on C so i cant implement Python.

CodePudding user response:

You really should use third-party libraries. There's definitely no platform-independent way to do it in ANSI C. You can try using conio.h with its kbhit() function , the library can be downloaded from conio.

Or you can read the up /down /right /left keys from the terminal like

CodePudding user response:

You can maybe use SDL2, it works with Raspberry Pi and Linux and you can manage inputs events such as keyboard, mouse, pads etc.

More info here: https://wiki.libsdl.org/SDL_Event

  • Related