I am trying to build myself a simple screensaver in C++, with windows.h and PDCurses.
A fundemental part of screensavers is closing the screensaver when the mouse is moved, clicked, or the keyboard is pressed... etc.
I have tried to find a way for PDCurses to sense any mouse event, but with no avail, and the windows.h way of doing this is too complex for a C++ newb like me, and I can't think of a way to sense keyboard events either. Here is my code:
#include <windows.h>
#include <curses.h> //actually PDCurses is what I have.
int main()
{
SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE), CONSOLE_FULLSCREEN_MODE, 0);
initscr();
raw();
keypad(stdscr, TRUE);
noecho();
curs_set(0);
int doty = 1, dotx = 1, xm = 1, ym = 1, maxy, maxx;
getmaxyx(stdscr, maxy, maxx);
while(1){
clear();
mvaddch(doty - 1, dotx - 1, char(219));
refresh();
delay_output(35);
if (doty >= maxy) ym = -1;
if (dotx >= maxx) xm = -1;
if (doty <= 1) ym = 1;
if (dotx <= 1) xm = 1;
dotx += xm;
doty += ym;
}
endwin();
return 0;
}
How would I go about detecting any keyboard or mouse events?