int server(int args) { if (args < 0) return (0); my_put_nbr((int)getpid()); if (write(1, "\n", 1) < 0) return (1); set_infos(); while (1) { if (g_infos.id == 0) { if (get_c_pid()) return (1); if (g_infos.pid != 0) { if (signal(SIGUSR1, &sig_1) == SIG_ERR || signal(SIGUSR2, &sig_2) == SIG_ERR) return (1); } } if (usleep(100000) == 0) set_infos(); } return (0); }
int hid_switch_without_skin(void) { options.skin = 0; set_infos(); redraw_skin(); return 0; }
int hid_init(void) { // Found a PC keyboard keymap match_keymap(tihw.calc_type); // Load kbd keymap if(keymap_load(options.keys_file) == -1) { gchar *s = g_strdup_printf("unable to load this keymap: <%s>\n", options.keys_file); tiemu_error(0, s); g_free(s); return -1; } // Found a skin match_skin(tihw.calc_type); // Load skin (2 parts) if(skin_load(&skin_infos, options.skin_file) == -1) { gchar *s = g_strdup_printf("unable to load this skin: <%s>\n", options.skin_file); tiemu_error(0, s); g_free(s); return -1; } // Allocate the skn pixbuf (if needed) skn = skin_infos.image; // Set skin keymap depending on calculator type switch(tihw.calc_type) { case TI92: case TI92p: case V200: skn_keymap = sknKey92; break; case TI89: case TI89t: skn_keymap = sknKey89; break; default: { gchar *s = g_strdup_printf("no skin found for this calc\n"); tiemu_error(0, s); g_free(s); return -1; } } // Set window/LCD sizes set_scale(options.view); set_infos(); // Allocate the TI screen buffer lcd_bytmap = (uint32_t *)malloc(LCDMEM_W * LCDMEM_H); // Allocate the lcd pixbuf lcd = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, si.t * LCDMEM_W, si.t * LCDMEM_H); if(lcd == NULL) { gchar *s = g_strdup_printf("unable to create LCD pixbuf.\n"); tiemu_error(0, s); g_free(s); return -1; } // Used by TI89 (the LCD view is clipped from memory view) si.l = gdk_pixbuf_new_subpixbuf(lcd, 0, 0, tihw.lcd_w, tihw.lcd_h); // Constants for LCD update (speed-up) li.n_channels = gdk_pixbuf_get_n_channels (lcd); li.width = gdk_pixbuf_get_width (lcd); li.height = gdk_pixbuf_get_height (lcd); li.rowstride = gdk_pixbuf_get_rowstride (lcd); li.pixels = gdk_pixbuf_get_pixels (lcd); // Create main window display_main_wnd(); // Allocate the backing pixmap (used for drawing and refresh) pixmap = gdk_pixmap_new(main_wnd->window, wr.w, wr.h, -1); if(pixmap == NULL) { gchar *s = g_strdup_printf("unable to create backing pixbuf.\n"); tiemu_error(0, s); g_free(s); return -1; } // Draw the skin and compute grayscale palette redraw_skin(); compute_grayscale(); // Init the planar/chunky conversion table for LCD compute_convtable(); // Install LCD refresh: 100 FPS (10 ms) tid = g_timeout_add((params.lcd_rate == -1) ? 50 : params.lcd_rate, (GtkFunction)hid_refresh, NULL); gtk_widget_show(main_wnd); // show wnd here if(options.view == VIEW_FULL) gdk_window_fullscreen(main_wnd->window); return 0; }