Beispiel #1
0
static cb_ret_t
panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_NOTIFY:
        if (sender != NULL && sender->id == panel_listing_types_id)
        {
            WCheck *ch;
            WInput *in1, *in2, *in3;

            in1 = INPUT (dlg_find_by_id (h, panel_user_format_id));
            in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id));
            ch = CHECK (dlg_find_by_id (h, mini_user_status_id));
            in3 = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (!(ch->state & C_BOOL))
                input_assign_text (in3, status_format[RADIO (sender)->sel]);
            input_update (in1, FALSE);
            input_update (in2, FALSE);
            input_update (in3, FALSE);
            widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx);
            widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx);
            return MSG_HANDLED;
        }

        if (sender != NULL && sender->id == mini_user_status_id)
        {
            WInput *in;

            in = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (CHECK (sender)->state & C_BOOL)
            {
                widget_disable (WIDGET (in), FALSE);
                input_assign_text (in, status_format[3]);
            }
            else
            {
                WRadio *r;

                r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                widget_disable (WIDGET (in), TRUE);
                input_assign_text (in, status_format[r->sel]);
            }
            /* input_update (in, FALSE); */
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Beispiel #2
0
void escape_wait(void)
{
	do
	{
		input_update();
	}
	while(key[KEY_ESC]);
}
Beispiel #3
0
void update_devices(struct memory* m, uint64_t cycles) {
  if (m->devices[DEVICE_DISPLAY])
    display_update(m->devices[DEVICE_DISPLAY], cycles);
  if (m->devices[DEVICE_TIMER])
    timer_update(m->devices[DEVICE_TIMER], cycles);
  if (m->devices[DEVICE_INPUT])
    input_update(m->devices[DEVICE_INPUT], cycles);
}
Beispiel #4
0
/**
 * Update loop
 */
void update_callback()
{
    input_update(); /* updates input system */
    update_light();
    update_camera(); /* update camera after input is refreshed */
    eng_update();   /* updates engine and renders the frame */
    app_window_swapbuffers();
}
Beispiel #5
0
void Sys_SendKeyEvents(void)
{
#ifndef DEDICATED_ONLY
  input_update();
#endif

  /* grab frame time */
  sys_frame_time = timeGetTime();
}
Beispiel #6
0
/*---------------------------------------------------------
 Function: joypad_wait

 Description:
 Waits until the joypad fire button has been released.
---------------------------------------------------------*/
void joypad_wait(void)
{
   int   x, y, fire;

   do {
		input_update();
      measure(x, y, fire);
   } while (fire);
}
Beispiel #7
0
void input_menu()
{
	thread_lockinputmutex();

	input_reset();
	input_update();

	thread_unlockinputmutex();
}
Beispiel #8
0
void game_update(f32 dt) {
	entityManager_update(g_entities, dt);

	if (input_keyDown(SDL_SCANCODE_R)) {
		entityManager_reloadLua(g_entities);
	}

	//this should always be the last thing to update
	input_update();
}
Beispiel #9
0
/*---------------------------------------------------------
 Function: keyboard_wait

 Description:
  Waits until all keyboard keys have been released.
---------------------------------------------------------*/
void keyboard_wait(void)
{
	int x, y, fire;

	do
	{
		input_update();
		getkeyboard(x, y, fire);
	}
	while(x || y || fire || key[KEY_ESC]);
}
Beispiel #10
0
/*---------------------------------------------------------
 Function: mouse_wait

 Description:
 Waits until all mouse buttons have been released.
---------------------------------------------------------*/
void mouse_wait(void)
{
   int   x, y, b;

   getmousexy(b, x, y);
   while (b)
	{
		input_update();
		getmousexy(b, x, y);
	}
}
Beispiel #11
0
/*---------------------------------------------------------
 Function: input_fire

 Description:
 Waits until fire button on any enabled device has been
 pressed.
---------------------------------------------------------*/
void input_fire(void)
{
   int  j, k, m;
   int  x, y;

   k = j = m = 0;
   do {
		input_update();

      if (keyboard) getkeyboard(x, y, k);
      if (joypad) getjoypad(x, y, j);
      if (mouse) getmouse(x, y, m);
	} while ((!k && !j && !m) || !window.isFocus());
}
Beispiel #12
0
int main (int argc, char* argv[]) {
	SDL_Event		event;
	SDL_Surface		*screen;

	if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) {
		printf ("Unable to initialize SDL: %s\n", SDL_GetError ());
		return 1;
	}

	SDL_WM_SetCaption ("Cube of cubes", "Cube of cubes");
	SDL_ShowCursor(SDL_DISABLE);
	SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);

	//Initialize window
	screen = SDL_SetVideoMode (WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL);
	if (!screen) {
		printf ("Unable to set video mode: %s\n", SDL_GetError ());
		return 1;
	}

	r_init ();

	//Main loop
	while (!user_exit) {
		//Handle input
		while (SDL_PollEvent (&event)) {
			switch (event.type) {
			case SDL_KEYDOWN:
				input_keyDown (event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				input_keyUp (event.key.keysym.sym);
				break;
			case SDL_MOUSEMOTION:
				input_mouseMove (event.motion.x, event.motion.y);
				break;
			case SDL_QUIT:
				exit (0);
			}
		}
		input_update ();
		r_drawFrame ();
		// Cap it at 100 fps
		usleep (10000);
	}

	SDL_Quit ();

	return 0;
}
Beispiel #13
0
static void
update_command (void)
{
    if (l_panelize->pos != last_listitem)
    {
        struct panelize *data = NULL;

        last_listitem = l_panelize->pos;
        listbox_get_current (l_panelize, NULL, (void **) &data);
        input_assign_text (pname, data->command);
        pname->point = 0;
        input_update (pname, TRUE);
    }
}
Beispiel #14
0
int main(void) {
    // LCD Screen
    lcd_init();
    terminal_init();

    // Input
    input_init();

    // Set power LED
    DDRB |= (1 << PINB6);
    clear_bit(PORTB, PINB6);

    // Radio
    uint8_t local_addr[] = { 0x1B, 0x1B, 0x1B, 0x1B, 0x1B };
    uint8_t robot_addr[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };
    spi_init();
    nrf24_init();
    nrf24_config(47, sizeof(RemoteCommand)); // Channel 7
    nrf24_set_rx_addr(local_addr);
    nrf24_set_tx_addr(robot_addr);

    // Ready to go!
    sei();

    RemoteMode mode = MODE_MANUAL;

    while (1)
    {
        input_update(&input_state);

        switch (mode) {
        case MODE_MANUAL:
            UpdateManualMode(&input_state);
            break;
        case MODE_AUTO:
            asm("nop"::);
            break;
        case MODE_MENU:
            asm("nop"::);
            break;
        }
    }
}
Beispiel #15
0
static int
insert_text (WInput * in, char *text, ssize_t size)
{
    int buff_len = str_length (in->buffer);

    size = min (size, (ssize_t) strlen (text)) + start - end;
    if (strlen (in->buffer) + size >= (size_t) in->current_max_size)
    {
        /* Expand the buffer */
        char *narea = g_try_realloc (in->buffer, in->current_max_size + size + in->field_width);
        if (narea != NULL)
        {
            in->buffer = narea;
            in->current_max_size += size + in->field_width;
        }
    }
    if (strlen (in->buffer) + 1 < (size_t) in->current_max_size)
    {
        if (size > 0)
        {
            int i = strlen (&in->buffer[end]);
            for (; i >= 0; i--)
                in->buffer[end + size + i] = in->buffer[end + i];
        }
        else if (size < 0)
        {
            char *p = in->buffer + end + size, *q = in->buffer + end;
            while (*q)
                *(p++) = *(q++);
            *p = 0;
        }
        memcpy (in->buffer + start, text, size - start + end);
        in->point += str_length (in->buffer) - buff_len;
        input_update (in, TRUE);
        end += size;
    }
    return size != 0;
}
int main(void)
{
	physics_init(LCD_WIDTH, LCD_HEIGHT);
	input_init();
	display_init();
	segment_init();
	players_init();
	
	playerA = players_get(0);
	playerB = players_get(1);
	
	ball = physics_create(LCD_WIDTH / 2, LCD_HEIGHT / 2, BALL_RADIUS, BALL_MASS);
	
	for (;;)
	{
		input_update();
		players_update(0.01f);
		physics_update(0.01f);
		game_update();
		game_draw();
	}
	
	return 0;
}
Beispiel #17
0
/*
 * SDL_main
 * Program entry point.
 */
int SDL_main(int argc, char* argv[]){
	SDL_Event	event;
	SDL_Surface	*screen;

	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
	{
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}

	SDL_WM_SetCaption("Skybox Demo", "Skybox Demo");
	SDL_ShowCursor(SDL_DISABLE);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL);
	if(!screen)
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}

	r_init();


	//Declaration of variables used in decoupling.
	int currTime = SDL_GetTicks();
	int prevTime = 0;

	//THIS IS THE GAME LOOP! *********************************************

	while(!user_exit)
	{
		//Set time counters to appropriate values for calculations.
		prevTime = currTime;
		currTime = SDL_GetTicks();

		//Handle input
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_KEYDOWN:
				input_keyDown(event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				input_keyUp(event.key.keysym.sym);
				break;
			case SDL_MOUSEMOTION:
				input_mouseMove(event.motion.x, event.motion.y);
				break;
			case SDL_QUIT:
				user_exit = 1;
			}
		}

		input_update(currTime - prevTime);
		r_drawFrame();
	}

	//********************************************************************

	SDL_Quit();
	return 0;
}
Beispiel #18
0
static cb_ret_t
display_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    switch (msg)
    {
    case DLG_KEY:
        if (parm == '\n')
        {
            if (dlg_widget_active (display_radio))
            {
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
                dlg_stop (h);
                return MSG_HANDLED;
            }

            if (dlg_widget_active (display_user_format))
            {
                h->ret_value = B_USER + 6;
                dlg_stop (h);
                return MSG_HANDLED;
            }

            if (dlg_widget_active (display_mini_status))
            {
                h->ret_value = B_USER + 7;
                dlg_stop (h);
                return MSG_HANDLED;
            }
        }

        if ((g_ascii_tolower (parm) == display_user_hotkey)
            && dlg_widget_active (display_user_format) && dlg_widget_active (display_mini_status))
        {
            display_radio->pos = display_radio->sel = 3;
            dlg_select_widget (display_radio);  /* force redraw */
            h->callback (h, (Widget *) display_radio, DLG_ACTION, 0, NULL);
            return MSG_HANDLED;
        }
        return MSG_NOT_HANDLED;

    case DLG_ACTION:
        if (sender == (Widget *) display_radio)
        {
            if (!(display_check_status->state & C_BOOL))
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
            input_update (display_mini_status, FALSE);
            input_update (display_user_format, FALSE);
            widget_disable (display_user_format->widget, display_radio->sel != 3);
            return MSG_HANDLED;
        }

        if (sender == (Widget *) display_check_status)
        {
            if (display_check_status->state & C_BOOL)
            {
                widget_disable (display_mini_status->widget, FALSE);
                input_assign_text (display_mini_status, displays_status[3]);
            }
            else
            {
                widget_disable (display_mini_status->widget, TRUE);
                input_assign_text (display_mini_status, displays_status[display_radio->sel]);
            }
            input_update (display_mini_status, FALSE);
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}
Beispiel #19
0
/*
 * SDL_main
 */
int SDL_main(int argc, char* argv[])
{
	SDL_Event		event;
	SDL_Surface		*screen, *icon;

	putenv(strdup("SDL_VIDEO_CENTERED=1"));

    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
	{
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    icon = SDL_LoadBMP("gui/icon.bmp");
    SDL_WM_SetIcon(icon, NULL);

	SDL_WM_SetCaption("Convex Hull Testing", "Convex Hull Testing");
	SDL_ShowCursor(SDL_DISABLE);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, etrue);

	//Initialize window
    // | SDL_FULLSCREEN
    screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL | SDL_NOFRAME);
    if(!screen)
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return EXIT_FAILURE;
	}

    SDL_WarpMouse(512.0, 384.0);

    //gameState = STATE_MAINMENU;

    timer_init();
    renderer_init();
    world_init();
    //model_init();

	//Main loop
	while(!user_exit)
	{
		//Handle input
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_KEYDOWN:
				input_keyDown(event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				input_keyUp(event.key.keysym.sym);
				break;
			case SDL_MOUSEMOTION:
				input_mouseMove(event.motion.x, event.motion.y);
				break;
			case SDL_QUIT:
				user_exit = etrue;
			}
		}

		timer_update();

		while(timer.accumulated >= TIMESTEP)
		{
			input_update();
			world_update();

			timer.accumulated -= TIMESTEP;
		}

		world_lerpPositions(timer.accumulated);
		renderer_drawFrame();
	}

    SDL_Quit();

    return EXIT_SUCCESS;
}
Beispiel #20
0
//Program entry point
int SDL_main(int argc, char* argv[])
{
	int i;
	SDL_Event	event;		//Used for handling input events, as you can see later on.
	SDL_Surface	*screen;	//http://www.libsdl.org/cgi/docwiki.cgi/SDL_Surface
	CAMERA_POSITION camera;
	float *colors[3] = {&RED[0], &GREEN[0], &BLUE[0]};

	for (i = 0; i < 256; i++) {
		keys_down[i] = 0;
	}
	resetCamera(&camera);

	//The following is pretty self-explanatory
	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
	{
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}

	//You can of course customize this.
	SDL_WM_SetCaption("Perspective Projection", "Perspective Projection");

	//We need to explicitly enable double buffering
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	//Initialize window, setting the resolution to 1024x768 @ 32 bits per pixel. We want an OpenGL window.
	screen = SDL_SetVideoMode(1024, 768, 32, SDL_OPENGL);
	if(!screen)
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}

	//Any other one-time initialization would typically go here.
	//"Renderer" initialization
	r_init(&camera);

	//This is what is referred to as the "game loop." Obviously there is not much here currently.
	while(!user_exit)
	{
		bool mouseMoved = FALSE;
		int x = 0, y = 0;
		//Handle input
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_KEYDOWN:
				input_keyDown(event.key.keysym.sym, &camera);
				break;
			case SDL_KEYUP:
				input_keyUp(event.key.keysym.sym);
				break;
			case SDL_MOUSEBUTTONDOWN:
				randomizeColors(colors);
				break;
			case SDL_MOUSEMOTION:
				x = event.motion.x;
				y = event.motion.y;
				mouseMoved = TRUE;
				break;
			case SDL_QUIT:
				exit(0);
			}
		}
		input_update(&camera);
		if (mouseMoved) {
			input_mouseMoved(&camera, x, y);
			setUpAndLoadModelViewMatrix(&camera);
		}

		//Here is where you will do any OpenGL drawing. You would also do things like update moving objects, etc.
		//Do whatever we need to do to draw a single image.
		r_drawFrame(colors);
	}

	//Shut down SDL
	SDL_Quit();

	//Everything went OK.
	return 0;
}
Beispiel #21
0
/* input text */
void input(SDL_Surface *dst, int x, int y, char *text, int max)
{
	SDL_Event event;
	int action, active = 0, flip = 0;
	int up = 0, down = 0;
	
	#ifdef _PSP_FW_VERSION
	/* danzeff */
	if (config.danzeff)
	{
		strcpy(text, "");
		danzeff_load();
		danzeff_set_screen(dst);
		danzeff_moveTo(165, 110);
		
		for (;;)
		{
			SceCtrlData ctrl = getCtrlFromJoystick(joystick);
			int c = danzeff_readInput(ctrl);
			
			switch (c)
			{
				case 0:
					break;
				case '\10':
				case DANZEFF_LEFT:
					if (active > 0)
					{
						active--;
						text[active] = '\0';
					}
					break;
				case DANZEFF_RIGHT:
					if (active < max)
					{
						text[active] = ' ';
						active++;
						text[active] = '\0';
					}
					break;
				case DANZEFF_SELECT:
				case DANZEFF_START:
					return;
				default:
					if (active < max)
					{
						text[active] = c;
						active++;
						text[active] = '\0';
					}
					break;
			}
			
			danzeff_render();
			input_update(dst, x, y, text, active, flip);
			flip++;
			SDL_Delay(50);
			
			/* flush events */
			while (SDL_PollEvent(&event));
		}
	}
	else	
	#endif
	
	/* arcade */
	{
		strcpy(text, " ");
		for (;;)
		{
			while (SDL_PollEvent(&event))
			{
				switch (event.type)
				{
					case SDL_QUIT:
						quit();
						break;
					case SDL_KEYDOWN:
					case SDL_JOYBUTTONDOWN:
						if (event.type == SDL_KEYDOWN)
							action = event.key.keysym.sym;
						else
							action = event.jbutton.button;
						switch (action)
						{
							case SDLK_ESCAPE:
							case SDLK_SPACE:
							case PSP_BUTTON_START:
								return;
							case SDLK_LEFT:
							case PSP_BUTTON_LEFT:
							case PSP_BUTTON_L:
							case PSP_BUTTON_A:
								if (active > 0)
								{
									text[active] = '\0';
									active--;
								}
								break;
							case SDLK_RIGHT:
							case PSP_BUTTON_RIGHT:
							case PSP_BUTTON_R:
							case PSP_BUTTON_B:
							case PSP_BUTTON_Y:
							case PSP_BUTTON_X:
								if (active < max)
								{
									active++;
									text[active] = ' ';
									text[active+1] = '\0';
								}
								break;
							case SDLK_UP:
							case PSP_BUTTON_UP:
								up = 1;
								break;
							case SDLK_DOWN:
							case PSP_BUTTON_DOWN:
								down = 1;
								break;
							default:
								break;
						}
						break;
					case SDL_KEYUP:
					case SDL_JOYBUTTONUP:
						if (event.type == SDL_KEYUP)
							action = event.key.keysym.sym;
						else
							action = event.jbutton.button;
						switch (action)
						{
							case SDLK_UP:
							case PSP_BUTTON_UP:
								up = 0;
								break;
							case SDLK_DOWN:
							case PSP_BUTTON_DOWN:
								down = 0;
								break;
						}
						break;
				}
			}
			if (up == 1 || up > 10)
			{
				if ((text[active] >= 'A' && text[active] < 'Z') || (text[active] >= '0' && text[active] < '9')) text[active]++;
				else if (text[active] == 'Z') text[active] = '0';
				else if (text[active] == '9') text[active] = ' ';
				else if (text[active] == ' ') text[active] = 'A';
			}
			if (up) up++;
			if (down == 1 || down > 10)
			{
				if ((text[active] > 'A' && text[active] <= 'Z') || (text[active] > '0' && text[active] <= '9')) text[active]--;
				else if (text[active] == 'A') text[active] = ' ';
				else if (text[active] == ' ') text[active] = '9';
				else if (text[active] == '0') text[active] = 'Z';
			}
			if (down) down++;
			input_update(dst, x, y, text, active, flip);
			flip++;
			SDL_Delay(50);
		}
	}
}
Beispiel #22
0
static cb_ret_t
panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_KEY:
        if (parm == '\n')
        {
            Widget *wi;

            wi = dlg_find_by_id (h, panel_listing_types_id);
            if (widget_is_active (wi))
            {
                WInput *in;

                in = INPUT (dlg_find_by_id (h, mini_user_format_id));
                input_assign_text (in, status_format[RADIO (wi)->sel]);
                dlg_stop (h);
                return MSG_HANDLED;
            }

            wi = dlg_find_by_id (h, panel_user_format_id);
            if (widget_is_active (wi))
            {
                h->ret_value = B_USER + 6;
                dlg_stop (h);
                return MSG_HANDLED;
            }

            wi = dlg_find_by_id (h, mini_user_format_id);
            if (widget_is_active (wi))
            {
                h->ret_value = B_USER + 7;
                dlg_stop (h);
                return MSG_HANDLED;
            }
        }

        if (g_ascii_tolower (parm) == listing_user_hotkey)
        {
            Widget *wi;

            wi = dlg_find_by_id (h, panel_user_format_id);
            if (widget_is_active (wi))
            {
                wi = dlg_find_by_id (h, mini_user_format_id);
                if (widget_is_active (wi))
                {
                    WRadio *r;

                    r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                    r->pos = r->sel = panel_listing_user_idx;
                    dlg_select_widget (WIDGET (r));     /* force redraw */
                    send_message (h, r, MSG_ACTION, 0, NULL);
                    return MSG_HANDLED;
                }
            }
        }
        return MSG_NOT_HANDLED;

    case MSG_ACTION:
        if (sender != NULL && sender->id == panel_listing_types_id)
        {
            WCheck *ch;
            WInput *in1, *in2, *in3;

            in1 = INPUT (dlg_find_by_id (h, panel_user_format_id));
            in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id));
            ch = CHECK (dlg_find_by_id (h, mini_user_status_id));
            in3 = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (!(ch->state & C_BOOL))
                input_assign_text (in3, status_format[RADIO (sender)->sel]);
            input_update (in1, FALSE);
            input_update (in2, FALSE);
            input_update (in3, FALSE);
            widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx);
            widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx);
            return MSG_HANDLED;
        }

        if (sender != NULL && sender->id == mini_user_status_id)
        {
            WInput *in;

            in = INPUT (dlg_find_by_id (h, mini_user_format_id));

            if (CHECK (sender)->state & C_BOOL)
            {
                widget_disable (WIDGET (in), FALSE);
                input_assign_text (in, status_format[3]);
            }
            else
            {
                WRadio *r;

                r = RADIO (dlg_find_by_id (h, panel_listing_types_id));
                widget_disable (WIDGET (in), TRUE);
                input_assign_text (in, status_format[r->sel]);
            }
            /* input_update (in, FALSE); */
            return MSG_HANDLED;
        }

        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Beispiel #23
0
/*---------------------------------------------------------
 Function: menu

 Description:
 Build and manage menu.
 mode : Menu mode (MAINMENU or SHOPMENU).
 p    : Build menu for PLAYER p. (Especially important for SHOPMENU)
---------------------------------------------------------*/
int menu(int mode, int p)
{
   int      dx, dy, db;    // Accumulated cursor coordinates.
	int		mb;
   int      joy_x, joy_y, joy_fire; // Joystick values.
   int      x, y, b;       // Mouse coordinates.
   int      request;
   static   int key_allowed;

   Uint32 startTime = 0;

// Initialize menu system.
   nowplayer = p;
   initmenu();
   nowmenu = 0;            // No menu active at the moment.
   strcpy(shopmenu[0].text, p ? "PLAYER 2" : "PLAYER 1");
   switch (mode) {
      case MAINMENU:  buildmenu(mainmenu); break;
      case SOUNDMENU: buildmenu(soundmenu); break;
      case SHOPMENU:  buildmenu(shopmenu); break;
   }

// Initialize some variables.
   joy_x = joy_y = joy_fire = 0;

// Initialize "checkmenu".
   checkmenu(-1, 0, 0);

   x = MENUX + MENUXS/2;
   y = MENUY + MENUYS/2;
   do {
      startTime = SDL_GetTicks();
      demo();

// Restore mouse pointer background.
      dx = dy = mb = b = 0;
      input_update();

      if (joypad) {
         getjoypad(joy_x, joy_y, joy_fire);
         x += joy_x*4; y += joy_y*4; b += joy_fire;
      }
      getkeyboard(dx, dy, db); x += dx*4; y += dy*4; b += db;

      if (mouse && !(dx || dy)) {
            getmouse(dx, dy, mb);

            if((dx || dy))
                getmousexy(mb, x, y);
				
				b += mb;
      }

      testlimits(x, y);
      //if (mouse) setmousexy(x, y);
        back->restore();
// Process events.
         if (!keys) key_allowed = 1;
         if (!keys_enabled) key_released = 0;
// Send KEY PRESSED message to menu.
         if (!keys && key_released && key_released!=KEY_ESC) {
            if (nowmenu[0].action) nowmenu[0].action(M_KEY, key_released);
            key_released = 0;
         }
// Send joypad messages.
         if (joy_enabled && button_released != -1) {
            if (nowmenu[0].action) nowmenu[0].action(M_JOYPAD, button_released);
         }

// Send mouse messages.
         if (pointer_enabled) {
            if (request = checkmenu(b, x, y)) break;
         }
// Build backoff menu if ESC has been pressed.
         if (key_allowed && key[KEY_ESC] && backoff) {
            buildmenu(backoff);
            key_allowed = 0;
				escape_wait();
         }


         back->save(x, y);

// Copy demo display to restricted area of screen
        render.drawTexture(&demoTexture, BORDER, 0, 16, 0, 4*32 + 16, YMAX);
// Restore title logo.
        render.x_drawsprite(&sHead, 100, 12, 0);

        if (pointer_enabled) render.x_drawsprite(&sPointer, x, y, 0);

      render.update();

        while(SDL_GetTicks() - startTime < 32)
        {
            SDL_Delay(1);
        }

   } while (!quit_requested);

   destroymenu();
// Shut down menu system.
   shutmenu();
   return quit_requested ? M_QUIT : request;
}
Beispiel #24
0
inputdatabattle input_battle() // Runs during battle gamephase
{
	// Temp Variables
	inputdatabattle d;
	static int lastcx;
	static int lastcy;

	// Lock Mutex
	thread_lockinputmutex();

	// Update Input Variables
	input_update();


	// Booleans
	d.forward = in_keyhold[SDLK_w];
	d.back = in_keyhold[SDLK_s];
	d.left = in_keyhold[SDLK_a];
	d.right = in_keyhold[SDLK_d];
	d.up = in_keyhold[SDLK_SPACE];
	d.down = in_keyhold[SDLK_c];
	d.triggerpress = in_leftmousepress;
	d.triggerhold = in_leftmousehold;

	// Weapon Change
	d.gunchange = -1;
	if(in_keypress[SDLK_5]) d.gunchange = 4;
	if(in_keypress[SDLK_4]) d.gunchange = 3;
	if(in_keypress[SDLK_3]) d.gunchange = 2;
	if(in_keypress[SDLK_2]) d.gunchange = 1;
	if(in_keypress[SDLK_1]) d.gunchange = 0;

	// Ammo Change
	d.ammochange = in_deltamousewheel;

	// Cam/chasis Rotate
	//if(in_keyhold[SDLK_f])
	if(in_rightmousehold)
	{
		// dx/y : percentage of a half windowsquare that the mouse has moved
		intv dx = (in_cursorx-lastcx)*UPM/(g_windowsquare/2);
		intv dy = (in_cursory-lastcy)*UPM/(g_windowsquare/2);
		d.rotatex=VMV(VMV(2*UMV(dx,g_viewangletangent),-PI2),ROTATEMOD);
		d.rotatey=VMV(VMV(2*UMV(dy,g_viewangletangent),-PI2),ROTATEMOD);
	}
	else
	{
		d.rotatex = 0;
		d.rotatey = 0;
	}

	// Aim Vector (in relation to cam/chasis)
	d.aimx = (in_cursorx-g_windowwidth/2)*UPM/(g_windowsquare/2);
	d.aimy = (g_windowheight/2-in_cursory)*UPM/(g_windowsquare/2);
	d.aimz = 1*UPM;
	d.aimlx = (lastcx-g_windowwidth/2)*UPM/(g_windowsquare/2);
	d.aimly = (g_windowheight/2-lastcy)*UPM/(g_windowsquare/2);

	lastcx = in_cursorx;
	lastcy = in_cursory;

	// Test
	d.testpress = in_keypress[SDLK_t];
	d.testpress2 = in_keypress[SDLK_y];
	if(d.testpress2) DEBUGON^=1;

	// Reset Press Variables
	input_reset();

	// Unlock Mutex
	thread_unlockinputmutex();


	return d;
}
Beispiel #25
0
int main(int argc, char * argv[])
{
	input_init();

	std::string path_to_exe("");
	{
		std::string path_with_exe(argv[0]);
		unsigned found = path_with_exe.find_last_of("/\\");
		path_to_exe = path_with_exe.substr(0,found+1);
	}

	std::cout<<path_to_exe<<std::endl;
	SDL_Init( SDL_INIT_EVERYTHING );
	TTF_Init();
	SDL_Surface * screen = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE);
	GUI_Init(screen);

	{
		std::string font_path(path_to_exe);
		font_path += "freefont/FreeMono.ttf";
		GUI_standard_font = TTF_OpenFont( font_path.c_str(), 15 );
	}

	std::cout<<"fontptr: "<<GUI_standard_font<<std::endl;


	Area * screen_widget = new Area(0, 0, 640, 480);

	Area * test_widget = new Area(20, 20, 200, 200, screen_widget);
	test_widget->set_colour(200, 100, 100);

	Area * another_test_widget = new Area(240, 20, 200, 200, screen_widget);
	another_test_widget->set_colour(100, 200, 100);

	Area * ultra_test_widget = new Area(20, 20, 160, 160, another_test_widget);
	ultra_test_widget->set_colour(100, 100, 200);

	Label * test_label = new Label(10, 10, 140, 20, ultra_test_widget);
	test_label->set_colour(120, 120, 220);
	test_label->set_text("Hallo Welt!");



	Button * test_button = new Button(10, 40, 120, 20, ultra_test_widget);
	test_button->set_colour(100, 200, 200);
	test_button->set_text("Test!");

	Button * end_button = new Button(20, 240, 120, 20, screen_widget);
	end_button->set_colour(255, 0, 0);
	end_button->set_text("Ende!");




	Text_Edit * text_edit = new Text_Edit(20, 280, 160, 20, screen_widget);
	text_edit->set_text("aender mich!");



	input_update();
	while(!key_hit(SDLK_ESCAPE) && !end_button->released)// && !mouse_hit(1))
	{
		SDL_Surface * screen_surface = screen_widget->get_sdl_surface();	
		SDL_BlitSurface(screen_surface, NULL, screen, NULL);

		screen_widget->update();
		if(test_button->released)
		{
			test_label->set_text("Button geklickt!");
		}
		SDL_Flip(screen);
		flush_keys();
		flush_mouse();
		SDL_Delay(1000/60);
		input_update();
	}

	//SDL_Delay(2000);

	return 0;
}
Beispiel #26
0
/*
 * SDL_main
 * Program entry point.
 */
int main(int argc, char* argv[])
{
	size = 32;
	srand(time(NULL));
	SDL_Event	event;
	SDL_Surface	*screen;

	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
	{
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}

	SDL_WM_SetCaption("Camera Demo", "Camera Demo");
	SDL_ShowCursor(SDL_DISABLE);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL);
	if(!screen)
	{
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}

	r_init();

	float t = 0.0f;
	float dt = 0.1f;

	float currentTime = 0.0f;
	float accumulator = 0.0f;

	while(!user_exit)
	{
		if (won) {
			r_init();
		}
		float newTime = time(0);
		float deltaTime = newTime - currentTime;
		currentTime = newTime;

		if (deltaTime>0.25f)
			deltaTime = 0.25f;

		accumulator += deltaTime;

		while (accumulator>=dt)
		{
			accumulator -= dt;
			t += dt;
		}

		//Handle input
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_KEYDOWN:
				input_keyDown(event.key.keysym.sym);
				break;
			case SDL_KEYUP:
				input_keyUp(event.key.keysym.sym);
				break;
			case SDL_MOUSEMOTION:
				input_mouseMove(event.motion.x, event.motion.y);
				break;
			case SDL_QUIT:
				user_exit = 1;
			}
		}

		input_update();

		r_drawFrame();
	}

	SDL_Quit();
	return 0;
}