mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 06:47:45 -04:00
key combos for new input code
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@690 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
f15ca4db35
commit
2c60056042
12 changed files with 128 additions and 136 deletions
33
gp2x/emu.c
33
gp2x/emu.c
|
@ -575,38 +575,8 @@ static void updateKeys(void)
|
|||
keys &= CONFIGURABLE_KEYS;
|
||||
keys2 = keys;
|
||||
|
||||
#if 1
|
||||
/* FIXME: combos, player2 */
|
||||
/* FIXME: player2 */
|
||||
allActions[0] = in_update();
|
||||
#else
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (keys2 & (1 << i))
|
||||
{
|
||||
int pl, acts = currentConfig.KeyBinds[i];
|
||||
if (!acts) continue;
|
||||
pl = (acts >> 16) & 1;
|
||||
if (kb_combo_keys & (1 << i))
|
||||
{
|
||||
int u = i+1, acts_c = acts & kb_combo_acts;
|
||||
// let's try to find the other one
|
||||
if (acts_c) {
|
||||
for (; u < 32; u++)
|
||||
if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {
|
||||
allActions[pl] |= acts_c & currentConfig.KeyBinds[u];
|
||||
keys2 &= ~((1 << i) | (1 << u));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// add non-combo actions if combo ones were not found
|
||||
if (!acts_c || u == 32)
|
||||
allActions[pl] |= acts & ~kb_combo_acts;
|
||||
} else {
|
||||
allActions[pl] |= acts;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PicoPad[0] = allActions[0] & 0xfff;
|
||||
PicoPad[1] = allActions[1] & 0xfff;
|
||||
|
@ -834,7 +804,6 @@ void emu_Loop(void)
|
|||
scaling_update();
|
||||
Pico.m.dirtyPal = 1;
|
||||
oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc;
|
||||
emu_findKeyBindCombos();
|
||||
|
||||
// pal/ntsc might have changed, reset related stuff
|
||||
target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#define IN_PREFIX "gp2x:"
|
||||
#define IN_GP2X_NBUTTONS 32
|
||||
|
||||
/* note: in_gp2x hadles combos (if 2 btns have the same bind,
|
||||
* both must be pressed for action to happen) */
|
||||
static int in_gp2x_combo_keys = 0;
|
||||
static int in_gp2x_combo_acts = 0;
|
||||
|
||||
extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */
|
||||
|
||||
enum { BTN_UP = 0, BTN_LEFT = 2, BTN_DOWN = 4, BTN_RIGHT = 6,
|
||||
|
@ -28,7 +33,7 @@ static const char * const in_gp2x_keys[IN_GP2X_NBUTTONS] = {
|
|||
|
||||
static void in_gp2x_probe(void)
|
||||
{
|
||||
in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1);
|
||||
in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1, 1);
|
||||
}
|
||||
|
||||
static int in_gp2x_get_bind_count(void)
|
||||
|
@ -59,14 +64,17 @@ static int in_gp2x_get_gpio_bits(void)
|
|||
/* returns bitfield of binds of pressed buttons */
|
||||
int in_gp2x_update(void *drv_data, int *binds)
|
||||
{
|
||||
int i, value, ret = 0;
|
||||
int i, keys, ret = 0;
|
||||
|
||||
value = in_gp2x_get_gpio_bits();
|
||||
keys = in_gp2x_get_gpio_bits();
|
||||
|
||||
for (i = 0; value; i++) {
|
||||
if (value & 1)
|
||||
if (keys & in_gp2x_combo_keys)
|
||||
return in_combos_do(keys, binds, BTN_PUSH, in_gp2x_combo_keys, in_gp2x_combo_acts);
|
||||
|
||||
for (i = 0; keys; i++) {
|
||||
if (keys & 1)
|
||||
ret |= binds[i];
|
||||
value >>= 1;
|
||||
keys >>= 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -172,6 +180,8 @@ static int in_gp2x_clean_binds(void *drv_data, int *binds)
|
|||
count++;
|
||||
}
|
||||
|
||||
in_combos_find(binds, BTN_PUSH, &in_gp2x_combo_keys, &in_gp2x_combo_acts);
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
@ -180,6 +190,8 @@ void in_gp2x_init(void *vdrv)
|
|||
{
|
||||
in_drv_t *drv = vdrv;
|
||||
|
||||
in_gp2x_combo_keys = in_gp2x_combo_acts = 0;
|
||||
|
||||
drv->prefix = in_gp2x_prefix;
|
||||
drv->probe = in_gp2x_probe;
|
||||
drv->get_bind_count = in_gp2x_get_bind_count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue