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
34 extern int scaled_display;
38 /* UsrInputType[] is user-specified. InputType[] is current
39 (game loading can override user settings)
41 static int UsrInputType[2]={SI_GAMEPAD,SI_GAMEPAD};
42 static int InputType[2];
44 static int UsrInputTypeFC={SI_NONE};
45 static int InputTypeFC;
47 static uint32 JSreturn;
50 static int powerpadsc[2][12];
51 static int powerpadside=0;
54 static uint32 MouseData[3];
55 static uint8 fkbkeys[0x48];
56 unsigned long lastpad=0;
58 extern void ResetNES(void);
59 extern void CleanSurface(void);
61 char soundvolmeter[21];
67 static void setsoundvol(int soundvolume)
69 //FCEUI_SetSoundVolume(soundvol);
71 gp2x_sound_volume(soundvolume, soundvolume);
72 int meterval=soundvolume/5;
73 for (soundvolIndex=0; soundvolIndex < 20; soundvolIndex++)
75 if (soundvolIndex < meterval)
77 soundvolmeter[soundvolIndex]='*';
81 soundvolmeter[soundvolIndex]='_';
85 FCEU_DispMessage("|%s|", soundvolmeter);
90 void FCEUD_UpdateInput(void)
92 static int volpushed_frames = 0;
93 long lastpad2 = lastpad;
94 unsigned long keys = gp2x_joystick_read(0);
95 uint32 JS = 0; // RLDU SEBA
98 #define down(b) (keys & GP2X_##b)
99 if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_L|GP2X_START)) == (GP2X_L|GP2X_L|GP2X_START))
105 else if (down(VOL_UP))
107 /* wait for at least 10 updates, because user may be just trying to enter menu */
108 if (volpushed_frames++ > 10) {
110 if (soundvol > 100) soundvol=100;
111 //FCEUI_SetSoundVolume(soundvol);
112 setsoundvol(soundvol);
115 else if (down(VOL_DOWN))
117 if (volpushed_frames++ > 10) {
119 if (soundvol < 0) soundvol=0;
120 //FCEUI_SetSoundVolume(soundvol);
121 setsoundvol(soundvol);
126 volpushed_frames = 0;
130 for (i = 0; i < 32; i++)
132 if (keys & (1 << i)) {
133 int acts = Settings.KeyBinds[i];
143 //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);
147 // JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8);
148 // TODO: make these bindable, use new interface
149 if(gametype==GIT_FDS)
152 if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH)))
154 DriverInterface(DES_FDSSELECT,0);
156 else if ((pad & GP2X_L) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_PUSH)) && (!(pad & GP2X_R))&& (!(lastpad2 & GP2X_L)))
158 DriverInterface(DES_FDSINSERT,0);
160 else if ((pad & GP2X_R) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_PUSH)) && (!(lastpad2 & GP2X_R)))
162 DriverInterface(DES_FDSEJECT,0);
169 static void InitOtherInput(void)
184 //case SI_POWERPAD:InputDPtr=&powerpadbuf[x];break;
185 case SI_GAMEPAD:InputDPtr=((uint8 *)&JSreturn)+(x<<1);break;
186 case SI_ARKANOID:InputDPtr=MouseData;t|=1;break;
187 case SI_ZAPPER:InputDPtr=MouseData;
192 FCEUI_SetInput(x,InputType[x],InputDPtr,attrib);
199 case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break;
200 case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break;
201 case SIFC_FKB:InputDPtr=fkbkeys;break;
204 FCEUI_SetInputFC(InputTypeFC,InputDPtr,attrib);
205 FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
207 if(t && !(inited&16))