Remove mouse input device #713

This commit is contained in:
Cong
2021-09-26 12:43:31 +10:00
parent 67fcc60f89
commit 60fb5404a1
16 changed files with 24 additions and 218 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

View File

@@ -288,36 +288,6 @@ int GetKeyboardCmd(
return cmd; return cmd;
} }
static int GetMouseCmd(
Mouse *mouse, bool isPressed, int useMouseMove, struct vec2i pos)
{
int cmd = 0;
bool (*mouseFunc)(const Mouse *, const int) =
isPressed ? MouseIsPressed : MouseIsDown;
if (useMouseMove)
{
cmd |= MouseGetMove(mouse, pos);
}
else
{
if (MouseWheel(mouse).y > 0)
cmd |= CMD_UP;
else if (MouseWheel(mouse).y < 0)
cmd |= CMD_DOWN;
}
if (mouseFunc(mouse, SDL_BUTTON_LEFT))
cmd |= CMD_BUTTON1;
if (mouseFunc(mouse, SDL_BUTTON_RIGHT))
cmd |= CMD_BUTTON2;
if (mouseFunc(mouse, SDL_BUTTON_MIDDLE))
cmd |= CMD_GRENADE;
if (mouseFunc(mouse, SDL_BUTTON_X1))
cmd |= CMD_MAP;
return cmd;
}
static int GetJoystickCmd(const SDL_JoystickID id, bool isPressed) static int GetJoystickCmd(const SDL_JoystickID id, bool isPressed)
{ {
@@ -351,9 +321,7 @@ static int GetJoystickCmd(const SDL_JoystickID id, bool isPressed)
return cmd; return cmd;
} }
int GetGameCmd( int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData)
EventHandlers *handlers, const PlayerData *playerData,
const struct vec2i playerPos)
{ {
int cmd = 0; int cmd = 0;
@@ -363,9 +331,6 @@ int GetGameCmd(
cmd = GetKeyboardCmd( cmd = GetKeyboardCmd(
&handlers->keyboard, playerData->deviceIndex, false); &handlers->keyboard, playerData->deviceIndex, false);
break; break;
case INPUT_DEVICE_MOUSE:
cmd = GetMouseCmd(&handlers->mouse, false, 1, playerPos);
break;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
cmd = GetJoystickCmd(playerData->deviceIndex, false); cmd = GetJoystickCmd(playerData->deviceIndex, false);
break; break;
@@ -387,9 +352,6 @@ int GetOnePlayerCmd(
case INPUT_DEVICE_KEYBOARD: case INPUT_DEVICE_KEYBOARD:
cmd = GetKeyboardCmd(&handlers->keyboard, deviceIndex, isPressed); cmd = GetKeyboardCmd(&handlers->keyboard, deviceIndex, isPressed);
break; break;
case INPUT_DEVICE_MOUSE:
cmd = GetMouseCmd(&handlers->mouse, isPressed, 0, svec2i_zero());
break;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
cmd = GetJoystickCmd(deviceIndex, isPressed); cmd = GetJoystickCmd(deviceIndex, isPressed);
break; break;
@@ -465,7 +427,8 @@ int GetMenuCmd(EventHandlers *handlers)
if (!cmd) if (!cmd)
{ {
// Check mouse // Check mouse
cmd = GetOnePlayerCmd(handlers, true, INPUT_DEVICE_MOUSE, 0); if (MouseIsPressed(&handlers->mouse, SDL_BUTTON_LEFT))
cmd |= CMD_BUTTON1;
} }
return cmd; return cmd;
@@ -557,38 +520,6 @@ void InputGetButtonNameColor(
} }
#endif #endif
break; break;
case INPUT_DEVICE_MOUSE:
switch (cmd)
{
case CMD_LEFT:
strcpy(buf, "left");
return;
case CMD_RIGHT:
strcpy(buf, "right");
return;
case CMD_UP:
strcpy(buf, "up");
return;
case CMD_DOWN:
strcpy(buf, "down");
return;
case CMD_BUTTON1:
strcpy(buf, "left click");
return;
case CMD_BUTTON2:
strcpy(buf, "right click");
return;
case CMD_MAP:
strcpy(buf, "middle click");
return;
case CMD_ESC:
strcpy(buf, "");
return;
default:
CASSERT(false, "unknown button");
return;
}
break;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
JoyButtonNameColor(dIndex, cmd, buf, color); JoyButtonNameColor(dIndex, cmd, buf, color);
return; return;
@@ -614,9 +545,6 @@ void InputGetDirectionNames(
sprintf(buf, "%s, %s, %s, %s", left, right, up, down); sprintf(buf, "%s, %s, %s, %s", left, right, up, down);
} }
break; break;
case INPUT_DEVICE_MOUSE:
strcpy(buf, "mouse wheel");
break;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
strcpy(buf, "directions"); strcpy(buf, "directions");
break; break;
@@ -639,8 +567,6 @@ bool InputHasGrenadeButton(const input_device_e d, const int dIndex)
return KeyGet( return KeyGet(
&gEventHandlers.keyboard.PlayerKeys[dIndex], &gEventHandlers.keyboard.PlayerKeys[dIndex],
KEY_CODE_GRENADE) != SDL_SCANCODE_UNKNOWN; KEY_CODE_GRENADE) != SDL_SCANCODE_UNKNOWN;
case INPUT_DEVICE_MOUSE:
return true;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
return true; return true;
case INPUT_DEVICE_AI: case INPUT_DEVICE_AI:

View File

@@ -60,9 +60,7 @@ void EventPoll(
int GetOnePlayerCmd( int GetOnePlayerCmd(
EventHandlers *handlers, const bool isPressed, const input_device_e device, EventHandlers *handlers, const bool isPressed, const input_device_e device,
const int deviceIndex); const int deviceIndex);
int GetGameCmd( int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData);
EventHandlers *handlers, const PlayerData *playerData,
const struct vec2i playerPos);
int GetKeyboardCmd( int GetKeyboardCmd(
keyboard_t *keyboard, const int kbIndex, const bool isPressed); keyboard_t *keyboard, const int kbIndex, const bool isPressed);
SDL_Scancode GetKey(EventHandlers *handlers); SDL_Scancode GetKey(EventHandlers *handlers);

View File

@@ -145,18 +145,3 @@ void MissionOptionsTerminate(struct MissionOptions *mo)
memset(mo, 0, sizeof *mo); memset(mo, 0, sizeof *mo);
} }
bool GameIsMouseUsed(void)
{
CA_FOREACH(const PlayerData, p, gPlayerDatas)
if (p->IsLocal && p->inputDevice == INPUT_DEVICE_MOUSE)
{
const TActor *a = ActorGetByUID(p->ActorUID);
if (a == NULL) continue;
if (a->dead) continue;
return true;
}
CA_FOREACH_END()
return false;
}

View File

@@ -72,5 +72,3 @@ void CampaignUnload(Campaign *co);
void MissionOptionsInit(struct MissionOptions *mo); void MissionOptionsInit(struct MissionOptions *mo);
void MissionOptionsTerminate(struct MissionOptions *mo); void MissionOptionsTerminate(struct MissionOptions *mo);
bool GameIsMouseUsed(void);

View File

@@ -225,7 +225,7 @@ void MouseSetCursor(Mouse *m, const SDL_SystemCursor sc)
SDL_SetCursor(m->cursors[sc]); SDL_SetCursor(m->cursors[sc]);
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
} }
void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail) void MouseSetPicCursor(Mouse *m, const Pic *cursor)
{ {
if (cursor) if (cursor)
{ {
@@ -256,34 +256,5 @@ void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail)
} }
m->cursor = NULL; m->cursor = NULL;
} }
m->trail = trail;
SDL_ShowCursor(cursor != NULL ? SDL_ENABLE : SDL_DISABLE); SDL_ShowCursor(cursor != NULL ? SDL_ENABLE : SDL_DISABLE);
} }
void MouseDraw(const Mouse *mouse)
{
if (mouse->trail)
{
const int dx = abs(mouse->currentPos.x - mouse->mouseMovePos.x);
const int dy = abs(mouse->currentPos.y - mouse->mouseMovePos.y);
const bool isInDeadZone =
dx <= MOUSE_MOVE_DEAD_ZONE && dy <= MOUSE_MOVE_DEAD_ZONE;
if (!isInDeadZone)
{
// Draw a trail between the mouse move pos and mouse pos
// The trail is made up of a fixed number of dots
const struct vec2i d =
svec2i_subtract(mouse->currentPos, mouse->mouseMovePos);
for (int i = 1; i <= TRAIL_NUM_DOTS; i++)
{
const struct vec2i pos = svec2i_add(
mouse->mouseMovePos,
svec2i_scale_divide(
svec2i_scale(d, (float)i), TRAIL_NUM_DOTS + 1));
PicRender(
mouse->trail, gGraphicsDevice.gameWindow.renderer, pos,
colorWhite, 0, svec2_one(), SDL_FLIP_NONE, Rect2iZero());
}
}
}
}

View File

@@ -43,7 +43,6 @@ typedef struct
struct vec2i currentPos; struct vec2i currentPos;
struct vec2i wheel; struct vec2i wheel;
SDL_Cursor *cursor; SDL_Cursor *cursor;
const Pic *trail;
Uint32 repeatedTicks; Uint32 repeatedTicks;
struct vec2i mouseMovePos; struct vec2i mouseMovePos;
@@ -67,8 +66,6 @@ bool MouseIsReleased(const Mouse *m, const int button);
// Get wheel movement since last poll // Get wheel movement since last poll
struct vec2i MouseWheel(const Mouse *m); struct vec2i MouseWheel(const Mouse *m);
// Get mouse movement from a screen position // Get mouse movement from a screen position
// Note: also sets whether the mouse trail is drawn, and from where
int MouseGetMove(Mouse *mouse, const struct vec2i pos); int MouseGetMove(Mouse *mouse, const struct vec2i pos);
void MouseSetCursor(Mouse *m, const SDL_SystemCursor sc); void MouseSetCursor(Mouse *m, const SDL_SystemCursor sc);
void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail); void MouseSetPicCursor(Mouse *m, const Pic *cursor);
void MouseDraw(const Mouse *mouse);

View File

@@ -457,8 +457,6 @@ const char *InputDeviceName(const int d, const int deviceIndex)
{ {
case INPUT_DEVICE_KEYBOARD: case INPUT_DEVICE_KEYBOARD:
return "Keyboard"; return "Keyboard";
case INPUT_DEVICE_MOUSE:
return "Mouse";
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
return JoyName(deviceIndex); return JoyName(deviceIndex);
case INPUT_DEVICE_AI: case INPUT_DEVICE_AI:

View File

@@ -166,7 +166,6 @@ typedef enum
{ {
INPUT_DEVICE_UNSET, INPUT_DEVICE_UNSET,
INPUT_DEVICE_KEYBOARD, INPUT_DEVICE_KEYBOARD,
INPUT_DEVICE_MOUSE,
INPUT_DEVICE_JOYSTICK, INPUT_DEVICE_JOYSTICK,
// Fake device used for co-op AI // Fake device used for co-op AI

View File

@@ -247,7 +247,6 @@ static void Display(HandleInputResult result)
UITooltipDraw( UITooltipDraw(
ec.g, gEventHandlers.mouse.currentPos, sTooltipObj->Tooltip); ec.g, gEventHandlers.mouse.currentPos, sTooltipObj->Tooltip);
} }
MouseDraw(&gEventHandlers.mouse);
} }
BlitUpdateFromBuf(ec.g, ec.g->screen); BlitUpdateFromBuf(ec.g, ec.g->screen);
WindowContextPostRender(&ec.g->gameWindow); WindowContextPostRender(&ec.g->gameWindow);

View File

@@ -214,7 +214,7 @@ static EditorResult BrushSetBrushTypePoint(void *data, int d)
b->Type = BRUSHTYPE_POINT; b->Type = BRUSHTYPE_POINT;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/pencil"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/pencil"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeLine(void *data, int d) static EditorResult BrushSetBrushTypeLine(void *data, int d)
@@ -224,7 +224,7 @@ static EditorResult BrushSetBrushTypeLine(void *data, int d)
b->Type = BRUSHTYPE_LINE; b->Type = BRUSHTYPE_LINE;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/line"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/line"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeBox(void *data, int d) static EditorResult BrushSetBrushTypeBox(void *data, int d)
@@ -234,7 +234,7 @@ static EditorResult BrushSetBrushTypeBox(void *data, int d)
b->Type = BRUSHTYPE_BOX; b->Type = BRUSHTYPE_BOX;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/box"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/box"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeBoxFilled(void *data, int d) static EditorResult BrushSetBrushTypeBoxFilled(void *data, int d)
@@ -244,7 +244,7 @@ static EditorResult BrushSetBrushTypeBoxFilled(void *data, int d)
b->Type = BRUSHTYPE_BOX_FILLED; b->Type = BRUSHTYPE_BOX_FILLED;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/box_filled"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/box_filled"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeBoxAndFill(void *data, int d) static EditorResult BrushSetBrushTypeBoxAndFill(void *data, int d)
@@ -254,7 +254,7 @@ static EditorResult BrushSetBrushTypeBoxAndFill(void *data, int d)
b->Type = BRUSHTYPE_BOX_AND_FILL; b->Type = BRUSHTYPE_BOX_AND_FILL;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/box_n_fill"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/box_n_fill"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeSelect(void *data, int d) static EditorResult BrushSetBrushTypeSelect(void *data, int d)
@@ -264,7 +264,7 @@ static EditorResult BrushSetBrushTypeSelect(void *data, int d)
b->Type = BRUSHTYPE_SELECT; b->Type = BRUSHTYPE_SELECT;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/select"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/select"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeFill(void *data, int d) static EditorResult BrushSetBrushTypeFill(void *data, int d)
@@ -274,7 +274,7 @@ static EditorResult BrushSetBrushTypeFill(void *data, int d)
b->Type = BRUSHTYPE_FILL; b->Type = BRUSHTYPE_FILL;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/bucket"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/bucket"));
return EDITOR_RESULT_NONE; return EDITOR_RESULT_NONE;
} }
static EditorResult BrushSetBrushTypeSetExit(void *data, int d) static EditorResult BrushSetBrushTypeSetExit(void *data, int d)
@@ -286,7 +286,7 @@ static EditorResult BrushSetBrushTypeSetExit(void *data, int d)
b->Type = BRUSHTYPE_SET_EXIT; b->Type = BRUSHTYPE_SET_EXIT;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/set_exit"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/set_exit"));
return result; return result;
} }
static EditorResult BrushSetBrushTypeSetKey(void *data, int d) static EditorResult BrushSetBrushTypeSetKey(void *data, int d)
@@ -297,7 +297,7 @@ static EditorResult BrushSetBrushTypeSetKey(void *data, int d)
b->Brush->u.ItemIndex = b->u.ItemIndex; b->Brush->u.ItemIndex = b->u.ItemIndex;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/set_key"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/set_key"));
return EDITOR_RESULT_CHANGE_TOOL; return EDITOR_RESULT_CHANGE_TOOL;
} }
static void ActivateBrush(UIObject *o, void *data) static void ActivateBrush(UIObject *o, void *data)

View File

@@ -59,7 +59,7 @@ static EditorResult BrushSetBrushTypeAddMapItem(void *data, int d)
b->Brush->u.MapObject = b->u.MapObject; b->Brush->u.MapObject = b->u.MapObject;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/add"));
return EDITOR_RESULT_CHANGE_TOOL; return EDITOR_RESULT_CHANGE_TOOL;
} }
static EditorResult BrushSetBrushTypeAddCharacter(void *data, int d) static EditorResult BrushSetBrushTypeAddCharacter(void *data, int d)
@@ -70,7 +70,7 @@ static EditorResult BrushSetBrushTypeAddCharacter(void *data, int d)
b->Brush->u.ItemIndex = b->u.ItemIndex; b->Brush->u.ItemIndex = b->u.ItemIndex;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/add"));
return EDITOR_RESULT_CHANGE_TOOL; return EDITOR_RESULT_CHANGE_TOOL;
} }
static EditorResult BrushSetBrushTypeAddObjective(void *data, int d) static EditorResult BrushSetBrushTypeAddObjective(void *data, int d)
@@ -82,7 +82,7 @@ static EditorResult BrushSetBrushTypeAddObjective(void *data, int d)
b->Brush->Index2 = b->Index2; b->Brush->Index2 = b->Index2;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/add"));
return EDITOR_RESULT_CHANGE_TOOL; return EDITOR_RESULT_CHANGE_TOOL;
} }
static EditorResult BrushSetBrushTypeAddKey(void *data, int d) static EditorResult BrushSetBrushTypeAddKey(void *data, int d)
@@ -93,7 +93,7 @@ static EditorResult BrushSetBrushTypeAddKey(void *data, int d)
b->Brush->u.ItemIndex = b->u.ItemIndex; b->Brush->u.ItemIndex = b->u.ItemIndex;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/add"));
return EDITOR_RESULT_CHANGE_TOOL; return EDITOR_RESULT_CHANGE_TOOL;
} }
static EditorResult BrushSetBrushTypeAddPickup(void *data, int d) static EditorResult BrushSetBrushTypeAddPickup(void *data, int d)
@@ -107,7 +107,7 @@ static EditorResult BrushSetBrushTypeAddPickup(void *data, int d)
b->Type = BRUSHTYPE_ADD_PICKUP; b->Type = BRUSHTYPE_ADD_PICKUP;
MouseSetPicCursor( MouseSetPicCursor(
&gEventHandlers.mouse, &gEventHandlers.mouse,
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL); PicManagerGetPic(&gPicManager, "editor/cursors/add"));
return AddPickupDialog(&gPicManager, &gEventHandlers, &b->u.Pickup); return AddPickupDialog(&gPicManager, &gEventHandlers, &b->u.Pickup);
} }

View File

@@ -108,52 +108,6 @@ static void PlayerSpecialCommands(TActor *actor, const int cmd)
} }
} }
// TODO: reimplement in camera
struct vec2i GetPlayerCenter(
GraphicsDevice *device, const Camera *camera, const PlayerData *pData,
const int playerIdx)
{
if (pData->ActorUID < 0)
{
// Player is dead
return svec2i_zero();
}
struct vec2i center = svec2i_zero();
int w = device->cachedConfig.Res.x;
int h = device->cachedConfig.Res.y;
if (GetNumPlayers(PLAYER_ANY, true, true) == 1 ||
GetNumPlayers(PLAYER_ANY, false, true) == 1 || CameraIsSingleScreen())
{
const struct vec2 pCenter = camera->lastPosition;
const struct vec2i screenCenter =
svec2i(w / 2, device->cachedConfig.Res.y / 2);
const TActor *actor = ActorGetByUID(pData->ActorUID);
const struct vec2 p = actor->thing.Pos;
center = svec2i_add(
svec2i_assign_vec2(svec2_subtract(p, pCenter)), screenCenter);
}
else
{
const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true);
if (numLocalPlayers == 2)
{
center.x = playerIdx == 0 ? w / 4 : w * 3 / 4;
center.y = h / 2;
}
else if (numLocalPlayers >= 3 && numLocalPlayers <= 4)
{
center.x = (playerIdx & 1) ? w * 3 / 4 : w / 4;
center.y = (playerIdx >= 2) ? h * 3 / 4 : h / 4;
}
else
{
CASSERT(false, "invalid number of players");
}
}
return center;
}
static void RunGameTerminate(GameLoopData *data); static void RunGameTerminate(GameLoopData *data);
static void RunGameOnEnter(GameLoopData *data); static void RunGameOnEnter(GameLoopData *data);
static void RunGameOnExit(GameLoopData *data); static void RunGameOnExit(GameLoopData *data);
@@ -264,9 +218,7 @@ static void RunGameOnEnter(GameLoopData *data)
Pic *crosshair = PicManagerGetPic(&gPicManager, "crosshair"); Pic *crosshair = PicManagerGetPic(&gPicManager, "crosshair");
crosshair->offset.x = -crosshair->size.x / 2; crosshair->offset.x = -crosshair->size.x / 2;
crosshair->offset.y = -crosshair->size.y / 2; crosshair->offset.y = -crosshair->size.y / 2;
MouseSetPicCursor( MouseSetPicCursor(&gEventHandlers.mouse, crosshair);
&gEventHandlers.mouse, crosshair,
PicManagerGetPic(&gPicManager, "crosshair_trail"));
NetServerSendGameStartMessages(&gNetServer, NET_SERVER_BCAST); NetServerSendGameStartMessages(&gNetServer, NET_SERVER_BCAST);
GameEvent start = GameEventNew(GAME_EVENT_GAME_START); GameEvent start = GameEventNew(GAME_EVENT_GAME_START);
@@ -382,9 +334,7 @@ static void RunGameInput(GameLoopData *data)
{ {
firstPausingDevice = p->inputDevice; firstPausingDevice = p->inputDevice;
} }
rData->cmds[idx] = GetGameCmd( rData->cmds[idx] = GetGameCmd(&gEventHandlers, p);
&gEventHandlers, p,
GetPlayerCenter(&gGraphicsDevice, &rData->Camera, p, idx));
cmdAll |= rData->cmds[idx]; cmdAll |= rData->cmds[idx];
// Only allow the first player to escape // Only allow the first player to escape
@@ -756,11 +706,6 @@ static void RunGameDraw(GameLoopData *data)
HUDDraw( HUDDraw(
&rData->Camera.HUD, rData->pausingDevice, rData->controllerUnplugged, &rData->Camera.HUD, rData->pausingDevice, rData->controllerUnplugged,
rData->Camera.NumViews); rData->Camera.NumViews);
const bool isMouse = GameIsMouseUsed();
if (isMouse)
{
MouseDraw(&gEventHandlers.mouse);
}
// Draw automap if enabled // Draw automap if enabled
if (rData->isMap) if (rData->isMap)
{ {

View File

@@ -109,10 +109,6 @@ void MenuDisplayPlayerControls(
FontStr(s, svec2i(pos.x - FontStrW(s) / 2, y - FontH())); FontStr(s, svec2i(pos.x - FontStrW(s) / 2, y - FontH()));
} }
break; break;
case INPUT_DEVICE_MOUSE:
sprintf(s, "(%s to scroll,\nleft and right click)", directionNames);
FontStr(s, svec2i(pos.x - FontStrW(s) / 2, y - FontH()));
break;
case INPUT_DEVICE_JOYSTICK: case INPUT_DEVICE_JOYSTICK:
{ {
sprintf(s, "(%s,", sprintf(s, "(%s,",

View File

@@ -287,12 +287,6 @@ static void AssignPlayerInputDevices(EventHandlers *handlers)
break; break;
} }
} }
if (MouseIsPressed(&handlers->mouse, SDL_BUTTON_LEFT) &&
PlayerTrySetUnusedInputDevice(p, INPUT_DEVICE_MOUSE, 0))
{
MenuPlaySound(MENU_SOUND_START);
continue;
}
for (int j = 0; j < (int)handlers->joysticks.size; j++) for (int j = 0; j < (int)handlers->joysticks.size; j++)
{ {
const Joystick *joy = CArrayGet(&handlers->joysticks, j); const Joystick *joy = CArrayGet(&handlers->joysticks, j);
@@ -493,7 +487,7 @@ static void PlayerSelectionDraw(GameLoopData *data)
else else
{ {
struct vec2i center = svec2i_zero(); struct vec2i center = svec2i_zero();
const char *prompt = "Press Fire to join..."; const char *prompt = "Press Fire to choose input device and join...";
const struct vec2i offset = const struct vec2i offset =
svec2i_scale_divide(FontStrSize(prompt), -2); svec2i_scale_divide(FontStrSize(prompt), -2);
switch (GetNumPlayers(false, false, true)) switch (GetNumPlayers(false, false, true))

View File

@@ -45,7 +45,7 @@ FEATURE(assign_unused, "Assign unused input device")
const int idx = 0; const int idx = 0;
p->deviceIndex = idx; p->deviceIndex = idx;
WHEN("I assign it with a different input device") WHEN("I assign it with a different input device")
bool res = PlayerTrySetUnusedInputDevice(p, INPUT_DEVICE_MOUSE, 0); bool res = PlayerTrySetUnusedInputDevice(p, INPUT_DEVICE_JOYSTICK, 0);
THEN("the assignment should fail") THEN("the assignment should fail")
SHOULD_BE_FALSE(res); SHOULD_BE_FALSE(res);
AND("the player's input device should be unchanged") AND("the player's input device should be unchanged")