Zapper update
This commit is contained in:
@@ -50,6 +50,7 @@ static bool use_par;
|
|||||||
int turbo_enabler;
|
int turbo_enabler;
|
||||||
int turbo_delay;
|
int turbo_delay;
|
||||||
static int regionoverride = -1;
|
static int regionoverride = -1;
|
||||||
|
static int t[2] = {0.0};
|
||||||
|
|
||||||
/* emulator-specific variables */
|
/* emulator-specific variables */
|
||||||
|
|
||||||
@@ -538,9 +539,11 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
|
|||||||
switch(device)
|
switch(device)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
|
t[port] = RETRO_DEVICE_JOYPAD;
|
||||||
FCEUI_SetInput(port, SI_GAMEPAD, &JSReturn[0], 0);
|
FCEUI_SetInput(port, SI_GAMEPAD, &JSReturn[0], 0);
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_MOUSE:
|
case RETRO_DEVICE_MOUSE:
|
||||||
|
t[port] = RETRO_DEVICE_MOUSE;
|
||||||
FCEUI_SetInput(port, SI_ZAPPER, &MouseData[0], 1);
|
FCEUI_SetInput(port, SI_ZAPPER, &MouseData[0], 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -570,7 +573,7 @@ void retro_set_environment(retro_environment_t cb)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct retro_controller_description pads[] = {
|
static const struct retro_controller_description pads[] = {
|
||||||
{ "NES Gamepad", RETRO_DEVICE_JOYPAD },
|
{ "Gamepad", RETRO_DEVICE_JOYPAD },
|
||||||
{ "Zapper", RETRO_DEVICE_MOUSE },
|
{ "Zapper", RETRO_DEVICE_MOUSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1020,47 +1023,41 @@ static void check_variables(bool startup)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mouse_x, mouse_y, mzx, mzy;
|
static int mzx = 0, mzy = 0, mzb = 0;
|
||||||
|
|
||||||
void GetMouseData(uint32_t *zapdata)
|
void GetMouseData(uint32_t *zapdata)
|
||||||
{
|
{
|
||||||
static int right, bottom, adjx, adjy, offscreen, port;
|
int right, bottom, port, adjx, adjy;
|
||||||
|
|
||||||
|
#ifdef PSP
|
||||||
|
adjx = adjy = use_overscan ? 8 : 0;
|
||||||
|
#else
|
||||||
|
adjx = overscan_h ? 8 : 0;
|
||||||
|
adjy = overscan_v ? 8 : 0;
|
||||||
|
#endif
|
||||||
|
port = (GameInfo->type == GIT_VSUNI) ? 0 : 1;
|
||||||
right = 256;
|
right = 256;
|
||||||
bottom = 240;
|
bottom = 240;
|
||||||
offscreen = 0;
|
mzb = 0;
|
||||||
#ifdef PSP
|
|
||||||
adjx = adjy = use_overscan ? 8:0;
|
|
||||||
#else
|
|
||||||
adjx = overscan_h ? 8:0;
|
|
||||||
adjy = overscan_v ? 8:0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (GameInfo->input[0] != SI_ZAPPER && GameInfo->input[1] != SI_ZAPPER)
|
|
||||||
return;
|
|
||||||
|
|
||||||
port = (GameInfo->type == GIT_VSUNI) ? 1 : 0;
|
|
||||||
|
|
||||||
/* TODO: Add some sort of mouse sensitivity */
|
/* TODO: Add some sort of mouse sensitivity */
|
||||||
mouse_x = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
mzx += input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||||
mouse_y = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
mzy += input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||||
|
|
||||||
mzx += mouse_x;
|
|
||||||
mzy += mouse_y;
|
|
||||||
|
|
||||||
/* Set crosshair within the limits of game's resolution */
|
/* Set crosshair within the limits of game's resolution */
|
||||||
if (mzx > right - adjx + offscreen)
|
if (mzx > right - adjx) mzx = right - adjx;
|
||||||
mzx = right - adjx + offscreen;
|
else if (mzx < 1 + adjx) mzx = 1 + adjx;
|
||||||
else if (mzx <= 1 + adjx)
|
if (mzy > bottom - adjy) mzy = bottom - adjy;
|
||||||
mzx = 1 + adjx;
|
else if (mzy < 1 + adjy) mzy = 1 + adjy;
|
||||||
|
|
||||||
if (mzy > bottom - adjy + offscreen)
|
if (input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT))
|
||||||
mzy = bottom - adjy + offscreen;
|
mzb |= 0x1;
|
||||||
else if (mzy <= 1 + adjy)
|
if (input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT))
|
||||||
mzy = 1 + adjy;
|
mzb |= 0x2;
|
||||||
|
|
||||||
zapdata[0] = mzx;
|
zapdata[0] = mzx;
|
||||||
zapdata[1] = mzy;
|
zapdata[1] = mzy;
|
||||||
zapdata[2] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT) ? 1 : 0
|
zapdata[2] = mzb;
|
||||||
| input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT) ? 2 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1154,6 +1151,7 @@ static void FCEUD_UpdateInput(void)
|
|||||||
|
|
||||||
JSReturn[0] = pad[0] | (pad[1] << 8) | (pad[2] << 16) | (pad[3] << 24);
|
JSReturn[0] = pad[0] | (pad[1] << 8) | (pad[2] << 16) | (pad[3] << 24);
|
||||||
|
|
||||||
|
if (t[0] == RETRO_DEVICE_MOUSE || t[1] == RETRO_DEVICE_MOUSE)
|
||||||
GetMouseData(&MouseData[0]);
|
GetMouseData(&MouseData[0]);
|
||||||
|
|
||||||
if (input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2))
|
if (input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2))
|
||||||
|
|||||||
Reference in New Issue
Block a user