+ 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;
+ // wait until select is released, so menu would not resume game
+ while (Framework_PollGetButtons() & BTN_HOME) Sleep(50);
+ }
+
+ 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;
+ /* TODO 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) {
+ int vol = currentConfig.volume;
+ if (events & 0x2000) {
+ if (vol < 100) vol++;
+ } else {
+ if (vol > 0) vol--;
+ }
+ //gp2x_sound_volume(vol, vol);
+ sprintf(noticeMsg, "VOL: %02i", vol);
+ noticeMsgTime = GetTickCount();
+ currentConfig.volume = vol;
+ }
+
+ events &= ~prevEvents;
+ //if (events) RunEvents(events); // TODO
+ if (movie_data) emu_updateMovie();
+
+ prevEvents = (allActions[0] | allActions[1]) >> 16;