Unverified Commit f605173e authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #63 from bbbradsmith/two_player

Two player support, other interface tweaks
parents bcdd9e19 06dd0840
Pipeline #2971 passed with stages
in 6 minutes and 4 seconds
......@@ -55,21 +55,36 @@ Note : zip support is provided by RetroArch and is done before passing the game
## Default Controls
```
L2 Show/Hide status
R2 Select virtual keyboard page
L Show/hide virtual keyboard
R Change Mouse speed 1 to 6 . (for gui and emu)
SEL Toggle Mouse/Joy mode
STR Toggle joystick number
Port 1:
B Fire / Left mouse button / Virtual keyboard keypress
A Auto-Fire / Right mouse button
Y Toggle Shift
Y Toggle virtual keyboard shift
X Hatari GUI
SEL Toggle Joystick / Mouse mode
STR Toggle 2 joysticks mode
L Show/hide virtual keyboard
R Change Mouse speed 1 to 6 . (for gui and emu)
L2 Show/Hide status
R2 Select virtual keyboard page
Pad / Analog Left - Joystick / Mouse
Port 2:
B Fire
A Auto-Fire
STR Toggle 2 joysticks mode
L2 Show/Hide status
Pad / Analog Left - Joystick
Other:
Analog Left - Joystick / Mouse
Mouse - Mouse
Mouse - Mouse (when port 1 is not in Joystick mode)
Key ~/` - Hatari GUI
Keyboard - Atari ST keys
Scroll Lock - (RetroArch default hotkey) game focus mode disables keyboard shortcuts, captures mouse
F11 - (RetroArch default hotkey) capture/release mouse
```
## Knows Bugs
- HATARI GUI is not functionnal because of a mouse bug (too much speed). Usually you don't need to enter the GUI. It was fixed in the P-UAE core with the same GUI, so a patch will be done for this core.
- It's a debug release, so expect bug.
- It's a debug release, so expect bug?
......@@ -13,6 +13,7 @@ extern int hmain(int argc, char *argv[]);
void parse_cmdline( const char *argv );
// Global variables
extern bool hatari_fastfdc;
extern bool hatari_borders;
extern char hatari_frameskips[2];
......@@ -49,6 +50,8 @@ int pre_main(const char *argv)
Add_Option("hatari");
Add_Option("--statusbar");
Add_Option("0");
Add_Option("--fastfdc");
Add_Option(hatari_fastfdc==true?"1":"0");
Add_Option("--borders");
Add_Option(hatari_borders==true?"1":"0");
Add_Option("--frameskips");
......
......@@ -51,20 +51,23 @@ char RPATH[512];
//EMU FLAGS
int NPAGE=-1, KCOL=1, BKGCOLOR=0, MAXPAS=6;
int SHIFTON=-1,MOUSEMODE=-1,NUMJOY=0,SHOWKEY=-1,PAS=4,STATUTON=-1;
int SHIFTON=-1,MOUSEMODE=-1,SHOWKEY=-1,PAS=4,STATUTON=-1;
int SND; //SOUND ON/OFF
static int firstps=0;
int pauseg=0; //enter_gui
//JOY
int al[2];//left analog1
unsigned char MXjoy0; // joy
int NUMjoy=1;
unsigned char MXjoy0; // joy 1
unsigned char MXjoy1; // joy 2
int NUMjoy=1; // 1 = joystick+mouse, -1 = 2 joysticks no mouse
//MOUSE
int touch=-1; // gui mouse btn
int fmousex,fmousey; // emu mouse
extern int gmx,gmy; //gui mouse
int point_x_last = -1;
int point_y_last = -1;
//KEYBOARD
char Key_Sate[512];
......@@ -98,7 +101,7 @@ long GetTicks(void)
//#warning "GetTick PS3\n"
unsigned long ticks_micro;
unsigned long ticks_micro;
uint64_t secs;
uint64_t nsecs;
......@@ -146,9 +149,9 @@ void gui_poll_events(void)
if(Ktime - LastFPSTime >= 1000/50)
{
slowdown=0;
slowdown=0;
frame++;
LastFPSTime = Ktime;
LastFPSTime = Ktime;
co_switch(mainThread);
}
#endif
......@@ -157,7 +160,7 @@ void gui_poll_events(void)
//save bkg for screenshot
void save_bkg(void)
{
int i, j, k;
int i, j, k;
unsigned char *ptr;
k = 0;
......@@ -278,35 +281,32 @@ void pause_select(void)
void Print_Statut(void)
{
STAT_BASEY=CROP_HEIGHT;
DrawFBoxBmp(bmp,0,CROP_HEIGHT,CROP_WIDTH,STAT_YSZ,RGB565(0,0,0));
STAT_BASEY=CROP_HEIGHT+24;
if(MOUSEMODE==-1)
Draw_text(bmp,STAT_DECX,STAT_BASEY,0xffff,0x8080,1,2,40,"Joy ");
else
Draw_text(bmp,STAT_DECX,STAT_BASEY,0xffff,0x8080,1,2,40,"Mouse");
DrawFBoxBmp(bmp,0,STAT_BASEY,CROP_WIDTH,STAT_YSZ,RGB565(0,0,0));
Draw_text(bmp,STAT_DECX+40 ,STAT_BASEY,0xffff,0x8080,1,2,40,(SHIFTON>0?"SHFT":""));
Draw_text(bmp,STAT_DECX+80 ,STAT_BASEY,0xffff,0x8080,1,2,40,"MS:%d",PAS);
Draw_text(bmp,STAT_DECX+120,STAT_BASEY,0xffff,0x8080,1,2,40,"Joy:%d",NUMjoy);
Draw_text(bmp,STAT_DECX ,STAT_BASEY,0xffff,0x8080,1,2,40,(MOUSEMODE<0)?" Joy ":"Mouse");
if (MOUSEMODE>=0)
Draw_text(bmp,STAT_DECX+40 ,STAT_BASEY,0xffff,0x8080,1,2,40,"Speed:%d",PAS);
Draw_text(bmp,STAT_DECX+100,STAT_BASEY,0xffff,0x8080,1,2,40,(SHIFTON>0)?"SHIFT":" ");
Draw_text(bmp,STAT_DECX+150,STAT_BASEY,0xffff,0x8080,1,2,40,"Joysticks:%s",(NUMjoy < 0) ? " 2 " : "1+M");
if(LEDA)
{
DrawFBoxBmp(bmp,CROP_WIDTH-6*BOXDEC-6-16,CROP_HEIGHT-0,16,16,RGB565(0,7,0));//led A drive
Draw_text(bmp,CROP_WIDTH-6*BOXDEC-6-16,CROP_HEIGHT-0,0xffff,0x0,1,2,40," A");
}
DrawFBoxBmp(bmp,CROP_WIDTH-6*BOXDEC-6-16,STAT_BASEY,16,16,RGB565(0,7,0));//led A drive
Draw_text(bmp,CROP_WIDTH-6*BOXDEC-6-16,STAT_BASEY,0xffff,0x0,1,2,40," A");
}
if(LEDB)
{
DrawFBoxBmp(bmp,CROP_WIDTH-7*BOXDEC-6-16,CROP_HEIGHT-0,16,16,RGB565(0,7,0));//led B drive
Draw_text(bmp,CROP_WIDTH-7*BOXDEC-6-16,CROP_HEIGHT-0,0xffff,0x0,1,2,40," B");
DrawFBoxBmp(bmp,CROP_WIDTH-7*BOXDEC-6-16,STAT_BASEY,16,16,RGB565(0,7,0));//led B drive
Draw_text(bmp,CROP_WIDTH-7*BOXDEC-6-16,STAT_BASEY,0xffff,0x0,1,2,40," B");
}
if(LEDC)
{
DrawFBoxBmp(bmp,CROP_WIDTH-8*BOXDEC-6-16,CROP_HEIGHT-0,16,16,RGB565(0,7,0));//led C drive
Draw_text(bmp,CROP_WIDTH-8*BOXDEC-6-16,CROP_HEIGHT-0,0xffff,0x0,1,2,40," C");
DrawFBoxBmp(bmp,CROP_WIDTH-8*BOXDEC-6-16,STAT_BASEY,16,16,RGB565(0,7,0));//led C drive
Draw_text(bmp,CROP_WIDTH-8*BOXDEC-6-16,STAT_BASEY,0xffff,0x0,1,2,40," C");
LEDC=0;
}
......@@ -335,37 +335,38 @@ void Process_key(void)
if( Key_Sate[i] && Key_Sate2[i]==0 )
{
if(SHIFTON == 1)
retro_key_up( SDLKeyToSTScanCode[i] );
retro_key_up( SDLKeyToSTScanCode[i] );
else if(SHIFTON == -1)
retro_key_down(SDLKeyToSTScanCode[i] );
retro_key_down( SDLKeyToSTScanCode[i] );
SHIFTON=-SHIFTON;
Key_Sate2[i]=1;
}
else if ( !Key_Sate[i] && Key_Sate2[i]==1 )Key_Sate2[i]=0;
}
else
{
if(Key_Sate[i] && SDLKeyToSTScanCode[i]!=-1 && Key_Sate2[i]==0)
{
retro_key_down( SDLKeyToSTScanCode[i] );
retro_key_down( SDLKeyToSTScanCode[i] );
Key_Sate2[i]=1;
}
else if ( !Key_Sate[i] && SDLKeyToSTScanCode[i]!=-1 && Key_Sate2[i]==1 )
{
retro_key_up( SDLKeyToSTScanCode[i] );
retro_key_up( SDLKeyToSTScanCode[i] );
Key_Sate2[i]=0;
}
}
}
}
const int DEADZONE = 0x8000 / 16;
void Deadzone(int* a)
{
if (al[0] <= -DEADZONE) al[0] += DEADZONE;
if (al[1] <= -DEADZONE) al[1] += DEADZONE;
if (al[0] >= DEADZONE) al[0] -= DEADZONE;
if (al[1] >= DEADZONE) al[1] -= DEADZONE;
}
/*
L2 show/hide Status
......@@ -377,7 +378,7 @@ void Process_key(void)
B fire/mouse-left/valid key in vkbd
A mouse-right
Y switch Shift ON/OFF
X Emu Gui
X Hatari Gui
*/
void update_input(void)
......@@ -386,7 +387,15 @@ void update_input(void)
static int oldi=-1;
static int vkx=0,vky=0;
static int mbL=0,mbR=0;
int mouse_l;
int mouse_r;
int16_t mouse_x;
int16_t mouse_y;
MXjoy0=0;
MXjoy1=0;
if(oldi!=-1)
{
IKBD_PressSTKey(oldi,0);
......@@ -398,7 +407,7 @@ void update_input(void)
Process_key();
i=RETRO_DEVICE_ID_JOYPAD_X;
if (Key_Sate[RETROK_F11] || input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
if (Key_Sate[RETROK_TILDE] || Key_Sate[RETROK_BACKQUOTE] || input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
pauseg=1;
i=RETRO_DEVICE_ID_JOYPAD_L;//show vkey toggle
......@@ -418,16 +427,17 @@ void update_input(void)
{
mbt[i]=0;
MOUSEMODE=-MOUSEMODE;
if (MOUSEMODE > 0) NUMjoy=1;
}
i=RETRO_DEVICE_ID_JOYPAD_START;//num joy toggle
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
i=RETRO_DEVICE_ID_JOYPAD_START;//num joy toggle (on either joystick)
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
else if ( mbt[i]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) )
{
mbt[i]=0;
NUMJOY++;if(NUMJOY>1)NUMJOY=0;
NUMjoy=-NUMjoy;
if (NUMjoy < 0) MOUSEMODE=-1;
}
i=RETRO_DEVICE_ID_JOYPAD_R;//mouse gui speed
......@@ -449,10 +459,10 @@ void update_input(void)
Screen_SetFullUpdate();
}
i=RETRO_DEVICE_ID_JOYPAD_L2;//show/hide status
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
i=RETRO_DEVICE_ID_JOYPAD_L2;//show/hide status (either joystick)
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
else if ( mbt[i]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) || input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) )
{
mbt[i]=0;
STATUTON=-STATUTON;
......@@ -472,37 +482,80 @@ void update_input(void)
}
}
// joystick 2
if (NUMjoy < 0) // 2 joysticks, no mouse
{
al[0] =(input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] =(input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
/* Directions */
if (al[1] <= JOYRANGE_UP_VALUE)
MXjoy1 |= ATARIJOY_BITMASK_UP;
else if (al[1] >= JOYRANGE_DOWN_VALUE)
MXjoy1 |= ATARIJOY_BITMASK_DOWN;
if (al[0] <= JOYRANGE_LEFT_VALUE)
MXjoy1 |= ATARIJOY_BITMASK_LEFT;
else if (al[0] >= JOYRANGE_RIGHT_VALUE)
MXjoy1 |= ATARIJOY_BITMASK_RIGHT;
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP ) ) MXjoy1 |= ATARIJOY_BITMASK_UP;
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN ) ) MXjoy1 |= ATARIJOY_BITMASK_DOWN;
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT ) ) MXjoy1 |= ATARIJOY_BITMASK_LEFT;
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) ) MXjoy1 |= ATARIJOY_BITMASK_RIGHT;
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) ) MXjoy1 |= ATARIJOY_BITMASK_FIRE;
// Joy autofire
if( input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) )
{
MXjoy1 |= ATARIJOY_BITMASK_FIRE;
if ((nVBLs&0x7)<4)
MXjoy1 &= ~ATARIJOY_BITMASK_FIRE;
}
}
// virtual keyboard (prevents other joystick 1 input and mouse)
if(SHOWKEY==1)
{
static int vkflag[5]={0,0,0,0,0};
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) && vkflag[0]==0 )
// analog stick can work the keyboard
al[0] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
bool al_up = al[1] <= JOYRANGE_UP_VALUE;
bool al_dn = al[1] >= JOYRANGE_DOWN_VALUE;
bool al_lf = al[0] <= JOYRANGE_LEFT_VALUE;
bool al_rt = al[0] >= JOYRANGE_RIGHT_VALUE;
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) || al_up) && vkflag[0]==0 )
vkflag[0]=1;
else if (vkflag[0]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) )
else if (vkflag[0]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) || al_up) )
{
vkflag[0]=0;
vky -= 1;
}
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) && vkflag[1]==0 )
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) || al_dn) && vkflag[1]==0 )
vkflag[1]=1;
else if (vkflag[1]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) )
else if (vkflag[1]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) || al_dn) )
{
vkflag[1]=0;
vky += 1;
}
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) && vkflag[2]==0 )
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) || al_lf) && vkflag[2]==0 )
vkflag[2]=1;
else if (vkflag[2]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) )
else if (vkflag[2]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) || al_lf) )
{
vkflag[2]=0;
vkx -= 1;
}
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) && vkflag[3]==0 )
if ( (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) || al_rt) && vkflag[3]==0 )
vkflag[3]=1;
else if (vkflag[3]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) )
else if (vkflag[3]==1 && ! (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) || al_rt) )
{
vkflag[3]=0;
vkx += 1;
......@@ -549,6 +602,7 @@ void update_input(void)
{
//Change Joy number
NUMjoy=-NUMjoy;
if (NUMjoy < 0) MOUSEMODE = -1;
oldi=-1;
}
else
......@@ -578,19 +632,15 @@ void update_input(void)
return;
}
static int mbL=0,mbR=0;
int mouse_l;
int mouse_r;
int16_t mouse_x;
int16_t mouse_y;
// joystick 1 / mouse
if(MOUSEMODE==-1)
if(MOUSEMODE < 0)
{
//Joy mode
//Joy mode (joystick controls joystick, mouse controls mouse)
//emulate Joy0 with joy analog left
al[0] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));///2;
al[1] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));///2;
al[0] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] =(input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
/* Directions */
if (al[1] <= JOYRANGE_UP_VALUE)
......@@ -626,35 +676,19 @@ void update_input(void)
fmousey=mouse_y;
}
else
else // MOUSEMODE >= 0
{
//Mouse mode
//Mouse mode (joystick controls mouse)
fmousex=fmousey=0;
//emulate mouse with joy analog left
al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
#if defined(VITA)
// fix analog to mouse move up alone
int analog_deadzone = (15 * 32768 / 100);
double analog_r_magnitude = sqrt((al[0]*al[0]) + (al[1]*al[1]));
if (analog_r_magnitude <= analog_deadzone)
{
al[0] = 0;
al[1] = 0;
}
#endif
if(al[0]<=-1024)
fmousex -=(-al[0])/1024;
if(al[0]>= 1024)
fmousex +=( al[0])/1024;
if(al[1]<=-1024)
fmousey -=(-al[1])/1024;
if(al[1]>= 1024)
fmousey +=( al[1])/1024;
Deadzone(al);
al[0] = (al[0] * PAS) / MAXPAS;
al[1] = (al[1] * PAS) / MAXPAS;
fmousex += al[0]/1024;
fmousey += al[1]/1024;
//emulate mouse with dpad
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
......@@ -700,8 +734,6 @@ void update_input(void)
void input_gui(void)
{
int SAVPAS=PAS;
input_poll_cb();
int mouse_l;
......@@ -709,86 +741,77 @@ void input_gui(void)
int16_t mouse_x,mouse_y;
mouse_x=mouse_y=0;
//mouse/joy toggle
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 2) && mbt[2]==0 )
mbt[2]=1;
else if ( mbt[2]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 2) )
{
mbt[2]=0;
MOUSEMODE=-MOUSEMODE;
}
if(slowdown>0)return;
if(MOUSEMODE==1)
// ability to adjust mouse speed in hatari GUI
int i=RETRO_DEVICE_ID_JOYPAD_R;
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
{
//emulate mouse with joy analog left
al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
#if defined(VITA)
// fix analog to mouse move up alone
int analog_deadzone = (15 * 32768 / 100);
double analog_r_magnitude = sqrt((al[0]*al[0]) + (al[1]*al[1]));
if (analog_r_magnitude <= analog_deadzone)
{
al[0] = 0;
al[1] = 0;
}
#endif
if(al[0]<=-1024)
mouse_x -=(-al[0])/1024;
if(al[0]>= 1024)
mouse_x +=( al[0])/1024;
if(al[1]<=-1024)
mouse_y -=(-al[1])/1024;
if(al[1]>= 1024)
mouse_y +=( al[1])/1024;
mbt[i]=0;
PAS++;if(PAS>MAXPAS)PAS=1;
}
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
mouse_x += PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
mouse_x -= PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
mouse_y += PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
mouse_y -= PAS;
mouse_l=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B);
mouse_r=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
//emulate mouse with joy analog left
al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
Deadzone(al);
al[0] = (al[0] * PAS) / MAXPAS;
al[1] = (al[1] * PAS) / MAXPAS;
mouse_x += al[0]/1024;
mouse_y += al[1]/1024;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
mouse_x += PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
mouse_x -= PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
mouse_y += PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
mouse_y -= PAS;
mouse_l=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B);
mouse_r=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
// joystick mouse control is relative
gmx+=mouse_x;
gmy+=mouse_y;
PAS=SAVPAS;
}
else
// pointer mouse control is absolute, and overrides joystick when you move it
int point_x = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int point_y = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
int point_b = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
if (point_x != point_x_last || point_y != point_y_last)
{
mouse_x = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
mouse_y = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
mouse_l = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
mouse_r = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
point_x_last = point_x;
point_y_last = point_y;
const int PMIN = -0x7FFF;
const int PMAX = 0x7FFF;
gmx = ((point_x - PMIN) * retrow) / (PMAX - PMIN);
gmy = ((point_y - PMIN) * retroh) / (PMAX - PMIN);
}
slowdown=1;
static int mmbL = 0, mmbR = 0;
if(mmbL==0 && mouse_l)
if(mmbL==0 && (mouse_l || point_b))
{
mmbL=1;
touch=1;
}
else if(mmbL==1 && !mouse_l)
else if(mmbL==1 && (!mouse_l && !point_b))
{
mmbL=0;
touch=-1;
}
// POINTER doesn't have a right button, but Hatari GUI doesn't need it
if(mmbR==0 && mouse_r)
mmbR=1;
else if(mmbR==1 && !mouse_r)
mmbR=0;
gmx+=mouse_x;
gmy+=mouse_y;
if (gmx<0)
gmx=0;
if (gmx>retrow-1)
......@@ -798,4 +821,3 @@ void input_gui(void)
if (gmy>retroh-1)
gmy=retroh-1;
}
......@@ -60,6 +60,7 @@ unsigned int video_config = 0;
int CHANGE_RATE = 0, CHANGEAV_TIMING = 0;
float FRAMERATE = 50.0, SAMPLERATE = 44100.0;
bool hatari_fastfdc = true;