int main() { //register keys to track vector<int> keyCodes { VK_LBUTTON, VK_RBUTTON, VK_TAB, VK_DELETE, VK_F1,VK_F2,VK_F3,VK_F4,VK_F5, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x41, 0x44, 0x45, 0X46, 0x51, 0x52, 0x53, 0X57 }; vector<int> menuKeyCodes{ VK_END, VK_HOME, VK_DOWN, VK_UP, VK_RETURN }; //load config and notifications Config config("config.txt"); Notification notification(config); while (true) { system("CLS"); //display the menu KeyPress menuKeys(config, menuKeyCodes, "menuKeys"); Display mainMenu(config, BUFFER_SIZE, menuKeys); checkKeys(menuKeys, mainMenu, notification, menuKeyCodes, 1); //ckeck for keys and display the counter screen KeyPress keyLogger(config, keyCodes, "keyLogger"); Display counter(config, BUFFER_SIZE, keyLogger); checkKeys(keyLogger, counter, notification, keyCodes); } //exit main return 0; }
//execute the menu //cycle: // ...->draw -> input scan -> iterations -> [activate submenu or user function] -> ... // draw: call target device object //input scan: call the navigation function (self) void menu::activate(menuOut& p,Stream& c,bool canExit) { if (activeNode!=this) { action(*this,p,c); previousMenu=(menu*)activeNode; activeNode=this; sel=0; p.top=0; this->canExit=canExit; } int op=-1; printMenu(p,canExit); op=menuKeys(p,c,canExit); if (op>=0&&op<sz) { sel=op; if (data[op]->enabled) { printMenu(p,canExit);//clearing old selection data[op]->activate(p,c,true); } } else if (op==-1) {//then exit p.clear(); activeNode=previousMenu; c.flush();//reset the encoder } }