+ unsigned int keys, allActions[2] = { 0, 0 }, events;
+ static unsigned int prevEvents = 0;
+ int i;
+
+ keys = Framework_PollGetButtons();
+ if (keys & BTN_HOME)
+ engineState = PGS_Menu;
+
+ keys &= CONFIGURABLE_KEYS;
+
+ for (i = 0; i < 32; i++)
+ {
+ if (keys & (1 << i))
+ {
+ int pl, acts = currentConfig.KeyBinds[i];
+ if (!acts) continue;
+ pl = (acts >> 16) & 1;
+ if (combo_keys & (1 << i))
+ {
+ int u = i+1, acts_c = acts & combo_acts;
+ // let's try to find the other one
+ if (acts_c)
+ for (; u < 32; u++)
+ if ( (currentConfig.KeyBinds[u] & acts_c) && (keys & (1 << u)) ) {
+ allActions[pl] |= acts_c;
+ keys &= ~((1 << i) | (1 << u));
+ break;
+ }
+ // add non-combo actions if combo ones were not found
+ if (!acts_c || u == 32)
+ allActions[pl] |= acts & ~combo_acts;
+ } else {
+ allActions[pl] |= acts;
+ }
+ }
+ }
+
+ PicoPad[0] = (unsigned short) allActions[0];
+ PicoPad[1] = (unsigned short) allActions[1];
+
+ events = (allActions[0] | allActions[1]) >> 16;
+
+ // volume is treated in special way and triggered every frame
+ if ((events & 0x6000) && PsndOut != NULL)
+ {
+ int vol = currentConfig.volume;
+ if (events & 0x2000) {
+ if (vol < 100) vol++;
+ } else {
+ if (vol > 0) vol--;
+ }
+ FrameworkAudio_SetVolume(vol, vol);
+ sprintf(noticeMsg, "VOL: %02i ", vol);
+ noticeMsgTime = GetTickCount();
+ currentConfig.volume = vol;
+ }
+
+ events &= ~prevEvents;
+ if (events) RunEvents(events);
+ if (movie_data) emu_updateMovie();
+
+ prevEvents = (allActions[0] | allActions[1]) >> 16;
+}
+
+static void find_combos(void)
+{
+ int act, u;
+
+ // find out which keys and actions are combos
+ combo_keys = combo_acts = 0;
+ for (act = 0; act < 32; act++)
+ {
+ int keyc = 0, keyc2 = 0;
+ if (act == 16 || act == 17) continue; // player2 flag
+ if (act > 17)
+ {
+ for (u = 0; u < 32; u++)
+ if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;
+ }
+ else
+ {
+ for (u = 0; u < 32; u++)
+ if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1
+ (currentConfig.KeyBinds[u] & (1 << act))) keyc++;
+ for (u = 0; u < 32; u++)
+ if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2
+ (currentConfig.KeyBinds[u] & (1 << act))) keyc2++;
+ if (keyc2 > keyc) keyc = keyc2;
+ }
+ if (keyc > 1)
+ {
+ // loop again and mark those keys and actions as combo
+ for (u = 0; u < 32; u++)
+ {
+ if (currentConfig.KeyBinds[u] & (1 << act)) {
+ combo_keys |= 1 << u;
+ combo_acts |= 1 << act;
+ }
+ }
+ }
+ }