Beispiel #1
0
/* input_backspace: does a backspace in the input buffer */
void input_backspace(char key, char *blah)
{
    cursor_to_input();
    if (THIS_POS > MIN_POS) {
	char *ptr = NULL;
	int pos;

	malloc_strcpy(&ptr, &(THIS_CHAR));
	strcpy(&(PREV_CHAR), ptr);
	new_free(&ptr);
	THIS_POS--;
	term_cursor_left();
	if (THIS_CHAR) {
	    if (term_delete())
		update_input(UPDATE_FROM_CURSOR);
	    {
		pos = str_start + term_cols - 1;
		pos += count_ansi(&(current_screen->input_buffer[str_start]), zone);
		if (pos < strlen(INPUT_BUFFER)) {
		    term_move_cursor(term_cols - 1, input_line);
		    term_putchar(INPUT_BUFFER[pos]);
		}
		update_input(UPDATE_JUST_CURSOR);
	    }
	} else {
	    term_putchar(' ');
	    term_cursor_left();
	    update_input(NO_UPDATE);
	}
    }
    in_completion = STATE_NORMAL;
    *new_nick = 0;
}
Beispiel #2
0
/* input_delete_character: deletes a character from the input line */
void input_delete_character(char unused, char *not_used)
{
    cursor_to_input();
    if (THIS_CHAR) {
	char *ptr = NULL;
	int pos;

	malloc_strcpy(&ptr, &(NEXT_CHAR));
	strcpy(&(THIS_CHAR), ptr);
	new_free(&ptr);
	if (term_delete())
	    update_input(UPDATE_FROM_CURSOR);
	else {
	    pos = str_start + term_cols - 1;
	    pos += count_ansi(&(current_screen->input_buffer[str_start]), zone);
	    if (pos < strlen(INPUT_BUFFER)) {
		term_move_cursor(term_cols - 1, input_line);
		term_putchar(INPUT_BUFFER[pos]);
		term_move_cursor(cursor, input_line);
	    }
	    update_input(NO_UPDATE);
	}
    }
    in_completion = STATE_NORMAL;
}
Beispiel #3
0
void main()
{
	auto int key, reading, channel,device0;
	auto rn_search newdev;

	brdInit();                 //initialize controller
   rn_init(RN_PORTS, 1);      //initialize controller RN ports

   //search for device match
	newdev.flags = MATCHFLAG;
	newdev.productid = MATCHPID;
   if ((device0 = rn_find(&newdev)) == -1)
   {
   	printf("\n no device found\n");
      exit(0);
   }

	//Display user instructions and channel headings
	DispStr(8, 1, GREEN, "\t\t<<< Digital inputs 0 - 23 >>>");
	DispStr(8, 3, BLACK, "IN00\tIN01\tIN02\tIN03\tIN04\tIN05\tIN06\tIN07");
	DispStr(8, 4, BLACK, "----\t----\t----\t----\t----\t----\t----\t----");

	DispStr(8, 7, BLACK, "IN08\tIN09\tIN10\tIN11\tIN12\tIN13\tIN14\tIN15");
	DispStr(8, 8, BLACK, "----\t----\t----\t----\t----\t----\t----\t----");

	DispStr(8,11, BLACK, "IN16\tIN17\tIN18\tIN19\tIN20\tIN21\tIN22\tIN23");
	DispStr(8,12, BLACK, "----\t----\t----\t----\t----\t----\t----\t----");


	DispStr(8, 16, RED, "Connect the Demo Bd. switches to the inputs that you what to toggle.");
	DispStr(8, 17, RED, "(See instructions in sample program for complete details)");
	DispStr(8, 19, RED, "<-PRESS 'Q' TO QUIT->");

	//loop until user presses the "Q" key
	for(;;)
	{
		// update input channels 0 - 7   (display at col = 8 row = 5)
		update_input(device0, 1, 8, 5);

		// update input channels 8 - 15  (display at col = 8 row = 9)
		update_input(device0, 2, 8, 9);

		// update input channels 16 - 23  (display at col = 8 row = 13)
		update_input(device0, 3, 8, 13);

		if(kbhit())
		{
			key = getchar();
			if (key == 'Q' || key == 'q')		// check if it's the q or Q key
			{
				while(kbhit()) getchar();
      		exit(0);
     		}
		}
   }
}
Beispiel #4
0
// check if any keys or buttons1 are pressed
bool
any_key_pressed (void)
{
  int i;
  bool ret = FALSE;

  update_input();

  for (i=0; i<KEY_PACK(SDLK_LAST); i++)
    if ( just_pressed(input_state[i]) )
      { 
	clear_fresh(input_state[i]);
	ret = TRUE; 
	break;
      }
  if ( just_pressed(input_state[KEY_PACK(JOY_BUTTON1)]) )
    {
      clear_fresh (input_state[KEY_PACK(JOY_BUTTON1)]);
      ret = TRUE;
    }

  if ( just_pressed(input_state[KEY_PACK(MOUSE_BUTTON1)]) )
    {
      ret = TRUE;
      clear_fresh (input_state[KEY_PACK(MOUSE_BUTTON1)]);
    }

  return (ret);

}  // any_key_pressed()
Beispiel #5
0
bool
KeyIsPressed (SDLKey key)
{
  update_input();

  return( (input_state[KEY_PACK(key)] & PRESSED) == PRESSED );
}
Beispiel #6
0
void
history_cmd (void)
{
    Listbox *listbox;
    GList *current;

    if (cmdline->need_push) {
	if (push_history (cmdline, cmdline->buffer) == 2)
	    cmdline->need_push = 0;
    }
    if (!cmdline->history) {
	message (1, MSG_ERROR, _(" The command history is empty "));
	return;
    }
    current = g_list_first (cmdline->history);
    listbox = create_listbox_window (60, 10, _(" Command history "),
				     "[Command Menu]");
    while (current) {
	LISTBOX_APPEND_TEXT (listbox, 0, (char *) current->data, current);
	current = g_list_next(current);
    }
    run_dlg (listbox->dlg);
    if (listbox->dlg->ret_value == B_CANCEL)
	current = NULL;
    else
	current = listbox->list->current->data;
    destroy_dlg (listbox->dlg);
    g_free (listbox);

    if (!current)
	return;
    cmdline->history = current;
    assign_text (cmdline, (char *) current->data);
    update_input (cmdline, 1);
}
void retro_run(void)
{
   uint32_t x, y;
   const uint8_t *buffer;
   uint32_t *surface, pitch;

   update_input();

   prosystem_ExecuteFrame(keyboard_data); // wants input

   videoWidth  = Rect_GetLength(&maria_visibleArea);
   videoHeight = Rect_GetHeight(&maria_visibleArea);
   buffer      = maria_surface + ((maria_visibleArea.top - maria_displayArea.top) * Rect_GetLength(&maria_visibleArea));
   surface     = (uint32_t*)videoBuffer;
   pitch       = 320;

   for(y = 0; y < videoHeight; y++)
   {
      for(x = 0; x < videoWidth; x += 4)
      {
         surface[x + 0] = display_palette32[buffer[x + 0]];
         surface[x + 1] = display_palette32[buffer[x + 1]];
         surface[x + 2] = display_palette32[buffer[x + 2]];
         surface[x + 3] = display_palette32[buffer[x + 3]];
      }
      surface += pitch;
      buffer  += videoWidth;
   }

   video_cb(videoBuffer, videoWidth, videoHeight, videoWidth << 2);

   sound_Store();
}
Beispiel #8
0
int run_emu(const char *path)
{
	SceCtrlData pad;
	unsigned int joypad1, joypad2;
	
	setup_audio();

	emu->set_sample_rate(44100);
	emu->set_equalizer(Nes_Emu::nes_eq);
	emu->set_palette_range(0);

	vita2d_texture *tex = vita2d_create_empty_texture(Nes_Emu::image_width, Nes_Emu::image_height);
	void *tex_data = vita2d_texture_get_datap(tex);

	static uint32_t video_buffer[Nes_Emu::image_width * Nes_Emu::image_height];
	emu->set_pixels(video_buffer, Nes_Emu::image_width);

	Auto_File_Reader freader(path);
	emu->load_ines(freader);

	int scale = 2;
	int pos_x = SCREEN_W/2 - (Nes_Emu::image_width/2)*scale;
	int pos_y = SCREEN_H/2 - (Nes_Emu::image_height/2)*scale;

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if ((pad.buttons & CHANGE_GAME_MASK) == CHANGE_GAME_MASK) break;

		joypad1 = joypad2 = update_input(&pad);

		emu->emulate_frame(joypad1, joypad2);
		const Nes_Emu::frame_t &frame = emu->frame();

		const uint8_t *in_pixels = frame.pixels;
		uint32_t *out_pixels = (uint32_t *)tex_data;

		for (unsigned h = 0; h < Nes_Emu::image_height;
			h++, in_pixels += frame.pitch, out_pixels += Nes_Emu::image_width) {
			for (unsigned w = 0; w < Nes_Emu::image_width; w++) {
				unsigned col = frame.palette[in_pixels[w]];
				const Nes_Emu::rgb_t& rgb = emu->nes_colors[col];
				unsigned r = rgb.red;
				unsigned g = rgb.green;
				unsigned b = rgb.blue;
				out_pixels[w] = 0xFF000000 | (r << 0) | (g << 8) | (b << 16);
			}
		}

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_texture_scale(tex, pos_x, pos_y, scale, scale);
		show_fps();

		vita2d_end_drawing();
		vita2d_swap_buffers();
	}

	return 0;
}
Beispiel #9
0
/*
 * input_beginning_of_line: moves the input cursor to the first character in
 * the input buffer 
 */
void new_input_beginning_of_line(char unused, char *not_used)
{
    cursor_to_input();
    THIS_POS = MIN_POS;
    update_input(UPDATE_JUST_CURSOR);
    extended_handled = 1;
}
Beispiel #10
0
/*
 * refresh_screen: Whenever the REFRESH_SCREEN function is activated, this
 * swoops into effect 
 */
void refresh_screen (unsigned char dumb, char *dumber)
{
extern int need_redraw;

#if !defined(WINNT) && !defined(__EMX__)
	term_clear_screen();
	unflash();
#else
	xterm_settitle();
	term_clear_screen();
#endif

#if 0
	for (tmp = screen_list; tmp; tmp = tmp->next)
		tmp->co = TI_cols, tmp->li = TI_lines;
#endif
	if (term_resize())
		recalculate_windows(current_window->screen);
	else
		redraw_all_windows();
	if (need_redraw)
		need_redraw = 0;
	update_all_windows();
	update_input(UPDATE_ALL);
}
Beispiel #11
0
void nick_completion(char dumb, char *dumber)
{
    char *q, *line;
    int i = -1;
    char *nick = NULL, *tmp;

    q = line = m_strdup(&current_screen->input_buffer[MIN_POS]);
    if (in_completion == STATE_NORMAL) {
	i = word_count(line);
	nick = extract_words(line, i - 1, i);
    }
    if (nick)
	line[strlen(line) - strlen(nick)] = 0;
    else
	*line = 0;
    if ((tmp = getchannick(input_lastmsg, nick && *nick ? nick : NULL))) {
	malloc_strcat(&q, tmp);
	set_input(q);
	update_input(UPDATE_ALL);
	malloc_strcpy(&input_lastmsg, tmp);
	in_completion = STATE_COMPLETE;
    }
    new_free(&q);
    new_free(&nick);
}
Beispiel #12
0
void retro_run(void)
{
   int x;
   unsigned width = 640;
   unsigned height = 400;

   bool updated = false;

   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      update_variables();

   if(pauseg==0)
   {
      update_input();

      if(SND==1)
      {
         int16_t *p=(int16_t*)SNDBUF;

         for(x = 0; x < snd_sampler; x++)
            audio_cb(*p++,*p++);
      }
   }

   if(ConfigureParams.Screen.bAllowOverscan || SHOWKEY==1 || STATUTON==1 || pauseg==1 )
   {
      width  = retrow;
      height = retroh;
   }
   video_cb(bmp, width, height, retrow<< 1);

   co_switch(emuThread);
}
Beispiel #13
0
void retro_run(void)
{
   int x;

   bool updated = false;

   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      update_variables();

   if(pauseg==0){

      update_input();

      if(SND==1){
         signed short int *p=(signed short int *)SNDBUF;
         for(x=0;x<snd_sampler;x++)audio_cb(*p++,*p++);			
      }	
   }   

   if(ConfigureParams.Screen.bAllowOverscan || SHOWKEY==1 || STATUTON==1 || pauseg==1 )video_cb(bmp,retrow,retroh, retrow<< 1);
   // EMU ST FULLSCREEN NO BORDER
   else video_cb(bmp,640/*retrow*/,400/*retrow-80*/,retrow << 1);

   co_switch(emuThread);

}
void retro_run(void)
{
   bool updated = false;

   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      check_variables();

   update_input();

   JaguarExecuteNew();

	static int lastw=STARTWIDTH;

	if(lastw!=TOMGetVideoModeWidth()){
		retro_get_system_av_info(&g_av_info);

		printf("width change:%d-" ,lastw);
		lastw=TOMGetVideoModeWidth();
		printf(">%d\n" ,lastw);

	    game_width = TOMGetVideoModeWidth();
	    game_height = TOMGetVideoModeHeight();
		tomWidth = game_width; tomHeight = game_height;

		printf("new res:%dx%d %f\n",game_width,game_height,(float)game_width/game_height);

		bool ret;
		ret = environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &g_av_info.geometry);
	}

   SDLSoundCallback(NULL,sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC:BUFPAL);

   video_cb(videoBuffer, game_width, game_height, MAXWIDTH << 2);
   audio_batch_cb((int16_t *)sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC/2:BUFPAL/2);
}
Beispiel #15
0
static int insert_text (WInput *in, char *text, ssize_t len)
{
    len = min (len, (ssize_t) strlen (text)) + start - end;
    if (strlen (in->buffer) + len >= (size_t) in->current_max_len){
    /* Expand the buffer */
    	char *narea = g_realloc (in->buffer, in->current_max_len + len + in->field_len);
	if (narea){
	    in->buffer = narea;
	    in->current_max_len += len + in->field_len;
	}
    }
    if (strlen (in->buffer)+1 < (size_t) in->current_max_len){
    	if (len > 0){
	    int i = strlen (&in->buffer [end]);
	    for (; i >= 0; i--)
	        in->buffer [end + len + i] = in->buffer [end + i];
	} else if (len < 0){
	    char *p = in->buffer + end + len, *q = in->buffer + end;
	    while (*q)
	    	*(p++) = *(q++);
	    *p = 0;
	}
	memcpy (in->buffer + start, text, len - start + end);
	in->point += len;
	update_input (in, 1);
	end += len;
    }
    return len != 0;
}
Beispiel #16
0
void	redraw_all_screens (void)
{
	Screen *s, *old_os;

	old_os = output_screen;
	for (s = screen_list; s; s = s->next)
	{
		if (!s->alive)
			continue;

		output_screen = s;
		unflash();
		term_clear_screen();
		if (s == main_screen && term_resize())
			recalculate_windows(current_window->screen);
	}

	/* Logically mark all windows as needing a redraw */
	redraw_all_windows();

	/* Physically redraw all windows and status bars */
	update_all_windows();

	/* Physically redraw all input lines */
	update_input(NULL, UPDATE_ALL);

	output_screen = old_os;
	need_redraw = 0;
}
Beispiel #17
0
void retro_run()
{
    input_poll_cb();
    
    update_input();
    
    static int16_t sound_buf[0x10000];
    static MDFN_Rect rects[384];
    
    EmulateSpecStruct spec = {0}; 
    spec.surface = surf;
    spec.SoundRate = 48000;
    spec.SoundBuf = sound_buf;
    spec.LineWidths = rects;
    spec.SoundBufMaxSize = sizeof(sound_buf) / 2;
    spec.SoundVolume = 1.0;
    spec.soundmultiplier = 1.0;
    
    MDFNI_Emulate(&spec);
    
    //unsigned width = rects[0].w;
    //unsigned height = spec.DisplayRect.h;
    unsigned width = 384;
    unsigned height = 224;
    
    convert_surface();
    video_cb(conv_buf, width, height, width << 1);
    
    audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);
}
Beispiel #18
0
void refresh_window_screen(Window *window)
{
   xterm_settitle();
   recalculate_windows(current_window->screen);
   update_all_windows();
   update_input(UPDATE_ALL);
}
Beispiel #19
0
/*
 * This removes every character from the 'anchor' position to the current
 * position from the input line, and puts it into the cut buffer.  It does
 * the requisite redraw as well.
 */
static void	cut_input (int anchor)
{
	char *	buffer;
	size_t	size;

	if (anchor < THIS_POS)
	{
		size = THIS_POS - anchor;
		buffer = alloca(size + 1);
		strlcpy(buffer, &INPUT_BUFFER[anchor], size + 1);
		malloc_strcpy(&cut_buffer, buffer);

		buffer = LOCAL_COPY(&THIS_CHAR);
		INPUT_BUFFER[anchor] = 0;
		ADD_TO_INPUT(buffer);
		THIS_POS = anchor;
	}
	else
	{
		size = anchor - THIS_POS;
		buffer = alloca(size + 1);
		strlcpy(buffer, &THIS_CHAR, size + 1);
		malloc_strcpy(&cut_buffer, buffer);

		buffer = LOCAL_COPY(&INPUT_BUFFER[anchor]);
		THIS_CHAR = 0;
		ADD_TO_INPUT(buffer);
	}

	update_input(UPDATE_ALL);
}
void retro_run()
{
   MDFNGI *curgame = game;

   input_poll_cb();

   update_input();

   static int16_t sound_buf[0x10000];
   static MDFN_Rect rects[FB_MAX_HEIGHT];
   rects[0].w = ~0;

   EmulateSpecStruct spec = {0};
   spec.surface = surf;
   spec.SoundRate = 44100;
   spec.SoundBuf = sound_buf;
   spec.LineWidths = rects;
   spec.SoundBufMaxSize = sizeof(sound_buf) / 2;
   spec.SoundVolume = 1.0;
   spec.soundmultiplier = 1.0;
   spec.SoundBufSize = 0;
   spec.VideoFormatChanged = false;
   spec.SoundFormatChanged = false;

   if (memcmp(&last_pixel_format, &spec.surface->format, sizeof(MDFN_PixelFormat)))
   {
      spec.VideoFormatChanged = TRUE;

      last_pixel_format = spec.surface->format;
   }

   if (spec.SoundRate != last_sound_rate)
   {
      spec.SoundFormatChanged = true;
      last_sound_rate = spec.SoundRate;
   }

   curgame->Emulate(&spec);

   int16 *const SoundBuf = spec.SoundBuf + spec.SoundBufSizeALMS * curgame->soundchan;
   int32 SoundBufSize = spec.SoundBufSize - spec.SoundBufSizeALMS;
   const int32 SoundBufMaxSize = spec.SoundBufMaxSize - spec.SoundBufSizeALMS;

   spec.SoundBufSize = spec.SoundBufSizeALMS + SoundBufSize;

   unsigned width  = spec.DisplayRect.w;
   unsigned height = spec.DisplayRect.h;

   const uint16_t *pix = surf->pixels16;
   video_cb(pix, width, height, FB_WIDTH << 1);

   video_frames++;
   audio_frames += spec.SoundBufSize;

   audio_batch_cb(spec.SoundBuf, spec.SoundBufSize);

   bool updated = false;
   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      check_variables();
}
Beispiel #21
0
/*
 * input_transpose_characters: swaps the positions of the two characters
 * before the cursor position 
 */
void input_transpose_characters(char unused, char *not_used)
{
    cursor_to_input();
    if (current_screen->buffer_pos > MIN_POS) {
	u_char c1[3] = { 0 };
	int pos, end_of_line = 0;

	if (THIS_CHAR)
	    pos = THIS_POS;
	else if (strlen(get_input()) > MIN_POS + 2) {
	    pos = THIS_CHAR - 1;
	    end_of_line = 1;
	} else
	    return;

	c1[0] = INPUT_BUFFER[pos];
	c1[1] = INPUT_BUFFER[pos] = INPUT_BUFFER[pos - 1];
	INPUT_BUFFER[pos - 1] = c1[0];
	term_cursor_left();
	if (end_of_line)
	    term_cursor_left();

	term_putchar(c1[0]);
	term_putchar(c1[1]);
	if (!end_of_line)
	    term_cursor_left();
	update_input(NO_UPDATE);
    }
}
Beispiel #22
0
void 	change_input_prompt (int direction)
{
	/* XXXXXX THIS is totaly wrong. XXXXXX */
	if (!last_input_screen->promptlist)
	{
		strlcpy(INPUT_BUFFER, last_input_screen->saved_input_buffer, sizeof INPUT_BUFFER);
		THIS_POS = last_input_screen->saved_buffer_pos;
		MIN_POS = last_input_screen->saved_min_buffer_pos;
		*last_input_screen->saved_input_buffer = 0;
		last_input_screen->saved_buffer_pos = 0;
		last_input_screen->saved_min_buffer_pos = 0;
	}

	else if (direction == -1)
		;

	else if (!last_input_screen->promptlist->next)
	{
		strlcpy(last_input_screen->saved_input_buffer, INPUT_BUFFER, sizeof INPUT_BUFFER);
		last_input_screen->saved_buffer_pos = THIS_POS;
		last_input_screen->saved_min_buffer_pos = MIN_POS;
		*INPUT_BUFFER = 0;
		THIS_POS = MIN_POS = 0;
	}

	update_input(UPDATE_ALL);
}
Beispiel #23
0
static void p_part(char *from, char **ArgList)
{
    char *channel;

    if (!from || !*from)
	return;
    channel = ArgList[0];

    PasteArgs(ArgList, 1);
    message_from(channel, LOG_CRAP);
    in_on_who = 1;

    if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS | IGNORE_CRAP, NULL) != IGNORED) &&
	do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1] ? ArgList[1] : empty_str))
	put_it("%s",
	       convert_output_format(get_format(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost,
				     channel, ArgList[1] ? ArgList[1] : empty_str));
    if (!my_stricmp(from, get_server_nickname(from_server))) {
	remove_channel(channel, from_server);
	remove_from_mode_list(channel, from_server);
	remove_from_join_list(channel, from_server);
	set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0);
    } else {
	remove_from_channel(channel, from, from_server, 0, NULL);
    }
    update_all_status(curr_scr_win, NULL, 0);
    update_input(UPDATE_ALL);
    message_from(NULL, LOG_CRAP);
    in_on_who = 0;
}
Beispiel #24
0
static void reinit_screen(Window *win, char *unused, int value)
{
	set_input_prompt(current_window, NULL, 0);
	set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0);
	update_all_windows();
	update_all_status(current_window, NULL, 0);
	update_input(UPDATE_ALL);
}
Beispiel #25
0
/* input_clear_to_eol: erases from the cursor to the end of the input buffer */
void input_clear_to_eol(char unused, char *not_used)
{
    cursor_to_input();
    malloc_strcpy(&cut_buffer, &(THIS_CHAR));
    THIS_CHAR = 0;
    term_clear_to_eol();
    update_input(NO_UPDATE);
}
Beispiel #26
0
 tracker<F>& tracker<F>::run(const I& in)
 {
   //copy(in, input_);
   //fill_border_clamp(input_);
   update_input(in);
   run();
   return *this;
 }
Beispiel #27
0
static void
input_do_set_cursor_pos(unsigned pos)
{
	ScreenInputData *inputdata = screen_get_inputdata(get_current_screen());

	inputdata->buffer.pos = pos;
	update_input(UPDATE_JUST_CURSOR);
}
Beispiel #28
0
bool
ModIsPressed (SDLMod mod)
{
  bool ret;
  update_input();
  ret = ( (current_modifiers & mod) != 0) ;
  return (ret);
}
Beispiel #29
0
/*-----------------------------------------------------------------
 * Desc: should do roughly what getchar() does, but in raw
 * 	 (SLD) keyboard mode.
 *
 * Return: the (SDLKey) of the next key-pressed event cast to (int)
 *
 *-----------------------------------------------------------------*/
int
getchar_raw (void)
{
  SDL_Event event;
  int Returnkey = 0;

  //  keyboard_update ();   /* treat all pending keyboard-events */

  while ( !Returnkey )
    {
      SDL_WaitEvent (&event);    /* wait for next event */

      switch (event.type)
	{
	case SDL_KEYDOWN:
	  /*
	   * here we use the fact that, I cite from SDL_keyboard.h:
	   * "The keyboard syms have been cleverly chosen to map to ASCII"
	   * ... I hope that this design feature is portable, and durable ;)
	   */
	  Returnkey = (int) event.key.keysym.sym;
	  if ( event.key.keysym.mod & KMOD_SHIFT )
	    Returnkey = toupper( (int)event.key.keysym.sym );
	  break;

	case SDL_JOYBUTTONDOWN:
	  if (event.jbutton.button == 0)
	    Returnkey = JOY_BUTTON1;
	  else if (event.jbutton.button == 1)
	    Returnkey = JOY_BUTTON2;
	  else if (event.jbutton.button == 2)
	    Returnkey = JOY_BUTTON3;
	  break;

	case SDL_MOUSEBUTTONDOWN:
	  if (event.button.button == SDL_BUTTON_LEFT)
	    Returnkey = MOUSE_BUTTON1;
	  else if (event.button.button == SDL_BUTTON_RIGHT)
	    Returnkey = MOUSE_BUTTON2;
	  else if (event.button.button == SDL_BUTTON_MIDDLE)
	    Returnkey = MOUSE_BUTTON3;
	  else if (event.button.button == SDL_BUTTON_WHEELUP)
	    Returnkey = MOUSE_WHEELUP;
	  else if (event.button.button == SDL_BUTTON_WHEELDOWN)
	    Returnkey = MOUSE_WHEELDOWN;
	  break;

	default:
	  SDL_PushEvent (&event);  /* put this event back into the queue */
	  update_input ();  /* and treat it the usual way */
	  continue;
	}

    } /* while(1) */

  return ( Returnkey );

} /* getchar_raw() */
Beispiel #30
0
/*
 * input_yank_cut_buffer: takes the contents of the cut buffer and inserts it
 * into the input line 
 */
void input_yank_cut_buffer(char unused, char *not_used)
{
    char *ptr = NULL;

    if (cut_buffer) {
	malloc_strcpy(&ptr, &(THIS_CHAR));
	/* Ooops... */
	THIS_CHAR = 0;
	ADD_TO_INPUT(cut_buffer);
	ADD_TO_INPUT(ptr);
	new_free(&ptr);
	update_input(UPDATE_FROM_CURSOR);
	THIS_POS += strlen(cut_buffer);
	if (THIS_POS > INPUT_BUFFER_SIZE)
	    THIS_POS = INPUT_BUFFER_SIZE;
	update_input(UPDATE_JUST_CURSOR);
    }
}