Browse Source

Controls: Map top button to use inv item

pull/420/head
Gleb Mazovetskiy 6 years ago committed by Anders Jenbo
parent
commit
7c4284fc4c
  1. 6
      SourceX/controls/game_controls.cpp
  2. 17
      SourceX/controls/game_controls.h
  3. 12
      SourceX/miniwin/misc_msg.cpp

6
SourceX/controls/game_controls.cpp

@ -64,7 +64,9 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
case ControllerButton::BUTTON_Y: // Top button
if (InGameMenu())
break; // Map to keyboard key
if (!ctrl_event.up)
if (invflag)
*action = GameActionSendMouseClick { GameActionSendMouseClick::RIGHT, ctrl_event.up };
else if (!ctrl_event.up)
*action = GameAction(GameActionType::SECONDARY_ACTION);
return true;
case ControllerButton::BUTTON_X: // Left button
@ -96,7 +98,7 @@ bool GetGameAction(const SDL_Event &event, GameAction *action)
// The rest is handled in charMovement() on every game_logic() call.
return true;
case ControllerButton::BUTTON_RIGHTSTICK:
*action = GameActionSendMouseLeftClick { ctrl_event.up };
*action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up };
return true;
default:
break;

17
SourceX/controls/game_controls.h

@ -15,7 +15,7 @@ enum class GameActionType {
TOGGLE_CHARACTER_INFO,
TOGGLE_QUICK_SPELL_MENU,
SEND_KEY,
SEND_MOUSE_LEFT_CLICK
SEND_MOUSE_CLICK,
};
struct GameActionSendKey {
@ -23,7 +23,12 @@ struct GameActionSendKey {
bool up;
};
struct GameActionSendMouseLeftClick {
struct GameActionSendMouseClick {
enum Button {
LEFT = 0,
RIGHT,
};
Button button;
bool up;
};
@ -46,15 +51,15 @@ struct GameAction {
{
}
GameAction(GameActionSendMouseLeftClick send_mouse_left_click)
: type(GameActionType::SEND_MOUSE_LEFT_CLICK)
, send_mouse_left_click(send_mouse_left_click)
GameAction(GameActionSendMouseClick send_mouse_click)
: type(GameActionType::SEND_MOUSE_CLICK)
, send_mouse_click(send_mouse_click)
{
}
union {
GameActionSendKey send_key;
GameActionSendMouseLeftClick send_mouse_left_click;
GameActionSendMouseClick send_mouse_click;
};
};

12
SourceX/miniwin/misc_msg.cpp

@ -450,9 +450,17 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
lpMsg->message = action.send_key.up ? DVL_WM_KEYUP : DVL_WM_KEYDOWN;
lpMsg->wParam = action.send_key.vk_code;
return true;
case GameActionType::SEND_MOUSE_LEFT_CLICK:
case GameActionType::SEND_MOUSE_CLICK:
ShowCursor();
SetMouseLMBMessage(e, lpMsg);
switch (action.send_mouse_click.button) {
case GameActionSendMouseClick::LEFT:
lpMsg->message = action.send_mouse_click.up ? DVL_WM_LBUTTONUP : DVL_WM_LBUTTONDOWN;
break;
case GameActionSendMouseClick::RIGHT:
lpMsg->message = action.send_mouse_click.up ? DVL_WM_RBUTTONUP : DVL_WM_RBUTTONDOWN;
break;
}
lpMsg->lParam = (MouseY << 16) | (MouseX & 0xFFFF);
return true;
}
return true;

Loading…
Cancel
Save