Esempio n. 1
0
void input_set_item(SDL_Event event, int type, int pnum, int counter) {
	
	#ifdef _GTK
	gtkui_config_input_focus(counter);
	#endif
	
	if (type == 0) { // Keyboard
		switch(counter) {
			case 0: player[pnum].u = event.key.keysym.scancode; break;
			case 1: player[pnum].d = event.key.keysym.scancode; break;
			case 2: player[pnum].l = event.key.keysym.scancode; break;
			case 3: player[pnum].r = event.key.keysym.scancode; break;
			case 4: player[pnum].select = event.key.keysym.scancode; break;
			case 5: player[pnum].start = event.key.keysym.scancode; break;
			case 6: player[pnum].a = event.key.keysym.scancode; break;
			case 7: player[pnum].b = event.key.keysym.scancode; break;
			case 8: player[pnum].ta = event.key.keysym.scancode; break;
			case 9: player[pnum].tb = event.key.keysym.scancode; break;
			default: break;
		}
	}
	else if (type == 1) { // Joystick
		switch(counter) {
			case 0: player[pnum].ju = input_translate_string(input_translate_event(event)); break;
			case 1: player[pnum].jd = input_translate_string(input_translate_event(event)); break;
			case 2: player[pnum].jl = input_translate_string(input_translate_event(event)); break;
			case 3: player[pnum].jr = input_translate_string(input_translate_event(event)); break;
			case 4: player[pnum].jselect = input_translate_string(input_translate_event(event)); break;
			case 5: player[pnum].jstart = input_translate_string(input_translate_event(event)); break;
			case 6: player[pnum].ja = input_translate_string(input_translate_event(event)); break;
			case 7: player[pnum].jb = input_translate_string(input_translate_event(event)); break;
			case 8: player[pnum].jta = input_translate_string(input_translate_event(event)); break;
			case 9: player[pnum].jtb = input_translate_string(input_translate_event(event)); break;
			default: break;
		}
	}
	#ifdef _GTK
	gtkui_config_input_fields(type, pnum);
	#endif
}
Esempio n. 2
0
void input_config_write() {
    // Write out the input configuration file

    FILE *fp = fopen(inputconfpath, "w");
    if (fp != NULL)	{
        fprintf(fp, "; Nestopia UE Input Configuration File\n\n");
        fprintf(fp, "; Possible values for keyboard input are in the Key Name column:\n; https://wiki.libsdl.org/SDL_Scancode\n\n");
        fprintf(fp, "; Possible values for joystick input:\n; j[joystick number][a|b|h][button/hat/axis number][1/0 = +/- (axes only)]\n");
        fprintf(fp, "; Example: j0b3 = joystick 0, button 3. j1a11 = joystick 1, axis 1 +\n\n");

        fprintf(fp, "[ui]\n");
        fprintf(fp, "qsave1=%s\n", SDL_GetScancodeName(ui.qsave1));
        fprintf(fp, "qsave2=%s\n", SDL_GetScancodeName(ui.qsave2));
        fprintf(fp, "qload1=%s\n", SDL_GetScancodeName(ui.qload1));
        fprintf(fp, "qload2=%s\n", SDL_GetScancodeName(ui.qload2));

        fprintf(fp, "screenshot=%s\n", SDL_GetScancodeName(ui.screenshot));

        fprintf(fp, "fdsflip=%s\n", SDL_GetScancodeName(ui.fdsflip));
        fprintf(fp, "fdsswitch=%s\n", SDL_GetScancodeName(ui.fdsswitch));

        fprintf(fp, "insertcoin1=%s\n", SDL_GetScancodeName(ui.insertcoin1));
        fprintf(fp, "insertcoin2=%s\n", SDL_GetScancodeName(ui.insertcoin2));

        fprintf(fp, "reset=%s\n", SDL_GetScancodeName(ui.reset));

        fprintf(fp, "altspeed=%s\n", SDL_GetScancodeName(ui.altspeed));
        fprintf(fp, "rwstart=%s\n", SDL_GetScancodeName(ui.rwstart));
        fprintf(fp, "rwstop=%s\n", SDL_GetScancodeName(ui.rwstop));

        fprintf(fp, "fullscreen=%s\n", SDL_GetScancodeName(ui.fullscreen));
        fprintf(fp, "filter=%s\n", SDL_GetScancodeName(ui.filter));
        fprintf(fp, "scalefactor=%s\n", SDL_GetScancodeName(ui.scalefactor));
        fprintf(fp, "\n"); // End of Section

        fprintf(fp, "[gamepad1]\n");
        fprintf(fp, "kb_u=%s\n", SDL_GetScancodeName(player[0].u));
        fprintf(fp, "kb_d=%s\n", SDL_GetScancodeName(player[0].d));
        fprintf(fp, "kb_l=%s\n", SDL_GetScancodeName(player[0].l));
        fprintf(fp, "kb_r=%s\n", SDL_GetScancodeName(player[0].r));
        fprintf(fp, "kb_select=%s\n", SDL_GetScancodeName(player[0].select));
        fprintf(fp, "kb_start=%s\n", SDL_GetScancodeName(player[0].start));
        fprintf(fp, "kb_a=%s\n", SDL_GetScancodeName(player[0].a));
        fprintf(fp, "kb_b=%s\n", SDL_GetScancodeName(player[0].b));
        fprintf(fp, "kb_ta=%s\n", SDL_GetScancodeName(player[0].ta));
        fprintf(fp, "kb_tb=%s\n", SDL_GetScancodeName(player[0].tb));

        fprintf(fp, "js_u=%s\n", input_translate_event(player[0].ju));
        fprintf(fp, "js_d=%s\n", input_translate_event(player[0].jd));
        fprintf(fp, "js_l=%s\n", input_translate_event(player[0].jl));
        fprintf(fp, "js_r=%s\n", input_translate_event(player[0].jr));
        fprintf(fp, "js_select=%s\n", input_translate_event(player[0].jselect));
        fprintf(fp, "js_start=%s\n", input_translate_event(player[0].jstart));
        fprintf(fp, "js_a=%s\n", input_translate_event(player[0].ja));
        fprintf(fp, "js_b=%s\n", input_translate_event(player[0].jb));
        fprintf(fp, "js_ta=%s\n", input_translate_event(player[0].jta));
        fprintf(fp, "js_tb=%s\n", input_translate_event(player[0].jtb));
        fprintf(fp, "\n"); // End of Section

        fprintf(fp, "[gamepad2]\n");
        fprintf(fp, "kb_u=%s\n", SDL_GetScancodeName(player[1].u));
        fprintf(fp, "kb_d=%s\n", SDL_GetScancodeName(player[1].d));
        fprintf(fp, "kb_l=%s\n", SDL_GetScancodeName(player[1].l));
        fprintf(fp, "kb_r=%s\n", SDL_GetScancodeName(player[1].r));
        fprintf(fp, "kb_select=%s\n", SDL_GetScancodeName(player[1].select));
        fprintf(fp, "kb_start=%s\n", SDL_GetScancodeName(player[1].start));
        fprintf(fp, "kb_a=%s\n", SDL_GetScancodeName(player[1].a));
        fprintf(fp, "kb_b=%s\n", SDL_GetScancodeName(player[1].b));
        fprintf(fp, "kb_ta=%s\n", SDL_GetScancodeName(player[1].ta));
        fprintf(fp, "kb_tb=%s\n", SDL_GetScancodeName(player[1].tb));

        fprintf(fp, "js_u=%s\n", input_translate_event(player[1].ju));
        fprintf(fp, "js_d=%s\n", input_translate_event(player[1].jd));
        fprintf(fp, "js_l=%s\n", input_translate_event(player[1].jl));
        fprintf(fp, "js_r=%s\n", input_translate_event(player[1].jr));
        fprintf(fp, "js_select=%s\n", input_translate_event(player[1].jselect));
        fprintf(fp, "js_start=%s\n", input_translate_event(player[1].jstart));
        fprintf(fp, "js_a=%s\n", input_translate_event(player[1].ja));
        fprintf(fp, "js_b=%s\n", input_translate_event(player[1].jb));
        fprintf(fp, "js_ta=%s\n", input_translate_event(player[1].jta));
        fprintf(fp, "js_tb=%s\n", input_translate_event(player[1].jtb));
        fprintf(fp, "\n"); // End of Section

        fclose(fp);
    }
}
Esempio n. 3
0
void input_config_write() {
	// Write out the input configuration file
	
	FILE *fp = fopen(inputconfpath, "w");
	if (fp != NULL)	{
		fprintf(fp, "[gamepad1]\n");
		fprintf(fp, "kb_u=%s\n", SDL_GetScancodeName(player[0].u));
		fprintf(fp, "kb_d=%s\n", SDL_GetScancodeName(player[0].d));
		fprintf(fp, "kb_l=%s\n", SDL_GetScancodeName(player[0].l));
		fprintf(fp, "kb_r=%s\n", SDL_GetScancodeName(player[0].r));
		fprintf(fp, "kb_select=%s\n", SDL_GetScancodeName(player[0].select));
		fprintf(fp, "kb_start=%s\n", SDL_GetScancodeName(player[0].start));
		fprintf(fp, "kb_a=%s\n", SDL_GetScancodeName(player[0].a));
		fprintf(fp, "kb_b=%s\n", SDL_GetScancodeName(player[0].b));
		fprintf(fp, "kb_ta=%s\n", SDL_GetScancodeName(player[0].ta));
		fprintf(fp, "kb_tb=%s\n", SDL_GetScancodeName(player[0].tb));
		
		fprintf(fp, "js_u=%s\n", input_translate_event(player[0].ju));
		fprintf(fp, "js_d=%s\n", input_translate_event(player[0].jd));
		fprintf(fp, "js_l=%s\n", input_translate_event(player[0].jl));
		fprintf(fp, "js_r=%s\n", input_translate_event(player[0].jr));
		fprintf(fp, "js_select=%s\n", input_translate_event(player[0].jselect));
		fprintf(fp, "js_start=%s\n", input_translate_event(player[0].jstart));
		fprintf(fp, "js_a=%s\n", input_translate_event(player[0].ja));
		fprintf(fp, "js_b=%s\n", input_translate_event(player[0].jb));
		fprintf(fp, "js_ta=%s\n", input_translate_event(player[0].jta));
		fprintf(fp, "js_tb=%s\n", input_translate_event(player[0].jtb));
		fprintf(fp, "\n"); // End of Section
		
		fprintf(fp, "[gamepad2]\n");
		fprintf(fp, "kb_u=%s\n", SDL_GetScancodeName(player[1].u));
		fprintf(fp, "kb_d=%s\n", SDL_GetScancodeName(player[1].d));
		fprintf(fp, "kb_l=%s\n", SDL_GetScancodeName(player[1].l));
		fprintf(fp, "kb_r=%s\n", SDL_GetScancodeName(player[1].r));
		fprintf(fp, "kb_select=%s\n", SDL_GetScancodeName(player[1].select));
		fprintf(fp, "kb_start=%s\n", SDL_GetScancodeName(player[1].start));
		fprintf(fp, "kb_a=%s\n", SDL_GetScancodeName(player[1].a));
		fprintf(fp, "kb_b=%s\n", SDL_GetScancodeName(player[1].b));
		fprintf(fp, "kb_ta=%s\n", SDL_GetScancodeName(player[1].ta));
		fprintf(fp, "kb_tb=%s\n", SDL_GetScancodeName(player[1].tb));
		
		fprintf(fp, "js_u=%s\n", input_translate_event(player[1].ju));
		fprintf(fp, "js_d=%s\n", input_translate_event(player[1].jd));
		fprintf(fp, "js_l=%s\n", input_translate_event(player[1].jl));
		fprintf(fp, "js_r=%s\n", input_translate_event(player[1].jr));
		fprintf(fp, "js_select=%s\n", input_translate_event(player[1].jselect));
		fprintf(fp, "js_start=%s\n", input_translate_event(player[1].jstart));
		fprintf(fp, "js_a=%s\n", input_translate_event(player[1].ja));
		fprintf(fp, "js_b=%s\n", input_translate_event(player[1].jb));
		fprintf(fp, "js_ta=%s\n", input_translate_event(player[1].jta));
		fprintf(fp, "js_tb=%s\n", input_translate_event(player[1].jtb));
		fprintf(fp, "\n"); // End of Section
		
		fclose(fp);
	}
}
Esempio n. 4
0
void input_set_item(SDL_Event event, int type, int pnum, int counter) {
    // Set an input item to what was requested by configuration process
    if (type == 0) { // Keyboard
        switch(counter) {
        case 0:
            player[pnum].u = event.key.keysym.scancode;
            break;
        case 1:
            player[pnum].d = event.key.keysym.scancode;
            break;
        case 2:
            player[pnum].l = event.key.keysym.scancode;
            break;
        case 3:
            player[pnum].r = event.key.keysym.scancode;
            break;
        case 4:
            player[pnum].select = event.key.keysym.scancode;
            break;
        case 5:
            player[pnum].start = event.key.keysym.scancode;
            break;
        case 6:
            player[pnum].a = event.key.keysym.scancode;
            break;
        case 7:
            player[pnum].b = event.key.keysym.scancode;
            break;
        case 8:
            player[pnum].ta = event.key.keysym.scancode;
            break;
        case 9:
            player[pnum].tb = event.key.keysym.scancode;
            break;
        default:
            break;
        }
    }
    else if (type == 1) { // Joystick
        switch(counter) {
        case 0:
            player[pnum].ju = input_translate_string(input_translate_event(event));
            break;
        case 1:
            player[pnum].jd = input_translate_string(input_translate_event(event));
            break;
        case 2:
            player[pnum].jl = input_translate_string(input_translate_event(event));
            break;
        case 3:
            player[pnum].jr = input_translate_string(input_translate_event(event));
            break;
        case 4:
            player[pnum].jselect = input_translate_string(input_translate_event(event));
            break;
        case 5:
            player[pnum].jstart = input_translate_string(input_translate_event(event));
            break;
        case 6:
            player[pnum].ja = input_translate_string(input_translate_event(event));
            break;
        case 7:
            player[pnum].jb = input_translate_string(input_translate_event(event));
            break;
        case 8:
            player[pnum].jta = input_translate_string(input_translate_event(event));
            break;
        case 9:
            player[pnum].jtb = input_translate_string(input_translate_event(event));
            break;
        default:
            break;
        }
    }
}