int main(int argc, char *argv[]) { /* Initialise the screen */ mywin = initscr(); noecho(); raw(); keypad(stdscr, TRUE); scrollok(mywin,1); idcok(mywin, 1); idlok(mywin, 1); /* Get the size of the window */ getmaxyx(mywin, nrows, ncols); clear(); refresh(); /* Set row and col */ r=0; c=0; /* The main loop */ while(1) { keyhandler(); } echo(); keypad(mywin, 0); endwin(); return 0; }
void isr_uart_for_keyboard(unsigned int intNum){ unsigned int baseaddr = modulelist[intNum].baseAddr; if(UARTIntPendingStatusGet(baseaddr) == UART_N0_INT_PENDING) return; unsigned int intval = UARTIntIdentityGet(baseaddr); if (intval == UART_INTID_RX_THRES_REACH) { for (int i=0;i<8;i++) { volatile unsigned char tempval = HWREGB(baseaddr+UART_RHR); ((unsigned char *)&keyTouchpadMsg)[i] = tempval; //UARTPutc(tempval); } if (isKeyTouchEvent(&keyTouchpadMsg)) { if(keyTouchpadMsg.type & MSG_TYPE_KEY){ g_keycode = keyCode(keyTouchpadMsg.keycode); atomicSet(&g_keyPushed); if(keyhandler!=NULL) keyhandler(g_keycode); } if (keyTouchpadMsg.type & MSG_TYPE_TOUCH) { g_ts.x = g_tsRaw.x = keyTouchpadMsg.tscval & 0xffff; g_ts.y = g_tsRaw.y = keyTouchpadMsg.tscval >>16; ts_linear(&tsCalibration, (int *)&g_ts.x, (int *)&g_ts.y); atomicSet(&g_touched); } if (keyTouchpadMsg.type & MSG_TYPE_KEYRESET) { atomicSet(&g_keyRest); } } }
SimPositionDeviceDriver::SimPositionDeviceDriver(json::Value config) { mouseOffsetX = 0; mouseOffsetY = 0; for (json::Value::Iterator it = config.begin(); it != config.end(); it++) { std::string key = it.key(); json::Value &value = it.value(); if (value.isMember("initial")) data[key].position = glm::vec3(value["initial"][0].asFloat(), value["initial"][1].asFloat(), value["initial"][2].asFloat()); if (value.isMember("camera")) if (value["camera"].asBool()) data[key].isCamera = true; static struct ActionMapping { std::string str; Action action; } actionMapping[] = { { "xneg", TRANS_X_NEG }, { "xpos", TRANS_X_POS }, { "yneg", TRANS_Y_NEG }, { "ypos", TRANS_Y_POS }, { "zneg", TRANS_Z_NEG }, { "zpos", TRANS_Z_POS }, { "rotxneg", ROT_X_NEG }, { "rotxpos", ROT_X_POS }, { "rotyneg", ROT_Y_NEG }, { "rotypos", ROT_Y_POS }, { "rotzneg", ROT_Z_NEG }, { "rotzpos", ROT_Z_POS }, }; for (int ii = 0; ii < sizeof(actionMapping) / sizeof(ActionMapping); ii++) if (value.isMember(actionMapping[ii].str)) keyHandlers[key].push_back(keyhandler(actionMapping[ii].action, KeyboardDeviceDriver::parseString(value[actionMapping[ii].str].asString()))); } }