-static void updateKeys(void)\r
-{\r
- unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;\r
- static unsigned int prevEvents = 0;\r
- int joy, i;\r
-\r
- keys = gp2x_joystick_read(0);\r
- if (keys & GP2X_SELECT) {\r
- engineState = select_exits ? PGS_Quit : PGS_Menu;\r
- // wait until select is released, so menu would not resume game\r
- while (gp2x_joystick_read(1) & GP2X_SELECT) usleep(50*1000);\r
- }\r
-\r
- keys &= CONFIGURABLE_KEYS;\r
- keys2 = keys;\r
-\r
- for (i = 0; i < 32; i++)\r
- {\r
- if (keys2 & (1 << i))\r
- {\r
- int pl, acts = currentConfig.KeyBinds[i];\r
- if (!acts) continue;\r
- pl = (acts >> 16) & 1;\r
- if (kb_combo_keys & (1 << i))\r
- {\r
- int u = i+1, acts_c = acts & kb_combo_acts;\r
- // let's try to find the other one\r
- if (acts_c) {\r
- for (; u < 32; u++)\r
- if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {\r
- allActions[pl] |= acts_c & currentConfig.KeyBinds[u];\r
- keys2 &= ~((1 << i) | (1 << u));\r
- break;\r
- }\r
- }\r
- // add non-combo actions if combo ones were not found\r
- if (!acts_c || u == 32)\r
- allActions[pl] |= acts & ~kb_combo_acts;\r
- } else {\r
- allActions[pl] |= acts;\r
- }\r
- }\r
- }\r
-\r
- // add joy inputs\r
- if (num_of_joys > 0)\r
- {\r
- gp2x_usbjoy_update();\r
- for (joy = 0; joy < num_of_joys; joy++) {\r
- int btns = gp2x_usbjoy_check2(joy);\r
- for (i = 0; i < 32; i++) {\r
- if (btns & (1 << i)) {\r
- int acts = currentConfig.JoyBinds[joy][i];\r
- int pl = (acts >> 16) & 1;\r
- allActions[pl] |= acts;\r
- }\r
- }\r
- }\r
- }\r
-\r
- PicoPad[0] = allActions[0] & 0xfff;\r
- PicoPad[1] = allActions[1] & 0xfff;\r
-\r
- if (allActions[0] & 0x7000) emu_DoTurbo(&PicoPad[0], allActions[0]);\r
- if (allActions[1] & 0x7000) emu_DoTurbo(&PicoPad[1], allActions[1]);\r
-\r
- events = (allActions[0] | allActions[1]) >> 16;\r
-\r
- // volume is treated in special way and triggered every frame\r
- if (events & 0x6000)\r
- update_volume(1, events & 0x2000);\r
-\r
- if ((events ^ prevEvents) & 0x40) {\r
- emu_changeFastForward(events & 0x40);\r
- update_volume(0, 0);\r
- reset_timing = 1;\r
- }\r
-\r
- events &= ~prevEvents;\r
-\r
- if (PicoAHW == PAHW_PICO)\r
- RunEventsPico(events, keys);\r
- if (events) RunEvents(events);\r
- if (movie_data) emu_updateMovie();\r
-\r
- prevEvents = (allActions[0] | allActions[1]) >> 16;\r
-}\r
-\r
-\r
-static void updateSound(int len)\r
-{\r
- if (PicoOpt&8) len<<=1;\r
-\r
- /* avoid writing audio when lagging behind to prevent audio lag */\r
- if (PicoSkipFrame != 2)\r
- gp2x_sound_write(PsndOut, len<<1);\r
-}\r
-\r
-\r
-static void SkipFrame(int do_audio)\r
-{\r
- PicoSkipFrame=do_audio ? 1 : 2;\r
- PicoFrame();\r
- PicoSkipFrame=0;\r
-}\r
-\r
-\r
-void emu_forcedFrame(int opts)\r