1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define JOY_RIGHT 0x80
32 extern uint8 Exit; // exit emu loop
35 /* UsrInputType[] is user-specified. InputType[] is current
36 (game loading can override user settings)
38 static int UsrInputType[2]={SI_GAMEPAD,SI_GAMEPAD};
39 static int InputType[2];
41 static int UsrInputTypeFC={SI_NONE};
42 static int InputTypeFC;
44 static uint32 JSreturn;
47 static int powerpadsc[2][12];
48 static int powerpadside=0;
51 static uint32 MouseData[3];
52 static uint8 fkbkeys[0x48];
53 unsigned long lastpad=0;
55 char soundvolmeter[21];
59 static void setsoundvol(int soundvolume)
61 //FCEUI_SetSoundVolume(soundvol);
63 gp2x_sound_volume(soundvolume, soundvolume);
64 int meterval=soundvolume/5;
65 for (soundvolIndex=0; soundvolIndex < 20; soundvolIndex++)
67 if (soundvolIndex < meterval)
69 soundvolmeter[soundvolIndex]='*';
73 soundvolmeter[soundvolIndex]='_';
77 FCEU_DispMessage("|%s|", soundvolmeter);
82 void FCEUD_UpdateInput(void)
84 static int volpushed_frames = 0;
85 static int turbo_rate_cnt_a = 0, turbo_rate_cnt_b = 0;
86 long lastpad2 = lastpad;
87 unsigned long keys = gp2x_joystick_read(0);
88 uint32 JS = 0; // RLDU SEBA
91 #define down(b) (keys & GP2X_##b)
92 if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_L|GP2X_START)) == (GP2X_L|GP2X_L|GP2X_START))
98 else if (down(VOL_UP))
100 /* wait for at least 10 updates, because user may be just trying to enter menu */
101 if (volpushed_frames++ > 10) {
103 if (soundvol > 100) soundvol=100;
104 //FCEUI_SetSoundVolume(soundvol);
105 setsoundvol(soundvol);
108 else if (down(VOL_DOWN))
110 if (volpushed_frames++ > 10) {
112 if (soundvol < 0) soundvol=0;
113 //FCEUI_SetSoundVolume(soundvol);
114 setsoundvol(soundvol);
119 volpushed_frames = 0;
123 for (i = 0; i < 32; i++)
125 if (keys & (1 << i)) {
126 int acts = Settings.KeyBinds[i];
129 if (acts & 0x100) { // A turbo
130 turbo_rate_cnt_a += Settings.turbo_rate_add;
131 JS |= (turbo_rate_cnt_a >> 24) & 1;
133 if (acts & 0x200) { // B turbo
134 turbo_rate_cnt_b += Settings.turbo_rate_add;
135 JS |= (turbo_rate_cnt_b >> 23) & 2;
144 //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
148 // JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8);
149 // TODO: make these bindable, use new interface
150 if(gametype==GIT_FDS)
153 if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH)))
155 DriverInterface(DES_FDSSELECT,0);
157 else if ((pad & GP2X_L) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_PUSH)) && (!(pad & GP2X_R))&& (!(lastpad2 & GP2X_L)))
159 DriverInterface(DES_FDSINSERT,0);
161 else if ((pad & GP2X_R) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_PUSH)) && (!(lastpad2 & GP2X_R)))
163 DriverInterface(DES_FDSEJECT,0);
170 static void InitOtherInput(void)
185 //case SI_POWERPAD:InputDPtr=&powerpadbuf[x];break;
186 case SI_GAMEPAD:InputDPtr=((uint8 *)&JSreturn)+(x<<1);break;
187 case SI_ARKANOID:InputDPtr=MouseData;t|=1;break;
188 case SI_ZAPPER:InputDPtr=MouseData;
193 FCEUI_SetInput(x,InputType[x],InputDPtr,attrib);
200 case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break;
201 case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break;
202 case SIFC_FKB:InputDPtr=fkbkeys;break;
205 FCEUI_SetInputFC(InputTypeFC,InputDPtr,attrib);
206 FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
208 if(t && !(inited&16))