예제 #1
0
파일: dualview.c 프로젝트: marrusian/C
int main(void)
{
   Views box = {{true, YELLOW, true, GREEN, DASHED}};
   char bin_str[CHAR_BIT*sizeof(unsigned int)+1];

   puts("Original box settings");
   show_settings(&box.st_view);

   puts("\nBox settings using unsigned int view:");
   show_settings1(box.us_view);
   printf("bits are %s\n", itobs(box.us_view, bin_str));

   box.us_view &= ~FILL_MASK;  // Clear fill bits
   box.us_view |= (FILL_BLUE|FILL_GREEN);
   box.us_view ^= OPAQUE;      // Toogle opacity
   box.us_view |= BORDER_RED;  // wrong approach
   box.us_view &= ~STYLE_MASK; // Clear style bits
   box.us_view |= B_DOTTED;    

   puts("\nModified box settings:");
   show_settings(&box.st_view);
   puts("\nBox settings using unsigned int view");
   show_settings1(box.us_view);
   printf("bits are %s\n", itobs(box.us_view, bin_str));

   return 0;
}
예제 #2
0
파일: fields.c 프로젝트: kyrylo/cprimer
int main(void)
{
	struct box_props box = {YES, YELLOW, YES, GREEN, DASHED};

	printf("Original box settings:\n");
	show_settings(&box);

	box.opaque = NO;
	box.border_color = MAGENTA;
	box.border_style = SOLID;
	printf("\nModified box settings:\n");
	show_settings(&box);

	return 0;
}
예제 #3
0
static void
do_next_command(char *input) {
	char *ptr, *arg;

	ptr = next_token(&input, " \t\r\n");
	if (ptr == NULL)
		return;
	arg = next_token(&input, " \t\r\n");
	if ((strcasecmp(ptr, "set") == 0) &&
	    (arg != NULL))
		setoption(arg);
	else if ((strcasecmp(ptr, "server") == 0) ||
		 (strcasecmp(ptr, "lserver") == 0)) {
		isc_app_block();
		set_nameserver(arg);
		check_ra = ISC_FALSE;
		isc_app_unblock();
		show_settings(ISC_TRUE, ISC_TRUE);
	} else if (strcasecmp(ptr, "exit") == 0) {
		in_use = ISC_FALSE;
	} else if (strcasecmp(ptr, "help") == 0 ||
		   strcasecmp(ptr, "?") == 0) {
		printf("The '%s' command is not yet implemented.\n", ptr);
	} else if (strcasecmp(ptr, "finger") == 0 ||
		   strcasecmp(ptr, "root") == 0 ||
		   strcasecmp(ptr, "ls") == 0 ||
		   strcasecmp(ptr, "view") == 0) {
		printf("The '%s' command is not implemented.\n", ptr);
	} else
		addlookup(ptr);
}
예제 #4
0
파일: fields.c 프로젝트: gentio/train
int main(void)
{
    /* create and initialize box_props structure */
    struct box_props box = {YES, YELLOW , YES, GREEN, DASHED};

    printf("Original box settings:\n");
    show_settings(&box);

    box.opaque = NO;
    box.fill_color = WHITE;
    box.border_color = MAGENTA;
    box.border_style = SOLID;
    printf("\nModified box settings:\n");
    show_settings(&box);

    return 0;
}
예제 #5
0
파일: CLI.cpp 프로젝트: Tiasa/chess-at-nite
void CLI::read_settings() {
    int user_option = -1;
    while (user_option != QUIT) {
        show_settings();
        user_option = get_user_option();
        apply_settings(user_option);
    }
}
예제 #6
0
파일: nslookup.c 프로젝트: 274914765/C
static void get_next_command (void)
{
    char *buf;

    char *ptr, *arg;

    char *input;

    fflush (stdout);
    buf = isc_mem_allocate (mctx, COMMSIZE);
    if (buf == NULL)
        fatal ("memory allocation failure");
    fputs ("> ", stderr);
    fflush (stderr);
    isc_app_block ();
    ptr = fgets (buf, COMMSIZE, stdin);
    isc_app_unblock ();
    if (ptr == NULL)
    {
        in_use = ISC_FALSE;
        goto cleanup;
    }
    input = buf;
    ptr = next_token (&input, " \t\r\n");
    if (ptr == NULL)
        goto cleanup;
    arg = next_token (&input, " \t\r\n");
    if ((strcasecmp (ptr, "set") == 0) && (arg != NULL))
        setoption (arg);
    else if ((strcasecmp (ptr, "server") == 0) || (strcasecmp (ptr, "lserver") == 0))
    {
        isc_app_block ();
        set_nameserver (arg);
        check_ra = ISC_FALSE;
        isc_app_unblock ();
        show_settings (ISC_TRUE, ISC_TRUE);
    }
    else if (strcasecmp (ptr, "exit") == 0)
    {
        in_use = ISC_FALSE;
        goto cleanup;
    }
    else if (strcasecmp (ptr, "help") == 0 || strcasecmp (ptr, "?") == 0)
    {
        printf ("The '%s' command is not yet implemented.\n", ptr);
        goto cleanup;
    }
    else if (strcasecmp (ptr, "finger") == 0 ||
             strcasecmp (ptr, "root") == 0 || strcasecmp (ptr, "ls") == 0 || strcasecmp (ptr, "view") == 0)
    {
        printf ("The '%s' command is not implemented.\n", ptr);
        goto cleanup;
    }
    else
        addlookup (ptr);
  cleanup:
    isc_mem_free (mctx, buf);
}
예제 #7
0
 static void unraise_loadMenu_guichan()
 {
   window_load->releaseModalFocus();
   window_load->setVisible(false);
   if(activateAfterClose != NULL)
     activateAfterClose->requestFocus();
   activateAfterClose = NULL;  
   show_settings();
 }
예제 #8
0
파일: testadmin.c 프로젝트: AndychenCL/cups
int					/* O - Exit status */
main(int  argc,				/* I - Number of command-line args */
     char *argv[])			/* I - Command-line arguments */
{
  int		i,			/* Looping var */
		num_settings;		/* Number of settings */
  cups_option_t	*settings;		/* Settings */
  http_t	*http;			/* Connection to server */


 /*
  * Connect to the server using the defaults...
  */

  http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
                      cupsEncryption(), 1, 30000, NULL);

 /*
  * Set the current configuration if we have anything on the command-line...
  */

  if (argc > 1)
  {
    for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++)
      num_settings = cupsParseOptions(argv[i], num_settings, &settings);

    if (cupsAdminSetServerSettings(http, num_settings, settings))
    {
      puts("New server settings:");
      cupsFreeOptions(num_settings, settings);
    }
    else
    {
      printf("Server settings not changed: %s\n", cupsLastErrorString());
      return (1);
    }
  }
  else
    puts("Current server settings:");

 /*
  * Get the current configuration...
  */

  if (cupsAdminGetServerSettings(http, &num_settings, &settings))
  {
    show_settings(num_settings, settings);
    cupsFreeOptions(num_settings, settings);
    return (0);
  }
  else
  {
    printf("    %s\n", cupsLastErrorString());
    return (1);
  }
}
예제 #9
0
void load_settings()
{
#ifdef FLASHBOOT
#else
	char buff[BUFFSIZE];
	FILE *in;
	puts("----- Reading settings... -----");
	in = fopen(settingsfile, "r");
	if (!in) {
		fprintf(stderr, "Can't open %s\n", settingsfile);
		exit(1);
	}
	/* CURRENT_OUT_FACTOR usually 1*/
	fgets(buff, BUFFSIZE, in);
	CURRENT_OUT_FACTOR = atof(buff);

	/* PARTICLES_OUT_FACTOR */
	fgets(buff, BUFFSIZE, in);
	PARTICLES_OUT_FACTOR = atof(buff);

	/* Timming 1*/
	fgets(buff, BUFFSIZE, in);
	T1 = atof(buff);
	
	/* Timming 2 */
	fgets(buff, BUFFSIZE, in);
	T2 = atof(buff);

	/* CURRENT_FACTOR */
	fgets(buff, BUFFSIZE, in);
	CURRENT_FACTOR = atof(buff);

	/* CHARGE_FACTOR */
	fgets(buff, BUFFSIZE, in);
	CHARGE_FACTOR = atof(buff);

	/* CHARGE */
	fgets(buff, BUFFSIZE, in);
	CHARGE = atoi(buff);

	/* HARMONICS */
	fgets(buff, BUFFSIZE, in);
	HARMONICS = atoi(buff);

	/* filename */
	fgets(buff, BUFFSIZE, in);
	printf("%s", buff);

	fclose(in);
	show_settings();
#endif
	N1 = T1*SAMPLE_FREQ/1000;
	N2 = T2*SAMPLE_FREQ/1000;

}
예제 #10
0
int main(void) {
    /* create Views object, initialize struct box view */
    union Views box = {{YES, YELLOW , YES, GREEN, DASHED}};
    char bin_str[8 * sizeof(unsigned int) + 1];
    printf("Original box settings:\n");
    show_settings(&box.st_view);
    printf("\nBox settings using unsigned int view:\n");
    show_settings1(box.ui_view);
    printf("bits are %s\n",
           itobs(box.ui_view, bin_str));
    box.ui_view &= ~FILL_MASK;          /* clear fill bits */
    box.ui_view |= (FILL_BLUE | FILL_GREEN); /* reset fill */
    box.ui_view ^= OPAQUE;               /* toggle opacity */
    box.ui_view |= BORDER_RED;           /* wrong approach */
    box.ui_view &= ~STYLE_MASK;        /* clear style bits */
    box.ui_view |= B_DOTTED;         /* set style to dotted*/
    printf("\nModified box settings:\n");
    show_settings(&box.st_view);
    printf("\nBox settings using unsigned int view:\n");
    show_settings1(box.ui_view);
    printf("bits are %s\n",
           itobs(box.ui_view, bin_str));
    return 0;
}
예제 #11
0
void 
astrometryC(FL_OBJECT *obj, long val) 

{
  int m;
  int x, y, z;

  m = fl_get_menu(obj);
  switch (m) {
  case EDIT_PARAMETERS:
    edit_parameters(obj, m);
    break;
  case DETECT_STARS:
    detect_stars(frame, state.control[state.control_num]);
    break;
  case MATCH_STARS:
    match_stars(frame, state.control[state.control_num]);
    break;
  case SAVE_STAR_LIST:
    star_list(frame, state.control[state.control_num]);
    break;
  case LOAD_STAR_LIST:
    load_star_list(frame, state.control[state.control_num]);
    break;
  case DO_ASTROMETRY:
    state.doastr = 1;
    fl_get_mouse(&x, &y, &z);
    fl_set_mouse(0, 0);
    fl_set_mouse(x, y);
    break;
  case OPTIONS:
    edit_options(obj, m);
    break;
  case CATALOGS:
    edit_catalogs(obj, m);
    break;
  case SAVE_SETTINGS:
    show_settings(obj, m);
    break;
  case SEND_MAIL:
    edit_mail(obj, m);
    break;
  case SHOW_REPORT:
    show_report();
    break;
  }
}
예제 #12
0
int sound_main(int argc, char **argv)
{
	if (!config.sound) {
		com_printf("Sound not enabled in config!\n");
		return 1;
	}

	if (argc == 1) {
		show_settings();
		return 0;
	}

	if (argv[1][0] == '/') {
		switch (toupper(argv[1][1])) {
		case 'E':
			blaster_setenv();
			break;
		case 'H':
		case '?':
			show_help(argv[0]);
			break;
		case 'S':
			if (argc < 3) {
				com_printf("/S requires parameter\n");
				return 1;
			}
			if (!midi_set_synth_type_from_string(argv[2])) {
				com_printf("%s mode unsupported\n", argv[2]);
				break;
			}
			break;
		default:
			com_printf("Unknown option %s\n", argv[1]);
			return 1;
		}
	}

	return 0;
}
예제 #13
0
파일: main.c 프로젝트: KirovAir/swiss-gc
void main_loop()
{ 	
	while(PAD_ButtonsHeld(0) & PAD_BUTTON_A) { VIDEO_WaitVSync (); }
	// We don't care if a subsequent device is "default"
	if(needsDeviceChange) {
		free_files();
		if(deviceHandler_deinit) {
			deviceHandler_deinit(deviceHandler_initial);
		}
		if (forceSlot) {
			deviceHandler_FAT_deinit(&initial_SD1);
		}
		curDevice = -1;
		needsDeviceChange = 0;
		deviceHandler_initial = NULL;
		needsRefresh = 1;
		curMenuLocation = ON_FILLIST;
		select_device(0);
		if (curDevice == WKF)  {
			trySlotB();
		}
		curMenuLocation = ON_OPTIONS;
	}
	
	if(deviceHandler_initial) {
		// If the user selected a device, make sure it's ready before we browse the filesystem
		deviceHandler_deinit( deviceHandler_initial );
		sdgecko_setSpeed(EXI_SPEED32MHZ);
		if(!deviceHandler_init( deviceHandler_initial )) {
			if(((deviceHandler_initial->name[0] == 's')&&(deviceHandler_initial->name[1] == 'd'))||(deviceHandler_initial->name[0] == 'i')) {
				print_gecko("SD/IDE-EXI Device Failed to initialize @ 32MHz!\r\nTrying again once @ 16MHz...\r\n");
				sdgecko_setSpeed(EXI_SPEED16MHZ);
				if(!deviceHandler_init(deviceHandler_initial)) {
				// Try the alternate slot for SDGecko or IDE-EXI
					if(deviceHandler_initial->name[0] == 's')
						deviceHandler_initial = (deviceHandler_initial == &initial_SD0) ?
												&initial_SD1:&initial_SD0;
					else
						deviceHandler_initial = (deviceHandler_initial == &initial_IDE0) ?
												&initial_IDE1:&initial_IDE0;
					memcpy(&curFile, deviceHandler_initial, sizeof(file_handle));
				}
				print_gecko("Trying alternate slot @ 32MHz...\r\n");
				sdgecko_setSpeed(EXI_SPEED32MHZ);
				if(!deviceHandler_init( deviceHandler_initial )) {
					print_gecko("Alternate slot failed once @ 16MHz... \r\n");
					sdgecko_setSpeed(EXI_SPEED16MHZ);
					if(!deviceHandler_init( deviceHandler_initial )) {
						print_gecko("Both slots failed twice\r\n");
						needsDeviceChange = 1;
						return;
					}
				}
			}
		}
		if(curDevice==SD_CARD || curDevice==WKF || curDevice==IDEEXI) { 
			load_config(forceSlot);
		}
	}
	else {
		curMenuLocation=ON_OPTIONS;
	}
	// If a previously undetected device has been successfully init'd, mark it as available from now on
	if(!deviceHandler_getDeviceAvailable(curDevice)) {
		deviceHandler_setDeviceAvailable(curDevice, 1);
	}
  
	while(1) {
		if(deviceHandler_initial && needsRefresh) {
			curMenuLocation=ON_OPTIONS;
			free_files();
			curSelection=0; files=0; curMenuSelection=0;
			// Read the directory/device TOC
			if(allFiles){ free(allFiles); allFiles = NULL; }
			print_gecko("Reading directory: %s\r\n",curFile.name);
			files = deviceHandler_readDir(&curFile, &allFiles, -1);
			memcpy(&curDir, &curFile, sizeof(file_handle));
			sortFiles(allFiles, files);
			print_gecko("Found %i entries\r\n",files);
			if(files<1) { deviceHandler_deinit(deviceHandler_initial); needsDeviceChange=1; break;}
			needsRefresh = 0;
			curMenuLocation=ON_FILLIST;
		}
		while(PAD_ButtonsHeld(0) & PAD_BUTTON_A) { VIDEO_WaitVSync (); }
		drawFiles(&allFiles, files);

		u16 btns = PAD_ButtonsHeld(0);
		if(curMenuLocation==ON_OPTIONS) {
			if(btns & PAD_BUTTON_LEFT){	curMenuSelection = (--curMenuSelection < 0) ? (MENU_MAX-1) : curMenuSelection;}
			else if(btns & PAD_BUTTON_RIGHT){curMenuSelection = (curMenuSelection + 1) % MENU_MAX;	}
		}
		if(deviceHandler_initial && ((btns & PAD_BUTTON_B)||(curMenuLocation==ON_FILLIST)))	{
			while(PAD_ButtonsHeld(0) & PAD_BUTTON_B){ VIDEO_WaitVSync (); }
			curMenuLocation=ON_FILLIST;
			renderFileBrowser(&allFiles, files);
		}
		else if(btns & PAD_BUTTON_A) {
			//handle menu event
			switch(curMenuSelection) {
				case 0:		// Device change
					needsDeviceChange = 1;  //Change from SD->DVD or vice versa
					break;
				case 1:		// Settings
					show_settings(NULL, NULL);
					break;
				case 2:		// Credits
					show_info();
					break;
				case 3:
					if(deviceHandler_initial) {
						memcpy(&curFile, deviceHandler_initial, sizeof(file_handle));
						if(curDevice == WKF) { 
							wkfReinit(); deviceHandler_deinit(deviceHandler_initial);
						}
					}
					needsRefresh=1;
					break;
				case 4:
					__libogc_exit(0);
					break;
			}
			
		}
		while (!(!(PAD_ButtonsHeld(0) & PAD_BUTTON_B) && !(PAD_ButtonsHeld(0) & PAD_BUTTON_A) && !(PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT) && !(PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT))) {
			VIDEO_WaitVSync();
		}
		if(needsDeviceChange) {
			break;
		}
	}
}
예제 #14
0
/**
 * OpenVPN's main init-run-cleanup loop.
 * @ingroup eventloop
 * 
 * This function contains the two outer OpenVPN loops.  Its structure is
 * as follows:
 *  - Once-per-process initialization.
 *  - Outer loop, run at startup and then once per \c SIGHUP:
 *    - Level 1 initialization
 *    - Inner loop, run at startup and then once per \c SIGUSR1:
 *      - Call event loop function depending on client or server mode:
 *        - \c tunnel_point_to_point()
 *        - \c tunnel_server()
 *    - Level 1 cleanup
 *  - Once-per-process cleanup.
 * 
 * @param argc - Commandline argument count.
 * @param argv - Commandline argument values.
 */
int
main (int argc, char *argv[])
{
  struct context c;

#if PEDANTIC
  fprintf (stderr, "Sorry, I was built with --enable-pedantic and I am incapable of doing any real work!\n");
  return 1;
#endif

  CLEAR (c);

  /* signify first time for components which can
     only be initialized once per program instantiation. */
  c.first_time = true;

  /* initialize program-wide statics */
  if (init_static ())
    {
      /*
       * This loop is initially executed on startup and then
       * once per SIGHUP.
       */
      do
	{
	  /* enter pre-initialization mode with regard to signal handling */
	  pre_init_signal_catch ();

	  /* zero context struct but leave first_time member alone */
	  context_clear_all_except_first_time (&c);

	  /* static signal info object */
	  CLEAR (siginfo_static);
	  c.sig = &siginfo_static;

	  /* initialize garbage collector scoped to context object */
	  gc_init (&c.gc);

	  /* initialize environmental variable store */
	  c.es = env_set_create (NULL);
#ifdef WIN32
	  env_set_add_win32 (c.es);
#endif

#ifdef ENABLE_MANAGEMENT
	  /* initialize management subsystem */
	  init_management (&c);
#endif

	  /* initialize options to default state */
	  init_options (&c.options, true);

	  /* parse command line options, and read configuration file */
	  parse_argv (&c.options, argc, argv, M_USAGE, OPT_P_DEFAULT, NULL, c.es);

#ifdef ENABLE_PLUGIN
	  /* plugins may contribute options configuration */
	  init_verb_mute (&c, IVM_LEVEL_1);
	  init_plugins (&c);
	  open_plugins (&c, true, OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE);
#endif

	  /* init verbosity and mute levels */
	  init_verb_mute (&c, IVM_LEVEL_1);

	  /* set dev options */
	  init_options_dev (&c.options);

	  /* openssl print info? */
	  if (print_openssl_info (&c.options))
	    break;

	  /* --genkey mode? */
	  if (do_genkey (&c.options))
	    break;

	  /* tun/tap persist command? */
	  if (do_persist_tuntap (&c.options))
	    break;

	  /* sanity check on options */
	  options_postprocess (&c.options);

	  /* show all option settings */
	  show_settings (&c.options);

	  /* print version number */
	  msg (M_INFO, "%s", title_string);

	  /* misc stuff */
	  pre_setup (&c.options);

	  /* test crypto? */
	  if (do_test_crypto (&c.options))
	    break;
	  
#ifdef ENABLE_MANAGEMENT
	  /* open management subsystem */
	  if (!open_management (&c))
	    break;
#endif

	  /* set certain options as environmental variables */
	  setenv_settings (c.es, &c.options);

	  /* finish context init */
	  context_init_1 (&c);

	  do
	    {
	      /* run tunnel depending on mode */
	      switch (c.options.mode)
		{
		case MODE_POINT_TO_POINT:
		  tunnel_point_to_point (&c);
		  break;
#if P2MP_SERVER
		case MODE_SERVER:
		  tunnel_server (&c);
		  break;
#endif
		default:
		  ASSERT (0);
		}

	      /* indicates first iteration -- has program-wide scope */
	      c.first_time = false;

	      /* any signals received? */
	      if (IS_SIG (&c))
		print_signal (c.sig, NULL, M_INFO);

	      /* pass restart status to management subsystem */
	      signal_restart_status (c.sig);
	    }
	  while (c.sig->signal_received == SIGUSR1);

	  uninit_options (&c.options);
	  gc_reset (&c.gc);
	}
      while (c.sig->signal_received == SIGHUP);
    }

  context_gc_free (&c);

  env_set_destroy (c.es);

#ifdef ENABLE_MANAGEMENT
  /* close management interface */
  close_management ();
#endif

  /* uninitialize program-wide statics */
  uninit_static ();

  openvpn_exit (OPENVPN_EXIT_STATUS_GOOD);  /* exit point */
  return 0;			            /* NOTREACHED */
}
예제 #15
0
파일: uart_fcts.c 프로젝트: rodan/ampy
static void uart1_rx_irq(enum sys_message msg)
{
    uint16_t u16;
    uint8_t p;
    uint8_t pga, ch, left = 0, right = 0;
    uint8_t *flash_addr = FLASH_ADDR;
    char *input;
    uint8_t *ptr;
    uint8_t allfine = 0;

    input = (char *)uart1_rx_buf;

    p = input[0];
    if (p > 97) {
        p -= 32;
    }

    if ((p == 63) || (p == M_CMD_HELP)) {       // [h?]
        display_help();
    } else if (p == M_CMD_SHOW) {        // [s]how settings
        show_settings();
        uart1_tx_str("ok\r\n", 4);
    } else if (p == M_CMD_WRITE) {       // [w]rite to flash
        if (str_to_uint16(input, &u16, 1, 1, 1, 3)) {
            if (u16 == 1) {
                flash_addr = SEGMENT_B;
            } else if (u16 == 2) {
                flash_addr = SEGMENT_C;
            } else if (u16 == 3) {
                flash_addr = SEGMENT_D;
            }
            flash_save(flash_addr, (void *)&s, sizeof(s));
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_READ) {       // [r]ead from flash
        if (str_to_uint16(input, &u16, 1, 1, 1, 3)) {
            if (u16 == 1) {
                flash_addr = SEGMENT_B;
            } else if (u16 == 2) {
                flash_addr = SEGMENT_C;
            } else if (u16 == 3) {
                flash_addr = SEGMENT_D;
            }
            settings_init(flash_addr);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_MUTE) {       // [m]ute pga
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            pga_set_mute_st(pga, MUTE, 1);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_UNMUTE) {     // [u]nmute pga
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            pga_set_mute_st(pga, UNMUTE, 1);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_VOL) {       // [v]olume set
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            ch = input[2];
            if (str_to_uint16(input, &u16, 3, strlen(input) - 3, 0, 255)) {
                ptr = (uint8_t *) & s.v1_r;
                if (ch == 98) {
                    // 'b' - change both channels
                    right = u16;
                    left = u16;
                    allfine = 1;
                } else if (ch == 114) {
                    // 'r' - only change the right channel
                    right = u16;
                    left = *(ptr + (pga * 2 - 2) + 1);
                    allfine = 1;
                } else if (ch == 108) {
                    // 'l' - only change the left channel
                    right = *(ptr + (pga * 2 - 2));
                    left = u16;
                    allfine = 1;
                }
                if (allfine) {
                    pga_set_volume(pga, right, left, 1, 1);
                    uart1_tx_str("ok\r\n", 4);
                }
            }
        }
    }
    //snprintf(str_temp, TEMP_LEN, "D 0x%x 0x%x 0x%x\r\n", input[0], input[1], input[2]);
    //uart1_tx_str(str_temp, strlen(str_temp));

    uart1_p = 0;
    uart1_rx_enable = 1;
}
예제 #16
0
void
on_popup_settings_activate (gpointer callback_data, guint action, GtkWidget *widget)
{
	show_settings ();
}
예제 #17
0
/****** Main menu constructor ******/
main_menu::main_menu(QWidget *parent) : QWidget(parent)
{
	//Setup actions
	QAction* open = new QAction("Open", this);
	QAction* quit = new QAction ("Quit", this);

	QAction* pause = new QAction("Pause", this);
	QAction* reset = new QAction("Reset", this);
	QAction* fullscreen = new QAction("Fullscreen", this);
	QAction* screenshot = new QAction("Screenshot", this);
	QAction* nplay_start = new QAction("Start Netplay", this);
	QAction* nplay_stop = new QAction("Stop Netplay", this);

	QAction* general = new QAction("General Settings...", this);
	QAction* display = new QAction("Display", this);
	QAction* sound = new QAction("Sound", this);
	QAction* controls = new QAction("Controls", this);
	QAction* netplay = new QAction("Netplay", this);
	QAction* paths = new QAction("Paths", this);

	QAction* custom_gfx = new QAction("Custom Graphics...", this);
	QAction* debugging = new QAction("Debugger", this);

	QAction* about = new QAction("About", this);

	//Set shortcuts for actions
	open->setShortcut(tr("CTRL+O"));
	quit->setShortcut(tr("CTRL+Q"));

	pause->setShortcut(tr("CTRL+P"));
	reset->setShortcut(tr("F8"));
	fullscreen->setShortcut(tr("F12"));
	screenshot->setShortcut(tr("F9"));
	nplay_start->setShortcut(tr("F5"));
	nplay_stop->setShortcut(tr("F6"));

	pause->setCheckable(true);
	pause->setObjectName("pause_action");
	fullscreen->setCheckable(true);
	fullscreen->setObjectName("fullscreen_action");

	menu_bar = new QMenuBar(this);

	//Setup File menu
	QMenu* file;

	file = new QMenu(tr("File"), this);
	file->addAction(open);
	recent_list = file->addMenu(tr("Recent Files"));
	file->addSeparator();
	state_save_list = file->addMenu(tr("Save State"));
	state_load_list = file->addMenu(tr("Load State"));
	file->addSeparator();
	file->addAction(quit);
	menu_bar->addMenu(file);

	//Setup Emulation menu
	QMenu* emulation;

	emulation = new QMenu(tr("Emulation"), this);
	emulation->addAction(pause);
	emulation->addAction(reset);
	emulation->addSeparator();
	emulation->addAction(fullscreen);
	emulation->addAction(screenshot);
	emulation->addSeparator();
	emulation->addAction(nplay_start);
	emulation->addAction(nplay_stop);
	menu_bar->addMenu(emulation);

	//Setup Options menu
	QMenu* options;
	
	options = new QMenu(tr("Options"), this);
	options->addAction(general);
	options->addSeparator();
	options->addAction(display);
	options->addAction(sound);
	options->addAction(controls);
	options->addAction(netplay);
	options->addAction(paths);
	menu_bar->addMenu(options);

	//Advanced menu
	QMenu* advanced;

	advanced = new QMenu(tr("Advanced"), this);
	advanced->addAction(custom_gfx);
	advanced->addAction(debugging);
	menu_bar->addMenu(advanced);

	//Setup Help menu
	QMenu* help;

	help = new QMenu(tr("Help"), this);
	help->addAction(about);
	menu_bar->addMenu(help);

	//Setup signals
	connect(quit, SIGNAL(triggered()), this, SLOT(quit()));
	connect(open, SIGNAL(triggered()), this, SLOT(open_file()));
	connect(pause, SIGNAL(triggered()), this, SLOT(pause()));
	connect(fullscreen, SIGNAL(triggered()), this, SLOT(fullscreen()));
	connect(screenshot, SIGNAL(triggered()), this, SLOT(screenshot()));
	connect(nplay_start, SIGNAL(triggered()), this, SLOT(start_netplay()));
	connect(nplay_stop, SIGNAL(triggered()), this, SLOT(stop_netplay()));
	connect(reset, SIGNAL(triggered()), this, SLOT(reset()));
	connect(general, SIGNAL(triggered()), this, SLOT(show_settings()));
	connect(display, SIGNAL(triggered()), this, SLOT(show_display_settings()));
	connect(sound, SIGNAL(triggered()), this, SLOT(show_sound_settings()));
	connect(controls, SIGNAL(triggered()), this, SLOT(show_control_settings()));
	connect(netplay, SIGNAL(triggered()), this, SLOT(show_netplay_settings()));
	connect(paths, SIGNAL(triggered()), this, SLOT(show_paths_settings()));
	connect(custom_gfx, SIGNAL(triggered()), this, SLOT(show_cgfx()));
	connect(debugging, SIGNAL(triggered()), this, SLOT(show_debugger()));
	connect(about, SIGNAL(triggered()), this, SLOT(show_about()));

	sw_screen = new soft_screen();
	hw_screen = new hard_screen();

	QVBoxLayout* layout = new QVBoxLayout;
	layout->setContentsMargins(0, 0, 0, -1);
	layout->addWidget(sw_screen);
	layout->addWidget(hw_screen);
	layout->setMenuBar(menu_bar);
	setLayout(layout);

	config::scaling_factor = 2;

	hw_screen->hide();
	hw_screen->setEnabled(false);

	//Parse .ini options
	parse_ini_file();

	//Parse cheats file
	if(config::use_cheats) { parse_cheats_file(); }

	//Parse command-line arguments
	//These will override .ini options!
	if(!parse_cli_args()) { exit(0); }

	//Some command-line arguments are invalid for the Qt version
	config::use_debugger = false;

	//Setup Recent Files
	list_mapper = new QSignalMapper(this);

	for(int x = (config::recent_files.size() - 1); x >= 0; x--)
	{
		QString path = QString::fromStdString(config::recent_files[x]);
		QFileInfo file(path);
		path = file.fileName();

		QAction* temp = new QAction(path, this);
		recent_list->addAction(temp);

		connect(temp, SIGNAL(triggered()), list_mapper, SLOT(map()));
		list_mapper->setMapping(temp, x);
	}

	connect(list_mapper, SIGNAL(mapped(int)), this, SLOT(load_recent(int)));

	//Setup Save States
	QSignalMapper* save_mapper = new QSignalMapper(this);

	for(int x = 0; x < 10; x++)
	{
		QAction* temp;

		if(x == 0) 
		{
			temp = new QAction(tr("Quick Save"), this);
			temp->setShortcut(tr("F1"));
		}
		
		else
		{
			std::string slot_id = "Slot " + util::to_str(x);
			QString slot_name = QString::fromStdString(slot_id);
			temp = new QAction(slot_name, this);
		}

		state_save_list->addAction(temp);

		connect(temp, SIGNAL(triggered()), save_mapper, SLOT(map()));
		save_mapper->setMapping(temp, x);
	}

	connect(save_mapper, SIGNAL(mapped(int)), this, SLOT(save_state(int)));

	//Setup Load States
	QSignalMapper* load_mapper = new QSignalMapper(this);

	for(int x = 0; x < 10; x++)
	{
		QAction* temp;

		if(x == 0)
		{
			temp = new QAction(tr("Quick Load"), this);
			temp->setShortcut(tr("F2"));
		}
		
		else
		{
			std::string slot_id = "Slot " + util::to_str(x);
			QString slot_name = QString::fromStdString(slot_id);
			temp = new QAction(slot_name, this);
		}

		state_load_list->addAction(temp);

		connect(temp, SIGNAL(triggered()), load_mapper, SLOT(map()));
		load_mapper->setMapping(temp, x);
	}

	connect(load_mapper, SIGNAL(mapped(int)), this, SLOT(load_state(int)));

	//Set up settings dialog
	settings = new gen_settings();
	settings->set_ini_options();

	//Set up custom graphics dialog
	cgfx = new gbe_cgfx();
	cgfx->hide();
	cgfx->advanced->setChecked(true);

	//Set up DMG-GBC debugger
	main_menu::dmg_debugger = new dmg_debug();
	main_menu::dmg_debugger->hide();

	//Setup About pop-up
	about_box = new QWidget();
	about_box->resize(300, 250);
	about_box->setWindowTitle("About GBE+");

	QDialogButtonBox* about_button = new QDialogButtonBox(QDialogButtonBox::Close);
	connect(about_button->button(QDialogButtonBox::Close), SIGNAL(clicked()), about_box, SLOT(close()));

	QLabel* emu_title = new QLabel("GBE+ 1.0");
	QFont font = emu_title->font();
	font.setPointSize(18);
	font.setBold(true);
	emu_title->setFont(font);

	QImage logo(QString::fromStdString(config::cfg_path + "data/icons/gbe_plus.png"));
	logo = logo.scaled(128, 128);
	QLabel* emu_desc = new QLabel("A GB/GBC/GBA emulator with enhancements");
	QLabel* emu_copyright = new QLabel("Copyright D.S. Baxter 2014-2016");
	QLabel* emu_proj_copyright = new QLabel("Copyright GBE+ Team 2014-2016");
	QLabel* emu_license = new QLabel("This program is licensed under the GNU GPLv2");
	QLabel* emu_site = new QLabel("<a href=\"https://github.com/shonumi/gbe-plus/\">GBE+ on GitHub</a>");
	emu_site->setOpenExternalLinks(true);
	QLabel* emu_logo = new QLabel;
	emu_logo->setPixmap(QPixmap::fromImage(logo));

	QVBoxLayout* about_layout = new QVBoxLayout;
	about_layout->addWidget(emu_title, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_desc, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_copyright, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_proj_copyright, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_license, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_site, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(emu_logo, 0, Qt::AlignCenter | Qt::AlignTop);
	about_layout->addWidget(about_button);
	about_box->setLayout(about_layout);
	about_box->setWindowIcon(QIcon(QString::fromStdString(config::cfg_path + "data/icons/gbe_plus.png")));
	
	about_box->hide();

	//Setup warning message box
	warning_box = new QMessageBox;
	QPushButton* warning_box_ok = warning_box->addButton("OK", QMessageBox::AcceptRole);
	warning_box->setIcon(QMessageBox::Warning);
	warning_box->hide();

	display_width = QApplication::desktop()->screenGeometry().width();
	display_height = QApplication::desktop()->screenGeometry().height();

	fullscreen_mode = false;
}
예제 #18
0
static void
setoption(char *opt) {
	if (strncasecmp(opt, "all", 3) == 0) {
		show_settings(ISC_TRUE, ISC_FALSE);
	} else if (strncasecmp(opt, "class=", 6) == 0) {
		if (testclass(&opt[6]))
			strlcpy(defclass, &opt[6], sizeof(defclass));
	} else if (strncasecmp(opt, "cl=", 3) == 0) {
		if (testclass(&opt[3]))
			strlcpy(defclass, &opt[3], sizeof(defclass));
	} else if (strncasecmp(opt, "type=", 5) == 0) {
		if (testtype(&opt[5]))
			strlcpy(deftype, &opt[5], sizeof(deftype));
	} else if (strncasecmp(opt, "ty=", 3) == 0) {
		if (testtype(&opt[3]))
			strlcpy(deftype, &opt[3], sizeof(deftype));
	} else if (strncasecmp(opt, "querytype=", 10) == 0) {
		if (testtype(&opt[10]))
			strlcpy(deftype, &opt[10], sizeof(deftype));
	} else if (strncasecmp(opt, "query=", 6) == 0) {
		if (testtype(&opt[6]))
			strlcpy(deftype, &opt[6], sizeof(deftype));
	} else if (strncasecmp(opt, "qu=", 3) == 0) {
		if (testtype(&opt[3]))
			strlcpy(deftype, &opt[3], sizeof(deftype));
	} else if (strncasecmp(opt, "q=", 2) == 0) {
		if (testtype(&opt[2]))
			strlcpy(deftype, &opt[2], sizeof(deftype));
	} else if (strncasecmp(opt, "domain=", 7) == 0) {
		strlcpy(domainopt, &opt[7], sizeof(domainopt));
		set_search_domain(domainopt);
		usesearch = ISC_TRUE;
	} else if (strncasecmp(opt, "do=", 3) == 0) {
		strlcpy(domainopt, &opt[3], sizeof(domainopt));
		set_search_domain(domainopt);
		usesearch = ISC_TRUE;
	} else if (strncasecmp(opt, "port=", 5) == 0) {
		set_port(&opt[5]);
	} else if (strncasecmp(opt, "po=", 3) == 0) {
		set_port(&opt[3]);
	} else if (strncasecmp(opt, "timeout=", 8) == 0) {
		set_timeout(&opt[8]);
	} else if (strncasecmp(opt, "t=", 2) == 0) {
		set_timeout(&opt[2]);
	} else if (strncasecmp(opt, "rec", 3) == 0) {
		recurse = ISC_TRUE;
	} else if (strncasecmp(opt, "norec", 5) == 0) {
		recurse = ISC_FALSE;
	} else if (strncasecmp(opt, "retry=", 6) == 0) {
		set_tries(&opt[6]);
	} else if (strncasecmp(opt, "ret=", 4) == 0) {
		set_tries(&opt[4]);
	} else if (strncasecmp(opt, "def", 3) == 0) {
		usesearch = ISC_TRUE;
	} else if (strncasecmp(opt, "nodef", 5) == 0) {
		usesearch = ISC_FALSE;
	} else if (strncasecmp(opt, "vc", 3) == 0) {
		tcpmode = ISC_TRUE;
	} else if (strncasecmp(opt, "novc", 5) == 0) {
		tcpmode = ISC_FALSE;
	} else if (strncasecmp(opt, "deb", 3) == 0) {
		short_form = ISC_FALSE;
		showsearch = ISC_TRUE;
	} else if (strncasecmp(opt, "nodeb", 5) == 0) {
		short_form = ISC_TRUE;
		showsearch = ISC_FALSE;
	} else if (strncasecmp(opt, "d2", 2) == 0) {
		debugging = ISC_TRUE;
	} else if (strncasecmp(opt, "nod2", 4) == 0) {
		debugging = ISC_FALSE;
	} else if (strncasecmp(opt, "search", 3) == 0) {
		usesearch = ISC_TRUE;
	} else if (strncasecmp(opt, "nosearch", 5) == 0) {
		usesearch = ISC_FALSE;
	} else if (strncasecmp(opt, "sil", 3) == 0) {
		/* deprecation_msg = ISC_FALSE; */
	} else if (strncasecmp(opt, "fail", 3) == 0) {
		nofail=ISC_FALSE;
	} else if (strncasecmp(opt, "nofail", 3) == 0) {
		nofail=ISC_TRUE;
	} else if (strncasecmp(opt, "ndots=", 6) == 0) {
		set_ndots(&opt[6]);
	} else {
		printf("*** Invalid option: %s\n", opt);
	}
}
예제 #19
0
파일: wmain.cpp 프로젝트: pewniak747/dicto
// creates all menus
void WMain::createMenus() {
	fileMenu=new QMenu(this);
	wordMenu=new QMenu(this);
	testMenu=new QMenu(this);
	helpMenu=new QMenu(this);

	newAction=new QAction(tr("&New"), this);
	newAction->setShortcuts(QKeySequence::New);
	newAction->setStatusTip(tr("Create new dictionary"));

	openAction=new QAction(tr("&Open..."), this);
	openAction->setShortcuts(QKeySequence::Open);
	openAction->setStatusTip(tr("Open dictionary"));

	saveAction=new QAction(tr("&Save"), this);
	saveAction->setShortcuts(QKeySequence::Save);
	saveAction->setStatusTip(tr("Save dictionary"));

	saveasAction=new QAction(tr("&Save as..."), this);
	saveasAction->setShortcuts(QKeySequence::SaveAs);
	saveasAction->setStatusTip(tr("Save dictionary as"));

	printAction=new QAction(tr("&Print"), this);
	printAction->setShortcuts(QKeySequence::Print);
	printAction->setStatusTip(tr("Print dictionary"));
	
	settingsAction=new QAction(tr("&Settings"), this);
	settingsAction->setShortcut(QKeySequence("Ctrl+B"));
	settingsAction->setStatusTip(tr("Settings"));

	quitAction=new QAction(tr("&Quit"), this);
	quitAction->setShortcut(QKeySequence("Ctrl+Q"));
	quitAction->setStatusTip(tr("Quit dicto"));

	addAction=new QAction(tr("&Add..."), this);
	addAction->setShortcut(Qt::Key_Insert);
	addAction->setStatusTip(tr("Add new word"));

	editAction=new QAction(tr("&Edit..."), this);
	editAction->setStatusTip(tr("Edit current word"));

	deleteAction=new QAction(tr("&Delete"), this);
	deleteAction->setShortcut(Qt::Key_Delete);
	deleteAction->setStatusTip(tr("Delete current word"));

	sortAction=new QAction(tr("&Sort"), this);
	sortAction->setShortcut(QKeySequence("Ctrl+A"));
	sortAction->setStatusTip(tr("Sort dictionary"));

	testAction=new QAction(tr("&Test..."), this);
	testAction->setShortcut(QKeySequence("Ctrl+T"));
	testAction->setStatusTip(tr("Prepare test"));

	examAction=new QAction(tr("&Exam..."), this);
	examAction->setShortcut(QKeySequence("Ctrl+E"));
	examAction->setStatusTip(tr("Prepare exam"));

	statsAction=new QAction(tr("&Statistics..."), this);
	statsAction->setShortcut(QKeySequence("Ctrl+W"));
	statsAction->setStatusTip(tr("Show statistics"));

	aboutAction=new QAction(tr("&About"), this);
	aboutAction->setStatusTip(tr("About dicto"));

	fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(newAction);
	fileMenu->addAction(openAction);
	fileMenu->addAction(saveAction);
	fileMenu->addAction(saveasAction);
	fileMenu->addAction(printAction);
	fileMenu->addSeparator();
	

	for (int i = 0; i < 10/*maxRecentFiles*/; ++i) {
		recentFilesActions[i] = new QAction(this);
		recentFilesActions[i]->setVisible(false);
		fileMenu->addAction(recentFilesActions[i]);
		connect(recentFilesActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile()));
	}
	updateRecentFileActions();

	
	fileMenu->addSeparator();
	fileMenu->addAction(settingsAction);
	fileMenu->addSeparator();
	fileMenu->addAction(quitAction);

	wordMenu = menuBar()->addMenu(tr("&Words"));
	wordMenu->addAction(addAction);
	wordMenu->addAction(editAction);
	wordMenu->addAction(deleteAction);
	wordMenu->addSeparator();
	wordMenu->addAction(sortAction);

	testMenu = menuBar()->addMenu(tr("&Test"));
	testMenu->addAction(testAction);
	testMenu->addAction(examAction);
	testMenu->addSeparator();
	testMenu->addAction(statsAction);

	helpMenu = menuBar()->addMenu(tr("&Help"));
	helpMenu->addAction(aboutAction);

	connect(newAction, SIGNAL(triggered()), this, SLOT(newfile()));
	connect(openAction, SIGNAL(triggered()), this, SLOT(openfile()));
	connect(saveAction, SIGNAL(triggered()), this, SLOT(savefile()));
	connect(saveasAction, SIGNAL(triggered()), this, SLOT(saveas()));
	connect(printAction, SIGNAL(triggered()), this, SLOT(print()));
	connect(settingsAction, SIGNAL(triggered()), this, SLOT(show_settings()));
	connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

	connect(addAction, SIGNAL(triggered()), this, SLOT(addentry()));
	connect(editAction, SIGNAL(triggered()), this, SLOT(editentry()));
	connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteentry()));
	connect(sortAction, SIGNAL(triggered()), this, SLOT(sortall()));

	connect(testAction, SIGNAL(triggered()), this, SLOT(preparetest()));
	connect(examAction, SIGNAL(triggered()), this, SLOT(prepareexam()));
	connect(statsAction, SIGNAL(triggered()), this, SLOT(stats()));

	connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
}