int keys2codes(unsigned int *klist, int klist_size, char *keystroke) { int i, j; unsigned int k, *kk=klist; char *kc = keystroke; if (! keymap['1']) keymap_init(); *kk = 0; *(kk+1) = 0; for (i=0, j=0; *kc; i++, kc++) { k = keymap[(int) *kc]; *kk |= (k << (24 - (i - j*N_KEY_IN_CODE) * 6)); if (i % N_KEY_IN_CODE == N_KEY_IN_CODE-1) { if (++j >= klist_size) break; kk++; *kk = 0; } } return j; }
void test1() { struct aug_keymap map; keymap_init(&map); aug_on_key_fn on_key; void *user; diag("++++test1++++"); diag("test basic functionality/sanity"); keymap_bind(&map, test1chr, test1_cb1, test1user); on_key = NULL; user = NULL; keymap_binding(&map, test1chr, &on_key, &user); ok1(on_key != NULL); ok1(user != NULL); (*on_key)(test1chr, user); ok1(keymap_size(&map) == 1); #define TEST1AMT 2 + 2 + 1 diag("----test1----\n#"); keymap_free(&map); }
int oxim_key2code(int key) { if (! keymap_normal['1']) keymap_init(); return (key < 128) ? keymap_normal[key] : 0; }
static void start_curses(void) { keymap_init(); mutt_signal_init(); if (initscr() == NULL) { puts ("Error initializing terminal."); exit(RETURN_ERR_TERM); } ci_start_color(); keypad(stdscr, TRUE); cbreak(); noecho(); typeahead(-1); /* simulate smooth scrolling */ meta(stdscr, TRUE); init_extended_keys(); }
void ps2_main(void){ m_state = STA_WAIT_RESET; kbd_init(); keymap_init(); clear(); //set key repeat speed; uint8_t gSpeed = eeprom_read_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED); if(gSpeed == 0xFF) gSpeed = 1; if(ps2_repeat_speed == PS2_REPEAT_SPEED_NONE){ ps2_repeat_speed = gSpeed; }else if(ps2_repeat_speed != gSpeed){ eeprom_write_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED, ps2_repeat_speed); } // init setKeyScanDriver(&driverKeyScanPs2); setUpdateDriver(&updatePs2); clearMatrix(); // DEBUG_PRINT(("STARTING PS/2 KEYBOARD\n")); sei(); // DBG1(0x90, 0, 0); for(;;){ // 카운트 이내에 신호가 잡히지 않으면 이동; // 특별한 경우에만 발생하는 현상이다. if(INTERFACE == INTERFACE_PS2 && interfaceReady == false && interfaceCount++ > 1000){ // move to usb INTERFACE = INTERFACE_USB; DBG1(0x99, 0, 0); break; } processRxPs2(); processTxPs2(); } // DBG1(0x9F, 0, 0); }
void test2() { struct aug_keymap map; aug_on_key_fn on_key; void *user; keymap_init(&map); diag("++++test2++++"); diag("binding an already bound key: should overwrite."); diag("bind key to first function..."); keymap_bind(&map, test2chr1, test2_cb1, test2user1); on_key = NULL; user = NULL; keymap_binding(&map, test2chr1, &on_key, &user); ok1(on_key != NULL); ok1(user != NULL); (*on_key)(test2chr1, user); ok1(keymap_size(&map) == 1); diag("bind key to a different function..."); keymap_bind(&map, test2chr1, test2_cb2, test2user2); ok1(keymap_size(&map) == 1); diag("do we get the new function or old?"); on_key = NULL; user = NULL; keymap_binding(&map, test2chr1, &on_key, &user); ok1(on_key != NULL); ok1(user != NULL); ok1(on_key == test2_cb2); (*on_key)(test2chr1, user); #define TEST2AMT 2 + 2 + 1 + 1 + 2 + 1 + 2 diag("----test2----\n#"); keymap_free(&map); }
void test3() { struct aug_keymap map; keymap_init(&map); aug_on_key_fn on_key; void *user; diag("++++test3++++"); diag("does unbind work?"); keymap_bind(&map, test3chr, test3_cb1, test3user); on_key = NULL; user = NULL; keymap_binding(&map, test3chr, &on_key, &user); ok1(on_key != NULL); ok1(user != NULL); (*on_key)(test3chr, user); ok1(keymap_size(&map) == 1); diag("unbind an non-existent key"); ok1(keymap_unbind(&map, '4') != 0); ok1(keymap_size(&map) == 1); diag("unbind the actual key"); ok1(keymap_unbind(&map, test3chr) == 0); ok1(keymap_size(&map) == 0); diag("asking for the binding just returns null values"); on_key = NULL; user = NULL; keymap_binding(&map, test3chr, &on_key, &user); ok1(on_key == NULL); ok1(user == NULL); #define TEST3AMT 2 + 2 + 1 + 2 + 2 + 2 diag("----test3----\n#"); keymap_free(&map); }
int main(int argc, char *argv[]) { gboolean root_override=FALSE, open_in_new_window = FALSE; GList *filenames = NULL, *projectfiles=NULL; gint linenumber = -1; Tbfwin *firstbfwin; #ifndef NOSPLASH GtkWidget *splash_window; #endif /* #ifndef NOSPLASH */ #ifdef ENABLE_NLS setlocale(LC_ALL,""); bindtextdomain(PACKAGE,LOCALEDIR); DEBUG_MSG("set bindtextdomain for %s to %s\n",PACKAGE,LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #ifdef HAVE_ATLEAST_GNOMEUI_2_6 gnome_init(PACKAGE, VERSION, argc, argv); #else gtk_init(&argc, &argv); #endif /* HAVE_ATLEAST_GNOMEUI_2_6 */ main_v = g_new0(Tmain, 1); main_v->session = g_new0(Tsessionvars,1); DEBUG_MSG("main, main_v is at %p\n", main_v); rcfile_check_directory(); rcfile_parse_main(); parse_commandline(argc, argv, &root_override, &filenames, &projectfiles, &open_in_new_window, &linenumber); #ifdef WITH_MSG_QUEUE if (((filenames || projectfiles) && (main_v->props.view_bars & MODE_REUSE_WINDOW)) || open_in_new_window) { msg_queue_start(filenames, projectfiles, linenumber, open_in_new_window); } #endif /* WITH_MSG_QUEUE */ #ifndef NOSPLASH /* start splash screen somewhere here */ splash_window = start_splash_screen(); splash_screen_set_label(_("parsing highlighting file...")); #endif /* #ifndef NOSPLASH */ { gchar *filename = g_strconcat(g_get_home_dir(), "/.winefish/dir_history", NULL); main_v->recent_directories = get_stringlist(filename, NULL); g_free(filename); } rcfile_parse_global_session(); rcfile_parse_highlighting(); #ifndef NOSPLASH splash_screen_set_label(_("compiling highlighting patterns...")); #endif /* #ifndef NOSPLASH */ hl_init(); #ifndef NOSPLASH splash_screen_set_label(_("initialize some other things...")); #endif /* #ifndef NOSPLASH */ filebrowserconfig_init(); filebrowser_filters_rebuild(); autoclosing_init(); #ifndef NOSPLASH splash_screen_set_label(_("parsing autotext and words file...")); #endif /* #ifndef NOSPLASH */ autotext_init(); completion_init(); #ifndef NOSPLASH splash_screen_set_label(_("parsing custom menu file...")); #endif /* #ifndef NOSPLASH */ rcfile_parse_custom_menu(FALSE,FALSE); #ifdef SNOOPER2 #ifndef NOSPLASH splash_screen_set_label(_("parsing keymap and initializing function list...")); #endif /* #ifndef NOSPLASH */ funclist_init(); keymap_init(); #endif /* SNOOPER2 */ main_v->tooltips = gtk_tooltips_new(); /* initialize the completion window */ /* main_v->completion.window = NULL; */ fref_init(); bmark_init(); #ifdef WITH_MSG_QUEUE if (!filenames && !projectfiles && (main_v->props.view_bars & MODE_REUSE_WINDOW)) { msg_queue_start(NULL, NULL, -1, open_in_new_window); } #endif /* WITH_MSG_QUEUE */ #ifndef NOSPLASH splash_screen_set_label(_("creating main gui...")); #endif /* #ifndef NOSPLASH */ /* create the first window */ firstbfwin = g_new0(Tbfwin,1); firstbfwin->session = main_v->session; firstbfwin->bookmarkstore = main_v->bookmarkstore; main_v->bfwinlist = g_list_append(NULL, firstbfwin); gui_create_main(firstbfwin, filenames, linenumber); bmark_reload(firstbfwin); #ifndef NOSPLASH splash_screen_set_label(_("showing main gui...")); #endif /* #ifndef NOSPLASH */ /* set GTK settings, must be AFTER the menu is created */ { gchar *shortcutfilename; GtkSettings* gtksettings = gtk_settings_get_default(); g_object_set(G_OBJECT(gtksettings), "gtk-can-change-accels", TRUE, NULL); shortcutfilename = g_strconcat(g_get_home_dir(), "/.winefish/menudump_2", NULL); gtk_accel_map_load(shortcutfilename); g_free(shortcutfilename); } gui_show_main(firstbfwin); /* if (main_v->props.view_html_toolbar && main_v->globses.quickbar_items == NULL) { info_dialog(firstbfwin->main_window, _("Winefish tip:"), _("This message is shown since you DONOT have any items in the QuickBar.\n\nIf you right-click a button in the Standard toolbars you can add buttons to the Quickbar.")); } */ if (projectfiles) { GList *tmplist = g_list_first(projectfiles); while (tmplist) { project_open_from_file(firstbfwin, tmplist->data, linenumber); tmplist = g_list_next(tmplist); } } #ifndef NOSPLASH DEBUG_MSG("destroy splash\n"); flush_queue(); { static struct timespec const req = { 0, 10000000}; nanosleep(&req, NULL); } gtk_widget_destroy(splash_window); #endif /* #ifndef NOSPLASH */ /* snooper must be installed after the main gui has shown; otherwise the program may be aborted */ #ifndef SNOOPER2 snooper_install(); #endif /* SNOOPER2 */ DEBUG_MSG("main, before gtk_main()\n"); gtk_main(); DEBUG_MSG("main, after gtk_main()\n"); #ifdef WITH_MSG_QUEUE /* do the cleanup */ msg_queue_cleanup(); #endif /* WITH_MSG_QUEUE */ DEBUG_MSG("Winefish: exiting cleanly\n"); return 0; }