Example #1
0
/* remove binds of missing keys, count remaining ones */
static int in_gp2x_clean_binds(void *drv_data, int *binds, int *def_binds)
{
	int i, count = 0;
//	int eb, have_vol = 0, have_menu = 0;

	for (i = 0; i < IN_GP2X_NBUTTONS; i++) {
		int t, offs;
		for (t = 0; t < IN_BINDTYPE_COUNT; t++) {
			offs = IN_BIND_OFFS(i, t);
			if (in_gp2x_keys[i] == NULL)
				binds[offs] = def_binds[offs] = 0;
			if (binds[offs])
				count++;
		}
#if 0
		eb = binds[IN_BIND_OFFS(i, IN_BINDTYPE_EMU)];
		if (eb & (PEV_VOL_DOWN|PEV_VOL_UP))
			have_vol = 1;
		if (eb & PEV_MENU)
			have_menu = 1;
#endif
	}

	// TODO: move to pico
#if 0
	/* autobind some important keys, if they are unbound */
	if (!have_vol && binds[GP2X_BTN_VOL_UP] == 0 && binds[GP2X_BTN_VOL_DOWN] == 0) {
		binds[IN_BIND_OFFS(GP2X_BTN_VOL_UP, IN_BINDTYPE_EMU)]   = PEV_VOL_UP;
		binds[IN_BIND_OFFS(GP2X_BTN_VOL_DOWN, IN_BINDTYPE_EMU)] = PEV_VOL_DOWN;
		count += 2;
	}

	if (!have_menu) {
		binds[IN_BIND_OFFS(GP2X_BTN_SELECT, IN_BINDTYPE_EMU)] = PEV_MENU;
		count++;
	}
#endif

	in_combos_find(binds, GP2X_BTN_PUSH, &in_gp2x_combo_keys, &in_gp2x_combo_acts);

	return count;
}
Example #2
0
static int in_tsbutton_update(void *drv_data, const int *binds, int *result)
{
	int ret, t;
	
	ret = update_button();
	if (ret != 0)
		return ret;

	if (tsbutton_down_id >= 0)
		for (t = 0; t < IN_BINDTYPE_COUNT; t++)
			result[t] |= binds[IN_BIND_OFFS(tsbutton_down_id, t)];

	return 0;
}
Example #3
0
/* ORs result with pressed buttons */
static int in_gp2x_update(void *drv_data, const int *binds, int *result)
{
	int type_start = 0;
	int i, t, keys;

	keys = in_gp2x_get_bits();

	if (keys & in_gp2x_combo_keys) {
		result[IN_BINDTYPE_EMU] = in_combos_do(keys, binds, GP2X_BTN_PUSH,
						in_gp2x_combo_keys, in_gp2x_combo_acts);
		type_start = IN_BINDTYPE_PLAYER12;
	}

	for (i = 0; keys; i++, keys >>= 1) {
		if (!(keys & 1))
			continue;

		for (t = type_start; t < IN_BINDTYPE_COUNT; t++)
			result[t] |= binds[IN_BIND_OFFS(i, t)];
	}

	return 0;
}
Example #4
0
static int in_sdl_update(void *drv_data, const int *binds, int *result)
{
	struct in_sdl_state *state = drv_data;
	keybits_t mask;
	int i, sym, bit, b;

	collect_events(state, NULL, NULL);

	for (i = 0; i < SDLK_LAST / KEYBITS_WORD_BITS + 1; i++) {
		mask = state->keystate[i];
		if (mask == 0)
			continue;
		for (bit = 0; mask != 0; bit++, mask >>= 1) {
			if ((mask & 1) == 0)
				continue;
			sym = i * KEYBITS_WORD_BITS + bit;

			for (b = 0; b < IN_BINDTYPE_COUNT; b++)
				result[b] |= binds[IN_BIND_OFFS(sym, b)];
		}
	}

	return 0;
}