I am working on a CHIP-8 emulator to be used on a Linux system. As I understand it, I need to get keyboard input from (any) 16 keys and map these to a hex keypad. Once I get the inputs, I have no trouble mapping them to the 16 CHIP-8 keys.
However, I cannot figure out how to actually tell if a key is pressed. I believe in Java I would use keylistener, but I cannot find anything analogous for Linux in C++. Is there a way I can tell what (if any) specific keys are pressed at any given time? Something like a getKeyState function I could call?
Thanks in advance.
There is this tutorial on ncurses
. NCURSES Programming HOWTO. I have confirmed that on my MacBook Pro, Mavericks 10.9.1, with the Xcode Command Line Tools installation, that the ncurses.h
is a symbolic link to curses.h
, both located in /usr/include
. This is the NCURSES Introduction page.
I have not created a specific class myself. However, some searching on /dev/input/eventX
, where X seems to be either a zero or one finds these two separate posts:Read from /dev/input and linux keypress events.