Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24163a7c92 | ||
|
|
d934197246 | ||
|
|
d4a130f1dc | ||
|
|
8ccf4eb9ba | ||
|
|
cdb7b6fede | ||
|
|
fcae072625 | ||
|
|
1d3dae01e9 | ||
|
|
736a626ccf | ||
|
|
a4cc8b0585 | ||
|
|
333c94be52 |
No files matched your search
+1
-55
@@ -143,11 +143,6 @@ static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL
|
|||||||
consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz...
|
consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz...
|
||||||
|
|
||||||
// allows a fake player to appear on the ms and serverlist when your dedi server is empty
|
|
||||||
static void FakeSeed_OnChange(void);
|
|
||||||
consvar_t cv_usefakeseed = {"fakeseed", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, FakeSeed_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
||||||
consvar_t cv_fakeseedname = {"fakeseedname", "Player 1", CV_SAVE|CV_CALL|CV_NOINIT, NULL, FakeSeed_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
||||||
|
|
||||||
SINT8 nodetoplayer[MAXNETNODES] = {};
|
SINT8 nodetoplayer[MAXNETNODES] = {};
|
||||||
SINT8 nodetoplayer2[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen)
|
SINT8 nodetoplayer2[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen)
|
||||||
SINT8 nodetoplayer3[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen == 2)
|
SINT8 nodetoplayer3[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen == 2)
|
||||||
@@ -245,13 +240,6 @@ consvar_t cv_httpsource = {"http_source", "", CV_SAVE, NULL, NULL, 0, NULL, NULL
|
|||||||
|
|
||||||
consvar_t cv_kicktime = {"kicktime", "10", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_kicktime = {"kicktime", "10", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
static void FakeSeed_OnChange(void)
|
|
||||||
{
|
|
||||||
#ifdef MASTERSERVER
|
|
||||||
Update_MS();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean UseLocalDelay(void)
|
static boolean UseLocalDelay(void)
|
||||||
{
|
{
|
||||||
if (dedicated || (server && server_lagless && !cv_mindelay.value) || modeattacking == ATTACKING_RECORD)
|
if (dedicated || (server && server_lagless && !cv_mindelay.value) || modeattacking == ATTACKING_RECORD)
|
||||||
@@ -1556,12 +1544,6 @@ static boolean CL_SendJoin(void)
|
|||||||
return HSendPacket(servernode, false, 0, sizeof(clientconfig_pak));
|
return HSendPacket(servernode, false, 0, sizeof(clientconfig_pak));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean UseFakeSeed(void)
|
|
||||||
{
|
|
||||||
// due to complexity this will disable the moment a real player joins
|
|
||||||
return (dedicated && cv_usefakeseed.value && D_NumPlayers() == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
||||||
{
|
{
|
||||||
UINT8 *p;
|
UINT8 *p;
|
||||||
@@ -1584,12 +1566,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
|||||||
netbuffer->u.serverinfo.time = (tic_t)LONG(servertime);
|
netbuffer->u.serverinfo.time = (tic_t)LONG(servertime);
|
||||||
netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime);
|
netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime);
|
||||||
|
|
||||||
// force 1 player
|
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
|
||||||
if (UseFakeSeed())
|
|
||||||
netbuffer->u.serverinfo.numberofplayer = (UINT8)1;
|
|
||||||
else
|
|
||||||
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
|
|
||||||
|
|
||||||
netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
|
netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
|
||||||
|
|
||||||
// SRB2Kart: Vanilla's gametype constants for MS support
|
// SRB2Kart: Vanilla's gametype constants for MS support
|
||||||
@@ -1668,37 +1645,6 @@ static void SV_SendPlayerInfo(INT32 node)
|
|||||||
|
|
||||||
netbuffer->packettype = PT_PLAYERINFO;
|
netbuffer->packettype = PT_PLAYERINFO;
|
||||||
|
|
||||||
// send a fake player to trick ms and serverbrowser
|
|
||||||
if (UseFakeSeed())
|
|
||||||
{
|
|
||||||
//printf("sending fake player lmao\n");
|
|
||||||
netbuffer->u.playerinfo[0].node = 0;
|
|
||||||
|
|
||||||
// fallback to smth, make sure this is always set
|
|
||||||
if (!cv_fakeseedname.string[0])
|
|
||||||
CV_Set(&cv_fakeseedname, "Player 1");
|
|
||||||
strlcpy(netbuffer->u.playerinfo[0].name, cv_fakeseedname.string, MAXPLAYERNAME+1);
|
|
||||||
|
|
||||||
memset(netbuffer->u.playerinfo[0].address, 0, 4);
|
|
||||||
|
|
||||||
// make it appear as spectator
|
|
||||||
netbuffer->u.playerinfo[0].team = 255;
|
|
||||||
|
|
||||||
// doesent really matter what we put here lel
|
|
||||||
netbuffer->u.playerinfo[0].score = LONG(42069);
|
|
||||||
netbuffer->u.playerinfo[0].timeinserver = SHORT(42069);
|
|
||||||
netbuffer->u.playerinfo[0].skin = (UINT8)1; // no clue wtf skin 1 is, tails maybe?
|
|
||||||
|
|
||||||
netbuffer->u.playerinfo[0].data = 0;
|
|
||||||
|
|
||||||
// mark every other slot as empty
|
|
||||||
for (i = 1; i < MSCOMPAT_MAXPLAYERS; i++)
|
|
||||||
netbuffer->u.playerinfo[i].node = 255;
|
|
||||||
|
|
||||||
HSendPacket(node, false, 0, sizeof(plrinfo) * MSCOMPAT_MAXPLAYERS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MSCOMPAT_MAXPLAYERS; i++)
|
for (i = 0; i < MSCOMPAT_MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
if ((i >= MAXPLAYERS) || !playeringame[i])
|
if ((i >= MAXPLAYERS) || !playeringame[i])
|
||||||
|
|||||||
@@ -582,8 +582,6 @@ extern tic_t simulated_lag;
|
|||||||
extern tic_t lowest_lag;
|
extern tic_t lowest_lag;
|
||||||
extern consvar_t cv_mindelay, cv_gentlemens;
|
extern consvar_t cv_mindelay, cv_gentlemens;
|
||||||
|
|
||||||
extern consvar_t cv_usefakeseed, cv_fakeseedname;
|
|
||||||
|
|
||||||
extern consvar_t
|
extern consvar_t
|
||||||
cv_netticbuffer, cv_allownewplayer,
|
cv_netticbuffer, cv_allownewplayer,
|
||||||
#ifdef SATURNJOIN
|
#ifdef SATURNJOIN
|
||||||
|
|||||||
@@ -166,57 +166,6 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
|||||||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||||
boolean capslock = 0; // gee i wonder what this does.
|
boolean capslock = 0; // gee i wonder what this does.
|
||||||
|
|
||||||
static void D_PadMenuScrollInput(UINT8 input)
|
|
||||||
{
|
|
||||||
event_t dpadev;
|
|
||||||
memset(&dpadev, 0, sizeof(event_t));
|
|
||||||
dpadev.type = ev_keydown;
|
|
||||||
|
|
||||||
switch (input)
|
|
||||||
{
|
|
||||||
case DPAD_UP:
|
|
||||||
dpadev.data1 = KEY_UPARROW;
|
|
||||||
break;
|
|
||||||
case DPAD_DOWN:
|
|
||||||
dpadev.data1 = KEY_DOWNARROW;
|
|
||||||
break;
|
|
||||||
case DPAD_LEFT:
|
|
||||||
dpadev.data1 = KEY_LEFTARROW;
|
|
||||||
break;
|
|
||||||
case DPAD_RIGHT:
|
|
||||||
dpadev.data1 = KEY_RIGHTARROW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
D_PostEvent(&dpadev); // put into eventlist
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SCROLLDELAY 19
|
|
||||||
|
|
||||||
// Check if any dpad button is held
|
|
||||||
// and pass it to the eventlist
|
|
||||||
static void D_GamePadMenuScrollTicker(void)
|
|
||||||
{
|
|
||||||
UINT8 i;
|
|
||||||
static UINT8 menuInputDelayTimer = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
|
||||||
{
|
|
||||||
if (dpadscrollstate[i])
|
|
||||||
{
|
|
||||||
if (menuInputDelayTimer < SCROLLDELAY)
|
|
||||||
menuInputDelayTimer++;
|
|
||||||
else if (menuInputDelayTimer == SCROLLDELAY)
|
|
||||||
D_PadMenuScrollInput(i);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
menuInputDelayTimer = 0;
|
|
||||||
}
|
|
||||||
#undef SCROLLDELAY
|
|
||||||
|
|
||||||
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
||||||
|
|
||||||
static void D_DeviceLEDTick(void)
|
static void D_DeviceLEDTick(void)
|
||||||
@@ -844,11 +793,6 @@ void D_SRB2Loop(void)
|
|||||||
|
|
||||||
if (!dedicated)
|
if (!dedicated)
|
||||||
{
|
{
|
||||||
if (menuactive)
|
|
||||||
{
|
|
||||||
D_GamePadMenuScrollTicker();
|
|
||||||
}
|
|
||||||
|
|
||||||
D_DeviceLEDTick();
|
D_DeviceLEDTick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -760,9 +760,6 @@ void D_RegisterServerCommands(void)
|
|||||||
CV_RegisterVar(&cv_showping);
|
CV_RegisterVar(&cv_showping);
|
||||||
CV_RegisterVar(&cv_pingmeasurement);
|
CV_RegisterVar(&cv_pingmeasurement);
|
||||||
|
|
||||||
CV_RegisterVar(&cv_usefakeseed);
|
|
||||||
CV_RegisterVar(&cv_fakeseedname);
|
|
||||||
|
|
||||||
#ifdef SEENAMES
|
#ifdef SEENAMES
|
||||||
CV_RegisterVar(&cv_allowseenames);
|
CV_RegisterVar(&cv_allowseenames);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -262,9 +262,6 @@ void G_ResetControls(void)
|
|||||||
|
|
||||||
memset(joyxmove, 0, sizeof(joyxmove));
|
memset(joyxmove, 0, sizeof(joyxmove));
|
||||||
memset(joyymove, 0, sizeof(joyymove));
|
memset(joyymove, 0, sizeof(joyymove));
|
||||||
|
|
||||||
// reset those just in case the game missed the keyup event
|
|
||||||
memset(dpadscrollstate, false, sizeof(dpadscrollstate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ typedef enum
|
|||||||
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
|
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
|
||||||
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
|
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
|
||||||
|
|
||||||
KEY_DBLMOUSE1 =KEY_HAT1 + JOYHATS*4, // double clicks
|
KEY_DBLMOUSE1 = KEY_HAT1 + JOYHATS*4, // double clicks
|
||||||
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
|
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
|
||||||
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
|
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
|
||||||
|
|
||||||
|
|||||||
@@ -221,10 +221,6 @@ INT32 I_mkdir(const char *dirname, INT32 unixright);
|
|||||||
*/
|
*/
|
||||||
const char *I_LocateWad(void);
|
const char *I_LocateWad(void);
|
||||||
|
|
||||||
/** \brief Joystick events
|
|
||||||
*/
|
|
||||||
void I_GetJoystickEvents(UINT8 index);
|
|
||||||
|
|
||||||
char *I_GetEnv(const char *name);
|
char *I_GetEnv(const char *name);
|
||||||
|
|
||||||
INT32 I_PutEnv(char *variable);
|
INT32 I_PutEnv(char *variable);
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ boolean I_CheckNativeRes(void);
|
|||||||
|
|
||||||
void I_SetBorderlessWindow(void);
|
void I_SetBorderlessWindow(void);
|
||||||
|
|
||||||
|
void I_HandleControllerHatRepeat(void);
|
||||||
|
|
||||||
#ifdef USE_FBO_OGL
|
#ifdef USE_FBO_OGL
|
||||||
|
|
||||||
void RefreshOGLSDLSurface(void);
|
void RefreshOGLSDLSurface(void);
|
||||||
|
|||||||
+3
-24
@@ -759,8 +759,6 @@ static void Command_Manual_f(void)
|
|||||||
itemOn = 0;
|
itemOn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean dpadscrollstate[4] = {false, false, false, false};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// M_Responder
|
// M_Responder
|
||||||
//
|
//
|
||||||
@@ -807,19 +805,15 @@ boolean M_Responder(event_t *ev)
|
|||||||
break;
|
break;
|
||||||
case KEY_HAT1:
|
case KEY_HAT1:
|
||||||
ch = KEY_UPARROW;
|
ch = KEY_UPARROW;
|
||||||
dpadscrollstate[DPAD_UP] = true;
|
|
||||||
break;
|
break;
|
||||||
case KEY_HAT1 + 1:
|
case KEY_HAT1 + 1:
|
||||||
ch = KEY_DOWNARROW;
|
ch = KEY_DOWNARROW;
|
||||||
dpadscrollstate[DPAD_DOWN] = true;
|
|
||||||
break;
|
break;
|
||||||
case KEY_HAT1 + 2:
|
case KEY_HAT1 + 2:
|
||||||
ch = KEY_LEFTARROW;
|
ch = KEY_LEFTARROW;
|
||||||
dpadscrollstate[DPAD_LEFT] = true;
|
|
||||||
break;
|
break;
|
||||||
case KEY_HAT1 + 3:
|
case KEY_HAT1 + 3:
|
||||||
ch = KEY_RIGHTARROW;
|
ch = KEY_RIGHTARROW;
|
||||||
dpadscrollstate[DPAD_RIGHT] = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,24 +829,6 @@ boolean M_Responder(event_t *ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ev->type == ev_keyup)
|
|
||||||
{
|
|
||||||
switch (ev->data1) // if you let go of those set those to false
|
|
||||||
{
|
|
||||||
case KEY_HAT1:
|
|
||||||
dpadscrollstate[DPAD_UP] = false;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 1:
|
|
||||||
dpadscrollstate[DPAD_DOWN] = false;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 2:
|
|
||||||
dpadscrollstate[DPAD_LEFT] = false;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 3:
|
|
||||||
dpadscrollstate[DPAD_RIGHT] = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (menuactive)
|
else if (menuactive)
|
||||||
{
|
{
|
||||||
tic_t thistime = I_GetTime();
|
tic_t thistime = I_GetTime();
|
||||||
@@ -1731,6 +1707,9 @@ void M_Ticker(void)
|
|||||||
if (dedicated)
|
if (dedicated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (menuactive)
|
||||||
|
I_HandleControllerHatRepeat();
|
||||||
|
|
||||||
if (--skullAnimCounter <= 0)
|
if (--skullAnimCounter <= 0)
|
||||||
skullAnimCounter = 8;
|
skullAnimCounter = 8;
|
||||||
|
|
||||||
|
|||||||
@@ -38,16 +38,6 @@ extern boolean forceshowhud;
|
|||||||
// Does all the real work of the menu interaction.
|
// Does all the real work of the menu interaction.
|
||||||
boolean M_Responder(event_t *ev);
|
boolean M_Responder(event_t *ev);
|
||||||
|
|
||||||
// for scrolling through menus with controllers
|
|
||||||
extern boolean dpadscrollstate[4];
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
DPAD_UP,
|
|
||||||
DPAD_DOWN,
|
|
||||||
DPAD_LEFT,
|
|
||||||
DPAD_RIGHT
|
|
||||||
};
|
|
||||||
|
|
||||||
// Called by main loop, runs for demo playback. If this returns true, nullify any further user input.
|
// Called by main loop, runs for demo playback. If this returns true, nullify any further user input.
|
||||||
boolean M_DemoResponder(event_t *ev);
|
boolean M_DemoResponder(event_t *ev);
|
||||||
|
|
||||||
|
|||||||
+1
-8
@@ -608,17 +608,10 @@ Update_parameters (void)
|
|||||||
}
|
}
|
||||||
#endif/*MASTERSERVER*/
|
#endif/*MASTERSERVER*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MASTERSERVER
|
|
||||||
void Update_MS(void)
|
|
||||||
{
|
|
||||||
Update_parameters();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
static void MasterServer_OnChange(void)
|
static void MasterServer_OnChange(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
UnregisterServer();
|
UnregisterServer();
|
||||||
|
|
||||||
Set_api(cv_masterserver.string);
|
Set_api(cv_masterserver.string);
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ char *GetMODVersion(int id);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *GetMasterServerRules(void);
|
char *GetMasterServerRules(void);
|
||||||
|
|
||||||
void Update_MS(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AddMServCommands(void);
|
void AddMServCommands(void);
|
||||||
|
|||||||
+1
-1
@@ -1832,7 +1832,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_ChangeMusicSpecial (const char *mmusic)
|
void S_ChangeMusicSpecial(const char *mmusic)
|
||||||
{
|
{
|
||||||
if (cv_resetspecialmusic.value)
|
if (cv_resetspecialmusic.value)
|
||||||
S_ChangeMusic(mmusic, MUSIC_FORCERESET, true);
|
S_ChangeMusic(mmusic, MUSIC_FORCERESET, true);
|
||||||
|
|||||||
+32
-63
@@ -719,16 +719,13 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
|
|||||||
{
|
{
|
||||||
SDL_GameControllerClose(JoySet->dev);
|
SDL_GameControllerClose(JoySet->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
JoySet->dev = NULL;
|
JoySet->dev = NULL;
|
||||||
JoySet->oldjoy = -1;
|
JoySet->oldjoy = -1;
|
||||||
|
JoySet->id = -1;
|
||||||
JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0;
|
JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0;
|
||||||
//JoySet->scale
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief joystick up and running
|
|
||||||
*/
|
|
||||||
static INT32 joystick_started[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
|
|
||||||
|
|
||||||
/** \brief SDL info about joystick
|
/** \brief SDL info about joystick
|
||||||
*/
|
*/
|
||||||
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
|
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
|
||||||
@@ -783,22 +780,26 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
|
|||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
if (JoyInfo[player].dev)
|
if (JoyInfo[player].dev)
|
||||||
{
|
{
|
||||||
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1;
|
cv_usejoystick[player].value = JoyInfo[player].id + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UINT8 joystickID, compareJoystick;
|
UINT8 joystickID, compareJoystick;
|
||||||
|
|
||||||
for (joystickID = 0; joystickID < MAXSPLITSCREENPLAYERS; joystickID++)
|
for (joystickID = 0; joystickID < MAXSPLITSCREENPLAYERS; joystickID++)
|
||||||
{
|
{
|
||||||
// is this cv_usejoystick used?
|
// is this cv_usejoystick used?
|
||||||
const INT32 value = atoi(cv_usejoystick[joystickID].string);
|
const INT32 value = atoi(cv_usejoystick[joystickID].string);
|
||||||
|
|
||||||
for (compareJoystick = 0; compareJoystick < MAXSPLITSCREENPLAYERS; compareJoystick++)
|
for (compareJoystick = 0; compareJoystick < MAXSPLITSCREENPLAYERS; compareJoystick++)
|
||||||
{
|
{
|
||||||
if (compareJoystick == player)
|
if (compareJoystick == player)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (value == JoyInfo[compareJoystick].oldjoy || value == cv_usejoystick[compareJoystick].value)
|
if (value == JoyInfo[compareJoystick].oldjoy || value == cv_usejoystick[compareJoystick].value)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compareJoystick == MAXSPLITSCREENPLAYERS)
|
if (compareJoystick == MAXSPLITSCREENPLAYERS)
|
||||||
{
|
{
|
||||||
// We DID make it through the whole loop, so we can use this one!
|
// We DID make it through the whole loop, so we can use this one!
|
||||||
@@ -806,6 +807,7 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joystickID == MAXSPLITSCREENPLAYERS)
|
if (joystickID == MAXSPLITSCREENPLAYERS)
|
||||||
{
|
{
|
||||||
// We DID NOT make it through the whole loop, so we can't assign this joystick to anything.
|
// We DID NOT make it through the whole loop, so we can't assign this joystick to anything.
|
||||||
@@ -828,14 +830,6 @@ void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Joystick buttons states
|
|
||||||
*/
|
|
||||||
static UINT64 lastjoybuttons[MAXSPLITSCREENPLAYERS] = {0,0,0,0};
|
|
||||||
|
|
||||||
/** \brief Joystick hats state
|
|
||||||
*/
|
|
||||||
static UINT64 lastjoyhats[MAXSPLITSCREENPLAYERS] = {0,0,0,0};
|
|
||||||
|
|
||||||
/** \brief Shuts down joystick
|
/** \brief Shuts down joystick
|
||||||
\return void
|
\return void
|
||||||
*/
|
*/
|
||||||
@@ -847,74 +841,34 @@ void I_ShutdownJoystick(UINT8 index)
|
|||||||
event.data2 = 0;
|
event.data2 = 0;
|
||||||
event.data3 = 0;
|
event.data3 = 0;
|
||||||
|
|
||||||
lastjoybuttons[index] = lastjoyhats[index] = 0;
|
|
||||||
|
|
||||||
// emulate the up of all joystick buttons
|
// emulate the up of all joystick buttons
|
||||||
for (i = 0; i < JOYBUTTONS; i++)
|
for (i = 0; i < JOYBUTTONS; i++)
|
||||||
{
|
{
|
||||||
event.data1=KEY_JOY1 + i;
|
event.data1 = KEY_JOY1 + i;
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// emulate the up of all joystick hats
|
// emulate the up of all joystick hats
|
||||||
for (i = 0; i < JOYHATS*4; i++)
|
for (i = 0; i < JOYHATS*4; i++)
|
||||||
{
|
{
|
||||||
event.data1=KEY_HAT1+i;
|
event.data1 = KEY_HAT1+i;
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset joystick position
|
// reset joystick position
|
||||||
event.type = ev_joystick;
|
event.type = ev_joystick;
|
||||||
|
|
||||||
for (i = 0; i < JOYAXISSET; i++)
|
for (i = 0; i < JOYAXISSET; i++)
|
||||||
{
|
{
|
||||||
event.data1 = i;
|
event.data1 = i;
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
joystick_started[index] = 0;
|
|
||||||
JoyReset(&JoyInfo[index]);
|
JoyReset(&JoyInfo[index]);
|
||||||
|
|
||||||
// don't shut down the subsystem here, because hotplugging
|
// don't shut down the subsystem here, because hotplugging
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_GetJoystickEvents(UINT8 index)
|
|
||||||
{
|
|
||||||
static event_t event = {};
|
|
||||||
INT32 i = 0;
|
|
||||||
UINT64 joyhats = 0;
|
|
||||||
|
|
||||||
if (!joystick_started[index])
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!JoyInfo[index].dev) //I_ShutdownJoystick();
|
|
||||||
return;
|
|
||||||
|
|
||||||
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
|
||||||
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_DOWN) << 1;
|
|
||||||
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_LEFT) << 2;
|
|
||||||
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_RIGHT) << 3;
|
|
||||||
|
|
||||||
if (joyhats != lastjoyhats[index])
|
|
||||||
{
|
|
||||||
INT64 j = 1; // keep only bits that changed since last time
|
|
||||||
INT64 newhats = joyhats ^ lastjoyhats[index];
|
|
||||||
lastjoyhats[index] = joyhats;
|
|
||||||
|
|
||||||
for (i = 0; i < JOYHATS*4; i++, j <<= 1)
|
|
||||||
{
|
|
||||||
if (newhats & j) // hat changed state?
|
|
||||||
{
|
|
||||||
if (joyhats & j)
|
|
||||||
event.type = ev_keydown;
|
|
||||||
else
|
|
||||||
event.type = ev_keyup;
|
|
||||||
event.data1 = KEY_HAT1 + i;
|
|
||||||
D_PostEvent(&event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Open joystick handle
|
/** \brief Open joystick handle
|
||||||
|
|
||||||
\param fname name of joystick
|
\param fname name of joystick
|
||||||
@@ -931,6 +885,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||||||
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
|
CONS_Printf(M_GetText("Joystick subsystem not started\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
|
||||||
@@ -965,12 +920,14 @@ static int joy_open(int playerIndex, int joyIndex)
|
|||||||
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|
||||||
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
|
||||||
return SDL_CONTROLLER_AXIS_MAX;
|
return SDL_CONTROLLER_AXIS_MAX;
|
||||||
|
|
||||||
// Else, we're changing devices, so send neutral joy events
|
// Else, we're changing devices, so send neutral joy events
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
|
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
|
||||||
I_ShutdownJoystick(playerIndex);
|
I_ShutdownJoystick(playerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
JoyInfo[playerIndex].dev = newdev;
|
JoyInfo[playerIndex].dev = newdev;
|
||||||
|
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
|
||||||
|
|
||||||
if (JoyInfo[playerIndex].dev == NULL)
|
if (JoyInfo[playerIndex].dev == NULL)
|
||||||
{
|
{
|
||||||
@@ -1007,8 +964,9 @@ void I_InitJoystick(UINT8 index)
|
|||||||
UINT8 i;
|
UINT8 i;
|
||||||
SDL_GameController *newcontroller = NULL;
|
SDL_GameController *newcontroller = NULL;
|
||||||
|
|
||||||
//I_ShutdownJoystick();
|
// not sure if this is the best place to put this
|
||||||
//SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE);
|
SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0");
|
||||||
|
|
||||||
if (M_CheckParm("-nojoy"))
|
if (M_CheckParm("-nojoy"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1037,6 +995,11 @@ void I_InitJoystick(UINT8 index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JoyInfo[index].dev = NULL;
|
||||||
|
JoyInfo[index].oldjoy = -1;
|
||||||
|
JoyInfo[index].id = -1;
|
||||||
|
JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
|
||||||
|
|
||||||
if (cv_usejoystick[index].value)
|
if (cv_usejoystick[index].value)
|
||||||
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
|
||||||
|
|
||||||
@@ -1049,23 +1012,24 @@ void I_InitJoystick(UINT8 index)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev);
|
||||||
|
|
||||||
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
|
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
|
||||||
{
|
{
|
||||||
cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
cv_usejoystick[index].value = JoyInfo[index].id + 1;
|
||||||
}
|
}
|
||||||
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
|
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
|
||||||
{
|
{
|
||||||
// SDL's device indexes are unstable, so cv_usejoystick may not match
|
// SDL's device indexes are unstable, so cv_usejoystick may not match
|
||||||
// the actual device index. So let's cheat a bit and find the device's current index.
|
// the actual device index. So let's cheat a bit and find the device's current index.
|
||||||
JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||||
joystick_started[index] = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (JoyInfo[index].oldjoy)
|
if (JoyInfo[index].oldjoy)
|
||||||
I_ShutdownJoystick(index);
|
I_ShutdownJoystick(index);
|
||||||
|
|
||||||
cv_usejoystick[index].value = 0;
|
cv_usejoystick[index].value = 0;
|
||||||
joystick_started[index] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
@@ -1130,8 +1094,10 @@ static void I_ShutdownInput(void)
|
|||||||
INT32 I_NumJoys(void)
|
INT32 I_NumJoys(void)
|
||||||
{
|
{
|
||||||
INT32 numjoy = 0;
|
INT32 numjoy = 0;
|
||||||
|
|
||||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||||
numjoy = SDL_NumJoysticks();
|
numjoy = SDL_NumJoysticks();
|
||||||
|
|
||||||
return numjoy;
|
return numjoy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1142,15 +1108,18 @@ const char *I_GetJoyName(INT32 joyindex)
|
|||||||
const char *tempname = NULL;
|
const char *tempname = NULL;
|
||||||
joyname[0] = 0;
|
joyname[0] = 0;
|
||||||
joyindex--; //SDL's Joystick System starts at 0, not 1
|
joyindex--; //SDL's Joystick System starts at 0, not 1
|
||||||
|
|
||||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||||
{
|
{
|
||||||
tempname = SDL_JoystickNameForIndex(joyindex);
|
tempname = SDL_JoystickNameForIndex(joyindex);
|
||||||
|
|
||||||
if (tempname)
|
if (tempname)
|
||||||
{
|
{
|
||||||
memcpy(joyname, tempname, 255);
|
memcpy(joyname, tempname, 255);
|
||||||
joyname[255] = '\0';
|
joyname[255] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return joyname;
|
return joyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+135
-56
@@ -558,7 +558,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
|||||||
|
|
||||||
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event = {0};
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -586,7 +586,9 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.data1)
|
if (event.data1)
|
||||||
|
{
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
@@ -638,7 +640,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
|||||||
|
|
||||||
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event = {0};
|
||||||
|
|
||||||
// Ignore the event if the mouse is not actually focused on the window.
|
// Ignore the event if the mouse is not actually focused on the window.
|
||||||
// This can happen if you used the mouse to restore keyboard focus;
|
// This can happen if you used the mouse to restore keyboard focus;
|
||||||
@@ -651,8 +653,6 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
|||||||
/// \todo inputEvent.button.which
|
/// \todo inputEvent.button.which
|
||||||
if (USE_MOUSEINPUT)
|
if (USE_MOUSEINPUT)
|
||||||
{
|
{
|
||||||
SDL_memset(&event, 0, sizeof(event_t));
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
@@ -693,27 +693,28 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
|||||||
|
|
||||||
static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event = {0};
|
||||||
|
|
||||||
if (USE_MOUSEINPUT)
|
if (USE_MOUSEINPUT)
|
||||||
{
|
{
|
||||||
SDL_memset(&event, 0, sizeof(event_t));
|
|
||||||
|
|
||||||
if (evt.y > 0)
|
if (evt.y > 0)
|
||||||
{
|
{
|
||||||
event.data1 = KEY_MOUSEWHEELUP;
|
event.data1 = KEY_MOUSEWHEELUP;
|
||||||
event.type = ev_keydown;
|
event.type = ev_keydown;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.y < 0)
|
if (evt.y < 0)
|
||||||
{
|
{
|
||||||
event.data1 = KEY_MOUSEWHEELDOWN;
|
event.data1 = KEY_MOUSEWHEELDOWN;
|
||||||
event.type = ev_keydown;
|
event.type = ev_keydown;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.y == 0)
|
if (evt.y == 0)
|
||||||
{
|
{
|
||||||
event.data1 = 0;
|
event.data1 = 0;
|
||||||
event.type = ev_keyup;
|
event.type = ev_keyup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == ev_keyup || event.type == ev_keydown)
|
if (event.type == ev_keyup || event.type == ev_keydown)
|
||||||
{
|
{
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
@@ -721,40 +722,78 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UINT8 hatrepeattimer[MAXSPLITSCREENPLAYERS];
|
||||||
|
#define HATREPEATDELAY 19
|
||||||
|
|
||||||
|
void I_HandleControllerHatRepeat(void)
|
||||||
|
{
|
||||||
|
// why bother if theres no controllers?
|
||||||
|
if (numcontrollers == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
event_t event = {ev_keydown, 0, 0, 0};
|
||||||
|
|
||||||
|
static const SDL_GameControllerButton hatbutt[4] =
|
||||||
|
{
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_UP,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||||
|
SDL_CONTROLLER_BUTTON_DPAD_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (!cv_usejoystick[i].value)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SDL_GameController *controller = JoyInfo[i].dev;
|
||||||
|
|
||||||
|
if (!controller)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (UINT8 h = 0; h < JOYHATS; h++)
|
||||||
|
{
|
||||||
|
if (SDL_GameControllerGetButton(controller, hatbutt[h]))
|
||||||
|
{
|
||||||
|
if (hatrepeattimer[i] < HATREPEATDELAY)
|
||||||
|
{
|
||||||
|
hatrepeattimer[i]++;
|
||||||
|
}
|
||||||
|
else if (hatrepeattimer[i] == HATREPEATDELAY)
|
||||||
|
{
|
||||||
|
event.data1 = KEY_HAT1 + (i * JOYHATS) + h;
|
||||||
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hatrepeattimer[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event;
|
||||||
SDL_JoystickID joyid[4];
|
|
||||||
INT32 value;
|
INT32 value;
|
||||||
UINT8 i;
|
UINT8 i;
|
||||||
|
|
||||||
// Determine the Joystick IDs for each current open joystick
|
// Determine the Joystick IDs for each current open joystick
|
||||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
{
|
{
|
||||||
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev));
|
if (evt.which == JoyInfo[i].id)
|
||||||
|
{
|
||||||
|
event.type = ev_joystick + i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == MAXSPLITSCREENPLAYERS)
|
||||||
|
return;
|
||||||
|
|
||||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
||||||
|
|
||||||
if (evt.which == joyid[0])
|
|
||||||
{
|
|
||||||
event.type = ev_joystick;
|
|
||||||
}
|
|
||||||
else if (evt.which == joyid[1])
|
|
||||||
{
|
|
||||||
event.type = ev_joystick2;
|
|
||||||
}
|
|
||||||
else if (evt.which == joyid[2])
|
|
||||||
{
|
|
||||||
event.type = ev_joystick3;
|
|
||||||
}
|
|
||||||
else if (evt.which == joyid[3])
|
|
||||||
{
|
|
||||||
event.type = ev_joystick4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
//axis
|
//axis
|
||||||
if (evt.axis > JOYAXISSET*2)
|
if (evt.axis > JOYAXISSET*2)
|
||||||
return;
|
return;
|
||||||
@@ -790,47 +829,89 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type)
|
static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32 type)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event = {0};
|
||||||
SDL_JoystickID joyid[4];
|
|
||||||
UINT8 i;
|
UINT8 i;
|
||||||
|
static const int hat_buttons_base[] = {KEY_HAT1, KEY_2HAT1, KEY_3HAT1, KEY_4HAT1};
|
||||||
|
|
||||||
// Determine the Joystick IDs for each current open joystick
|
// Determine the Joystick IDs for each current open joystick
|
||||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
{
|
{
|
||||||
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev));
|
if (evt.which == JoyInfo[i].id)
|
||||||
|
{
|
||||||
|
event.data1 = hat_buttons_base[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP
|
if (i == MAXSPLITSCREENPLAYERS)
|
||||||
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN
|
return;
|
||||||
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT
|
|
||||||
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
switch (type)
|
||||||
{
|
{
|
||||||
// dpad buttons are mapped as the hat instead
|
case SDL_CONTROLLERBUTTONUP:
|
||||||
|
event.type = ev_keyup;
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
|
event.type = ev_keydown;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (evt.button)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
||||||
|
event.data1 += 1;
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
|
||||||
|
event.data1 += 2;
|
||||||
|
break;
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||||
|
event.data1 += 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.type != ev_console)
|
||||||
|
{
|
||||||
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type)
|
||||||
|
{
|
||||||
|
event_t event = {0};
|
||||||
|
UINT8 i;
|
||||||
|
static const int buttons_base[] = {KEY_JOY1, KEY_2JOY1, KEY_3JOY1, KEY_4JOY1};
|
||||||
|
|
||||||
|
// dpad special case handling
|
||||||
|
if (evt.button >= SDL_CONTROLLER_BUTTON_DPAD_UP &&
|
||||||
|
evt.button <= SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||||
|
{
|
||||||
|
Impl_HandleControllerHatEvent(evt, type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.which == joyid[0])
|
// Determine the Joystick IDs for each current open joystick
|
||||||
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
{
|
{
|
||||||
event.data1 = KEY_JOY1;
|
if (evt.which == JoyInfo[i].id)
|
||||||
|
{
|
||||||
|
event.data1 = buttons_base[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (evt.which == joyid[1])
|
|
||||||
{
|
if (i == MAXSPLITSCREENPLAYERS)
|
||||||
event.data1 = KEY_2JOY1;
|
|
||||||
}
|
|
||||||
else if (evt.which == joyid[2])
|
|
||||||
{
|
|
||||||
event.data1 = KEY_3JOY1;
|
|
||||||
}
|
|
||||||
else if (evt.which == joyid[3])
|
|
||||||
{
|
|
||||||
event.data1 = KEY_4JOY1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -853,7 +934,9 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.type != ev_console)
|
if (event.type != ev_console)
|
||||||
|
{
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Impl_HandleControllerAddedEvent(SDL_Event evt)
|
static void Impl_HandleControllerAddedEvent(SDL_Event evt)
|
||||||
@@ -1097,7 +1180,6 @@ void I_StartupMouse(void)
|
|||||||
void I_OsPolling(void)
|
void I_OsPolling(void)
|
||||||
{
|
{
|
||||||
SDL_Keymod mod;
|
SDL_Keymod mod;
|
||||||
INT32 i;
|
|
||||||
|
|
||||||
if (consolevent)
|
if (consolevent)
|
||||||
I_GetConsoleEvents();
|
I_GetConsoleEvents();
|
||||||
@@ -1105,9 +1187,6 @@ void I_OsPolling(void)
|
|||||||
if (SDL_WasInit(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER))
|
if (SDL_WasInit(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER))
|
||||||
{
|
{
|
||||||
SDL_GameControllerUpdate();
|
SDL_GameControllerUpdate();
|
||||||
|
|
||||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
|
||||||
I_GetJoystickEvents(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
I_GetEvent();
|
I_GetEvent();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ write netcode into the sound code, OKAY?
|
|||||||
|
|
||||||
|
|
||||||
//static UINT16 BUFFERSIZE = 2048;
|
//static UINT16 BUFFERSIZE = 2048;
|
||||||
static UINT16 SAMPLERATE = 44100;
|
static const UINT16 SAMPLERATE = 44100;
|
||||||
|
|
||||||
#ifdef HAVE_OPENMPT
|
#ifdef HAVE_OPENMPT
|
||||||
#include "libopenmpt/libopenmpt.h"
|
#include "libopenmpt/libopenmpt.h"
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ typedef struct SDLJoyInfo_s
|
|||||||
{
|
{
|
||||||
/// Controller handle
|
/// Controller handle
|
||||||
SDL_GameController *dev;
|
SDL_GameController *dev;
|
||||||
|
/// Controller index
|
||||||
|
INT32 id;
|
||||||
/// number of old joystick
|
/// number of old joystick
|
||||||
int oldjoy;
|
int oldjoy;
|
||||||
/// number of axies
|
/// number of axies
|
||||||
|
|||||||
Reference in new issue
Block a user