mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 15:30:35 +02:00
Remove mouse input device #713
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 279 B |
@@ -288,36 +288,6 @@ int GetKeyboardCmd(
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -351,9 +321,7 @@ static int GetJoystickCmd(const SDL_JoystickID id, bool isPressed)
|
||||
return cmd;
|
||||
}
|
||||
|
||||
int GetGameCmd(
|
||||
EventHandlers *handlers, const PlayerData *playerData,
|
||||
const struct vec2i playerPos)
|
||||
int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData)
|
||||
{
|
||||
int cmd = 0;
|
||||
|
||||
@@ -363,9 +331,6 @@ int GetGameCmd(
|
||||
cmd = GetKeyboardCmd(
|
||||
&handlers->keyboard, playerData->deviceIndex, false);
|
||||
break;
|
||||
case INPUT_DEVICE_MOUSE:
|
||||
cmd = GetMouseCmd(&handlers->mouse, false, 1, playerPos);
|
||||
break;
|
||||
case INPUT_DEVICE_JOYSTICK:
|
||||
cmd = GetJoystickCmd(playerData->deviceIndex, false);
|
||||
break;
|
||||
@@ -387,9 +352,6 @@ int GetOnePlayerCmd(
|
||||
case INPUT_DEVICE_KEYBOARD:
|
||||
cmd = GetKeyboardCmd(&handlers->keyboard, deviceIndex, isPressed);
|
||||
break;
|
||||
case INPUT_DEVICE_MOUSE:
|
||||
cmd = GetMouseCmd(&handlers->mouse, isPressed, 0, svec2i_zero());
|
||||
break;
|
||||
case INPUT_DEVICE_JOYSTICK:
|
||||
cmd = GetJoystickCmd(deviceIndex, isPressed);
|
||||
break;
|
||||
@@ -465,7 +427,8 @@ int GetMenuCmd(EventHandlers *handlers)
|
||||
if (!cmd)
|
||||
{
|
||||
// Check mouse
|
||||
cmd = GetOnePlayerCmd(handlers, true, INPUT_DEVICE_MOUSE, 0);
|
||||
if (MouseIsPressed(&handlers->mouse, SDL_BUTTON_LEFT))
|
||||
cmd |= CMD_BUTTON1;
|
||||
}
|
||||
|
||||
return cmd;
|
||||
@@ -557,38 +520,6 @@ void InputGetButtonNameColor(
|
||||
}
|
||||
#endif
|
||||
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:
|
||||
JoyButtonNameColor(dIndex, cmd, buf, color);
|
||||
return;
|
||||
@@ -614,9 +545,6 @@ void InputGetDirectionNames(
|
||||
sprintf(buf, "%s, %s, %s, %s", left, right, up, down);
|
||||
}
|
||||
break;
|
||||
case INPUT_DEVICE_MOUSE:
|
||||
strcpy(buf, "mouse wheel");
|
||||
break;
|
||||
case INPUT_DEVICE_JOYSTICK:
|
||||
strcpy(buf, "directions");
|
||||
break;
|
||||
@@ -639,8 +567,6 @@ bool InputHasGrenadeButton(const input_device_e d, const int dIndex)
|
||||
return KeyGet(
|
||||
&gEventHandlers.keyboard.PlayerKeys[dIndex],
|
||||
KEY_CODE_GRENADE) != SDL_SCANCODE_UNKNOWN;
|
||||
case INPUT_DEVICE_MOUSE:
|
||||
return true;
|
||||
case INPUT_DEVICE_JOYSTICK:
|
||||
return true;
|
||||
case INPUT_DEVICE_AI:
|
||||
|
@@ -60,9 +60,7 @@ void EventPoll(
|
||||
int GetOnePlayerCmd(
|
||||
EventHandlers *handlers, const bool isPressed, const input_device_e device,
|
||||
const int deviceIndex);
|
||||
int GetGameCmd(
|
||||
EventHandlers *handlers, const PlayerData *playerData,
|
||||
const struct vec2i playerPos);
|
||||
int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData);
|
||||
int GetKeyboardCmd(
|
||||
keyboard_t *keyboard, const int kbIndex, const bool isPressed);
|
||||
SDL_Scancode GetKey(EventHandlers *handlers);
|
||||
|
@@ -145,18 +145,3 @@ void MissionOptionsTerminate(struct MissionOptions *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;
|
||||
}
|
||||
|
@@ -72,5 +72,3 @@ void CampaignUnload(Campaign *co);
|
||||
|
||||
void MissionOptionsInit(struct MissionOptions *mo);
|
||||
void MissionOptionsTerminate(struct MissionOptions *mo);
|
||||
|
||||
bool GameIsMouseUsed(void);
|
||||
|
@@ -225,7 +225,7 @@ void MouseSetCursor(Mouse *m, const SDL_SystemCursor sc)
|
||||
SDL_SetCursor(m->cursors[sc]);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail)
|
||||
void MouseSetPicCursor(Mouse *m, const Pic *cursor)
|
||||
{
|
||||
if (cursor)
|
||||
{
|
||||
@@ -256,34 +256,5 @@ void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail)
|
||||
}
|
||||
m->cursor = NULL;
|
||||
}
|
||||
m->trail = trail;
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,6 @@ typedef struct
|
||||
struct vec2i currentPos;
|
||||
struct vec2i wheel;
|
||||
SDL_Cursor *cursor;
|
||||
const Pic *trail;
|
||||
Uint32 repeatedTicks;
|
||||
|
||||
struct vec2i mouseMovePos;
|
||||
@@ -67,8 +66,6 @@ bool MouseIsReleased(const Mouse *m, const int button);
|
||||
// Get wheel movement since last poll
|
||||
struct vec2i MouseWheel(const Mouse *m);
|
||||
// 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);
|
||||
void MouseSetCursor(Mouse *m, const SDL_SystemCursor sc);
|
||||
void MouseSetPicCursor(Mouse *m, const Pic *cursor, const Pic *trail);
|
||||
void MouseDraw(const Mouse *mouse);
|
||||
void MouseSetPicCursor(Mouse *m, const Pic *cursor);
|
||||
|
@@ -457,8 +457,6 @@ const char *InputDeviceName(const int d, const int deviceIndex)
|
||||
{
|
||||
case INPUT_DEVICE_KEYBOARD:
|
||||
return "Keyboard";
|
||||
case INPUT_DEVICE_MOUSE:
|
||||
return "Mouse";
|
||||
case INPUT_DEVICE_JOYSTICK:
|
||||
return JoyName(deviceIndex);
|
||||
case INPUT_DEVICE_AI:
|
||||
|
@@ -166,7 +166,6 @@ typedef enum
|
||||
{
|
||||
INPUT_DEVICE_UNSET,
|
||||
INPUT_DEVICE_KEYBOARD,
|
||||
INPUT_DEVICE_MOUSE,
|
||||
INPUT_DEVICE_JOYSTICK,
|
||||
|
||||
// Fake device used for co-op AI
|
||||
|
@@ -247,7 +247,6 @@ static void Display(HandleInputResult result)
|
||||
UITooltipDraw(
|
||||
ec.g, gEventHandlers.mouse.currentPos, sTooltipObj->Tooltip);
|
||||
}
|
||||
MouseDraw(&gEventHandlers.mouse);
|
||||
}
|
||||
BlitUpdateFromBuf(ec.g, ec.g->screen);
|
||||
WindowContextPostRender(&ec.g->gameWindow);
|
||||
|
@@ -214,7 +214,7 @@ static EditorResult BrushSetBrushTypePoint(void *data, int d)
|
||||
b->Type = BRUSHTYPE_POINT;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/pencil"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/pencil"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeLine(void *data, int d)
|
||||
@@ -224,7 +224,7 @@ static EditorResult BrushSetBrushTypeLine(void *data, int d)
|
||||
b->Type = BRUSHTYPE_LINE;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/line"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/line"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeBox(void *data, int d)
|
||||
@@ -234,7 +234,7 @@ static EditorResult BrushSetBrushTypeBox(void *data, int d)
|
||||
b->Type = BRUSHTYPE_BOX;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeBoxFilled(void *data, int d)
|
||||
@@ -244,7 +244,7 @@ static EditorResult BrushSetBrushTypeBoxFilled(void *data, int d)
|
||||
b->Type = BRUSHTYPE_BOX_FILLED;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box_filled"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box_filled"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeBoxAndFill(void *data, int d)
|
||||
@@ -254,7 +254,7 @@ static EditorResult BrushSetBrushTypeBoxAndFill(void *data, int d)
|
||||
b->Type = BRUSHTYPE_BOX_AND_FILL;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box_n_fill"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/box_n_fill"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeSelect(void *data, int d)
|
||||
@@ -264,7 +264,7 @@ static EditorResult BrushSetBrushTypeSelect(void *data, int d)
|
||||
b->Type = BRUSHTYPE_SELECT;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/select"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/select"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeFill(void *data, int d)
|
||||
@@ -274,7 +274,7 @@ static EditorResult BrushSetBrushTypeFill(void *data, int d)
|
||||
b->Type = BRUSHTYPE_FILL;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/bucket"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/bucket"));
|
||||
return EDITOR_RESULT_NONE;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeSetExit(void *data, int d)
|
||||
@@ -286,7 +286,7 @@ static EditorResult BrushSetBrushTypeSetExit(void *data, int d)
|
||||
b->Type = BRUSHTYPE_SET_EXIT;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/set_exit"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/set_exit"));
|
||||
return result;
|
||||
}
|
||||
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;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/set_key"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/set_key"));
|
||||
return EDITOR_RESULT_CHANGE_TOOL;
|
||||
}
|
||||
static void ActivateBrush(UIObject *o, void *data)
|
||||
|
@@ -59,7 +59,7 @@ static EditorResult BrushSetBrushTypeAddMapItem(void *data, int d)
|
||||
b->Brush->u.MapObject = b->u.MapObject;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"));
|
||||
return EDITOR_RESULT_CHANGE_TOOL;
|
||||
}
|
||||
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;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"));
|
||||
return EDITOR_RESULT_CHANGE_TOOL;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeAddObjective(void *data, int d)
|
||||
@@ -82,7 +82,7 @@ static EditorResult BrushSetBrushTypeAddObjective(void *data, int d)
|
||||
b->Brush->Index2 = b->Index2;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"));
|
||||
return EDITOR_RESULT_CHANGE_TOOL;
|
||||
}
|
||||
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;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"));
|
||||
return EDITOR_RESULT_CHANGE_TOOL;
|
||||
}
|
||||
static EditorResult BrushSetBrushTypeAddPickup(void *data, int d)
|
||||
@@ -107,7 +107,7 @@ static EditorResult BrushSetBrushTypeAddPickup(void *data, int d)
|
||||
b->Type = BRUSHTYPE_ADD_PICKUP;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse,
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"), NULL);
|
||||
PicManagerGetPic(&gPicManager, "editor/cursors/add"));
|
||||
return AddPickupDialog(&gPicManager, &gEventHandlers, &b->u.Pickup);
|
||||
}
|
||||
|
||||
|
59
src/game.c
59
src/game.c
@@ -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 RunGameOnEnter(GameLoopData *data);
|
||||
static void RunGameOnExit(GameLoopData *data);
|
||||
@@ -264,9 +218,7 @@ static void RunGameOnEnter(GameLoopData *data)
|
||||
Pic *crosshair = PicManagerGetPic(&gPicManager, "crosshair");
|
||||
crosshair->offset.x = -crosshair->size.x / 2;
|
||||
crosshair->offset.y = -crosshair->size.y / 2;
|
||||
MouseSetPicCursor(
|
||||
&gEventHandlers.mouse, crosshair,
|
||||
PicManagerGetPic(&gPicManager, "crosshair_trail"));
|
||||
MouseSetPicCursor(&gEventHandlers.mouse, crosshair);
|
||||
|
||||
NetServerSendGameStartMessages(&gNetServer, NET_SERVER_BCAST);
|
||||
GameEvent start = GameEventNew(GAME_EVENT_GAME_START);
|
||||
@@ -382,9 +334,7 @@ static void RunGameInput(GameLoopData *data)
|
||||
{
|
||||
firstPausingDevice = p->inputDevice;
|
||||
}
|
||||
rData->cmds[idx] = GetGameCmd(
|
||||
&gEventHandlers, p,
|
||||
GetPlayerCenter(&gGraphicsDevice, &rData->Camera, p, idx));
|
||||
rData->cmds[idx] = GetGameCmd(&gEventHandlers, p);
|
||||
cmdAll |= rData->cmds[idx];
|
||||
|
||||
// Only allow the first player to escape
|
||||
@@ -756,11 +706,6 @@ static void RunGameDraw(GameLoopData *data)
|
||||
HUDDraw(
|
||||
&rData->Camera.HUD, rData->pausingDevice, rData->controllerUnplugged,
|
||||
rData->Camera.NumViews);
|
||||
const bool isMouse = GameIsMouseUsed();
|
||||
if (isMouse)
|
||||
{
|
||||
MouseDraw(&gEventHandlers.mouse);
|
||||
}
|
||||
// Draw automap if enabled
|
||||
if (rData->isMap)
|
||||
{
|
||||
|
@@ -109,10 +109,6 @@ void MenuDisplayPlayerControls(
|
||||
FontStr(s, svec2i(pos.x - FontStrW(s) / 2, y - FontH()));
|
||||
}
|
||||
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:
|
||||
{
|
||||
sprintf(s, "(%s,",
|
||||
|
@@ -287,12 +287,6 @@ static void AssignPlayerInputDevices(EventHandlers *handlers)
|
||||
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++)
|
||||
{
|
||||
const Joystick *joy = CArrayGet(&handlers->joysticks, j);
|
||||
@@ -493,7 +487,7 @@ static void PlayerSelectionDraw(GameLoopData *data)
|
||||
else
|
||||
{
|
||||
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 =
|
||||
svec2i_scale_divide(FontStrSize(prompt), -2);
|
||||
switch (GetNumPlayers(false, false, true))
|
||||
|
@@ -45,7 +45,7 @@ FEATURE(assign_unused, "Assign unused input device")
|
||||
const int idx = 0;
|
||||
p->deviceIndex = idx;
|
||||
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")
|
||||
SHOULD_BE_FALSE(res);
|
||||
AND("the player's input device should be unchanged")
|
||||
|
Reference in New Issue
Block a user