void input_key_normal(unsigned char key, int x, int y) { if (key == 'c') { keypress(103); //decrease charging } if (key == 'C') { keypress(104); //increase charging } }
void QIMPenInput::wordPicked( const QString &w ) { int bs = matcher->word().length(); for ( int i = 0; i < bs; i++ ) keypress( Qt::Key_Backspace << 16 ); for ( unsigned int i = 0; i < w.length(); i++ ) keypress( w[i].unicode() ); matcher->resetState(); wordPicker->clear(); }
void run(void) { XEvent ev; while(running && !XNextEvent(dc->dpy, &ev)) { if(XFilterEvent(&ev, win)) continue; switch(ev.type) { case Expose: if(ev.xexpose.count == 0) mapdc(dc, win, mw, mh); break; case KeyPress: keypress(&ev.xkey); break; case SelectionNotify: if(ev.xselection.property == utf8) paste(); break; case VisibilityNotify: if(ev.xvisibility.state != VisibilityUnobscured) XRaiseWindow(dc->dpy, win); break; } } }
/* * Separate display connection for each thread. */ static void event_loop_multi(void) { XEvent event; int w = 0; assert(MultiDisplays); while (!ExitFlag) { struct winthread *wt = &WinThreads[w]; if (XPending(wt->Dpy)) { XNextEvent(wt->Dpy, &event); switch (event.type) { case ConfigureNotify: resize(wt, event.xconfigure.width, event.xconfigure.height); break; case KeyPress: keypress(&event, wt); break; default: ; /* nop */ } } w = (w + 1) % NumWinThreads; usleep(5000); } }
static void run(void) { XEvent ev; while (!XNextEvent(dpy, &ev)) { if (XFilterEvent(&ev, win)) continue; switch(ev.type) { case Expose: if (ev.xexpose.count == 0) drw_map(drw, win, 0, 0, mw, mh); break; case FocusIn: /* regrab focus from parent window */ if (ev.xfocus.window != win) grabfocus(); break; case KeyPress: keypress(&ev.xkey); break; case SelectionNotify: if (ev.xselection.property == utf8) paste(); break; case VisibilityNotify: if (ev.xvisibility.state != VisibilityUnobscured) XRaiseWindow(dpy, win); break; } } }
int main(int argc, char *argv[]) { if(!(dpy = XOpenDisplay(NULL))) { printf("wimp: error: Can't open display!\n"); return 1; } if(init()) { printf("fail\n"); return 1; } grabkeys(); /* This is the main loop! */ printf("wimp: Starting main event loop.\n"); while(running) { XNextEvent(dpy, &ev); switch(ev.type) { case KeyPress: keypress(&ev); break; } } XCloseDisplay(dpy); return 0; }
void rungui(const char **user, const char **pass) { Input *i; XEvent ev; running = True; XSetInputFocus(dpy, inputs->win, RevertToPointerRoot, CurrentTime); XSync(dpy, False); while (running && !XNextEvent(dpy, &ev)) { if (XFilterEvent(&ev, None) || !(i = wintoinput(ev.xany.window))) continue; switch (ev.type) { case Expose: if (ev.xexpose.count == 0) drawinput(i); break; case KeyPress: keypress(i, &ev.xkey); break; case FocusIn: i->cursor = strlen(i->text); /* fallthrough */ case FocusOut: drawinput(i); break; } } *user = inputs->text; *pass = inputs->next->text; }
void main(void) { char a; P3_4=1; while(1) { a=scan(); if (a) { P3=a & 0x0F; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=0; P3_4=1; while(keypress()==1){ }; } } }
char scan(void) { char a,b,c,scankey; a=keypress(); scankey=-1; if (a) { b=findrow(); c=findcol(b); switch (c) { case 1: scankey=(b*4)+0;break; case 2: scankey=(b*4)+1;break; case 4: scankey=(b*4)+2;break; case 8: scankey=(b*4)+3;break; default : break; } } return scankey; }
static void event_loop(Display *dpy, Window win) { XEvent event; while (1) { XNextEvent( dpy, &event ); switch (event.type) { case Expose: redraw(dpy, WindowID, win); break; case ConfigureNotify: /*resize( event.xconfigure.width, event.xconfigure.height );*/ break; case KeyPress: { char buffer[10]; int r, code; code = XLookupKeysym(&event.xkey, 0); if (code == XK_Left) { } else { r = XLookupString(&event.xkey, buffer, sizeof(buffer), NULL, NULL); keypress(dpy, win, buffer[0]); } } default: /* nothing */ ; } } }
int checkinput(void) { int buts; buts = getratinput(&rat); if(keypress()) return(Get_key()); return(buts); }
void *thread_keypress (void *p) { hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p; keypress (hashcat_ctx); return NULL; }
static int entry_keypress(LuaState *L) { Entry *e = ms_lua_checkclass(L, CLASS, 1); const char *key = luaL_checkstring(L, 2); gunichar uc = g_utf8_get_char(key); return keypress(e, uc); }
void MainWindow::connectSim(SimThread *sim) { QObject::connect(ui->startButton,SIGNAL(clicked()),sim,SLOT(simRun())); QObject::connect(ui->stopButton,SIGNAL(clicked()),sim,SLOT(simStop())); QObject::connect(ui->stepButton,SIGNAL(clicked()),sim,SLOT(simStep())); QObject::connect(ui->stepButton,SIGNAL(clicked()),this,SLOT(updateMemory())); QObject::connect(ui->setupButton,SIGNAL(clicked()),this,SLOT(doSetup())); QObject::connect(this,SIGNAL(kbdKeypress(quint8)),sim,SLOT(keypress(quint8))); }
/* * The main process thread runs this loop. * Single display connection for all threads. */ static void event_loop(Display *dpy) { XEvent event; int i; assert(!MultiDisplays); while (!ExitFlag) { if (Locking) { while (1) { int k; pthread_mutex_lock(&Mutex); k = XPending(dpy); if (k) { XNextEvent(dpy, &event); pthread_mutex_unlock(&Mutex); break; } pthread_mutex_unlock(&Mutex); usleep(5000); } } else { XNextEvent(dpy, &event); } switch (event.type) { case ConfigureNotify: /* Find winthread for this event's window */ for (i = 0; i < NumWinThreads; i++) { struct winthread *wt = &WinThreads[i]; if (event.xconfigure.window == wt->Win) { resize(wt, event.xconfigure.width, event.xconfigure.height); break; } } break; case KeyPress: for (i = 0; i < NumWinThreads; i++) { struct winthread *wt = &WinThreads[i]; if (event.xkey.window == wt->Win) { keypress(&event, wt); break; } } break; default: /*no-op*/ ; } } }
/** * Raw key grabber. * poll_keyboard() is the raw key grabber (above the gfx driver, that is). * It handles console keys and insulates AGI from the console. In the main * loop, handle_keys() handles keyboard input and ego movement. */ int do_poll_keyboard () { int key = 0; /* If a key is ready, rip it */ if (keypress ()) { key = get_key (); _D ("key %02x pressed", key); } return key; }
static int processX(void) { XEvent event; if (XEventsQueued(xDisplay, QueuedAfterFlush) == 0) { return 0; } XNextEvent(xDisplay, &event); switch (event.type) { // the following event type is selected by KeyPressMask case KeyPress: keypress(&event); break; // the following event type is selected by ExposureMask case Expose: repaint(); break; // the following event types are selected by StructureNotifyMask case ConfigureNotify: windowWidth = event.xconfigure.width; windowHeight = event.xconfigure.height; glViewport(0, 0, windowWidth, windowHeight); break; case ReparentNotify: break; case DestroyNotify: exit(0); case CirculateNotify: case GravityNotify: case MapNotify: case UnmapNotify: // the following event types are always selected case MappingNotify: case ClientMessage: case SelectionClear: case SelectionNotify: case SelectionRequest: default: fprintf(stderr, "got event type %d\n", event.type); break; } return 1; }
static int picviewer_get_key () { int key; /* clear key queue */ while (keypress ()) { get_key (); } _D (_D_WARN "waiting..."); while (42) { poll_timer (); key = do_poll_keyboard (); if (key) break; } return key; }
int wait_any_key () { int key; /* clear key queue */ while (keypress ()) { get_key (); } _D (_D_WARN "waiting..."); while (42) { poll_timer (); /* msdos driver -> does nothing */ key = do_poll_keyboard (); if (!console_keyhandler (key) && key) break; console_cycle (); } return key; }
int main(int argc, char* argv[]) { argv0 = argv[0]; /* Open a connection to the X server. */ dpy = XOpenDisplay(""); if (dpy == 0) { panic("can't open display."); } /* Set up signal handlers. */ #if 0 signal(SIGTERM, SIG_IGN); signal(SIGINT, SIG_IGN); #endif signal(SIGHUP, SIG_IGN); signal(SIGCHLD, sigchld_handler); screen_count = ScreenCount(dpy); if (argc != 2) { panic("syntax: speckeysd <keys file>"); } read_hot_key_file(argv[1]); /* Make sure all our communication to the server got through. */ XSync(dpy, False); /* The main event loop. */ for (;;) { XEvent ev; XNextEvent(dpy, &ev); switch (ev.type) { case KeyPress: keypress(&ev); break; case MappingNotify: XRefreshKeyboardMapping((XMappingEvent*) &ev); break; default: /* Do I look like I care? */ break; } } }
// w= 119 a= 97 s= 115 d= 100 int main() { int exit = 0; int kp = 0; do { kp = _kbhit(); if ( kp == 1) keypress(&exit, &kp); if (kp == 119 && pl1.paddle > 1) pl1.paddle--; if (kp == 115 && pl1.paddle < 18) pl1.paddle++; if (ball.y < 1 || ball.y > 18) rev(&ball.dy); if (ball.x < 3 || ball.x > 58) rev(&ball.dx); if (ball.x < 3 && (pos(pl1.paddle - ball.y) > 2)) pl2.pts++; if (ball.dx == 1) ball.x++; else ball.x--; if (ball.dy == 1) ball.y++; else ball.y--; std::cout << "--------------------------------------------------------------" << std::endl; for (int i = 0; i < 20; i++) { std::cout << "|"; for (int j = 0; j < 60; j++) { if ((pos(pl1.paddle-i) <= 1) && (j == 1) && (1 <= i <= 14)) std::cout << ">"; else if ((ball.x == j) && (ball.y == i)) std::cout << "*"; else std::cout << " "; } std::cout << "|" << std::endl; } std::cout << "--------------------------------------------------------------" << std::endl; std::cout << " Player 1 " << pl1.pts << " : " << pl2.pts << " Player 2 " << std::endl; Sleep(50); system("cls"); kp = 0; } while (exit != 1); return 0; }
/** Event handle function: execute every function * handle by event * \param ev Event */ void getevent(XEvent ev) { switch(ev.type) { case ButtonPress: buttonpress(&ev.xbutton); break; case ClientMessage: clientmessageevent(&ev.xclient); break; case ConfigureRequest: configureevent(&ev.xconfigurerequest); break; case DestroyNotify: destroynotify(&ev.xdestroywindow); break; case EnterNotify: enternotify(&ev.xcrossing); break; case Expose: expose(&ev.xexpose); break; case FocusIn: focusin(&ev.xfocus); break; case KeyPress: keypress(&ev.xkey); break; case MapNotify: mapnotify(&ev.xmap); break; case MapRequest: maprequest(&ev.xmaprequest); break; case MappingNotify: mappingnotify(&ev.xmapping); break; case MotionNotify: motionnotify(&ev.xmotion); break; case PropertyNotify: propertynotify(&ev.xproperty); break; case ReparentNotify: reparentnotify(&ev.xreparent); break; case SelectionClear: selectionclearevent(&ev.xselectionclear); break; case UnmapNotify: unmapnotify(&ev.xunmap); break; default: #ifdef HAVE_XRANDR /* Check Xrandr event */ if(ev.type == xrandr_event) { /* Update xrandr configuration */ XRRUpdateConfiguration(&ev); /* Reload WMFS to update the screen(s) geometry changement */ quit(); for(; argv_global[0] && argv_global[0] == ' '; ++argv_global); execvp(argv_global, all_argv); } #endif /* HAVE_XRANDR */ break; } return; }
void putlogo(void) { int color,go=1; int x,y,count; FILE *fp; char name[] = "logo2.pic"; if(!(fp=fopen(name,"rb"))) { cprintf("\nCannot open file."); } else { fread(&color,sizeof(int),1,fp); fread(&count,sizeof(int),1,fp); for(y=0;y<=480;y++) { if(keypress()) go=0; if(go) { for(x=0;x<=640;x++) { if(count) { if(color) putpixel(x,y,color); count--; } else { fread(&color,sizeof(int),1,fp); fread(&count,sizeof(int),1,fp); if(color) putpixel(x,y,color); count--; } } } } fclose(fp); } if(go) sleep(2); removelogo(); }
int input_event( const input_event_t *event ) { switch( event->type ) { case INPUT_EVENT_KEYPRESS: return keypress( &( event->types.key ) ); case INPUT_EVENT_KEYRELEASE: return keyrelease( &( event->types.key ) ); case INPUT_EVENT_JOYSTICK_PRESS: return do_joystick( &( event->types.joystick ), 1 ); case INPUT_EVENT_JOYSTICK_RELEASE: return do_joystick( &( event->types.joystick ), 0 ); } ui_error( UI_ERROR_ERROR, "unknown input event type %d", event->type ); return 1; }
void run(void) { XEvent ev; while(!XNextEvent(dc->dpy, &ev)) switch(ev.type) { case Expose: if(ev.xexpose.count == 0) drawmenu(); break; case KeyPress: keypress(&ev.xkey); break; case SelectionNotify: if(ev.xselection.property == utf8) paste(); break; case VisibilityNotify: if(ev.xvisibility.state != VisibilityUnobscured) XRaiseWindow(dc->dpy, win); break; } }
int wait_key () { int key; /* clear key queue */ while (keypress ()) { get_key (); } _D (_D_WARN "waiting..."); while (42) { poll_timer (); /* msdos driver -> does nothing */ key = do_poll_keyboard (); if (!console_keyhandler (key)) { if (key == KEY_ENTER || key == KEY_ESCAPE #ifdef USE_MOUSE || key == BUTTON_LEFT #endif ) break; } console_cycle (); } return key; }
void StdioConsole::run() { int ret; int c; struct termios termios0; struct termios termios; fprintf(stdout, "Press ESC to quit.\n"); fflush(stdout); setbuf(stdin, NULL); ret = tcgetattr(0, &termios); if (ret == 0) { memcpy(&termios0, &termios, sizeof(termios0)); termios.c_lflag &= ~ICANON; termios.c_lflag &= ~ECHO; ret = tcsetattr(0, 0, &termios); } while ((c = fgetc(stdin)) != EOF) { if (c == 0x1b) { break; } keypress(c); } if (ret == 0) { tcsetattr(0, 0, &termios0); } }
prompt_for_more(char *descr) { int key; printf( "-- %s (EOF) --", descr); key = keypress(); printf("\n"); /* Do we quit or move to next file? */ switch (key) { case CTRL_C: printf( "^C"); case 'q': case 'Q': return (0); case 'n': case 'N': return (1); } /* switch */ return 1; /* next file !! */ }
void input_key_special(int key, int x, int y) { if (key == GLUT_KEY_LEFT) { keypress(usekeys[5]); } if (key == GLUT_KEY_RIGHT) { keypress(usekeys[6]); } if (key == GLUT_KEY_UP) { keypress(usekeys[7]); } if (key == GLUT_KEY_DOWN) { keypress(usekeys[8]); } if (key == GLUT_KEY_F2) { keypress(101); //show low bat warning } if (key == GLUT_KEY_F3) { keypress(102); //disable low bat warning } }
void QIMPenInput::enter() { keypress( Qt::Key_Return << 16 ); matcher->resetState(); }