Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion GameMods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#define ENH_USE_OWN_AO // Use own ambient occlusion engine - looks pretty much the same except it fixes the corners
#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu
#define ENH_ALLOW_SAND_GRAVITY // Allow sand to fall.
#define ENH_USE_GUI_SCALE_2 // Use a 2x GUI scale instead of 3x. Looks better on PC
#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots
#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly.
#define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu
Expand Down
2 changes: 1 addition & 1 deletion game/assets/materials/ui.material
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"states": ["DisableCulling"]
},

"ui_text:ui_texture_and_color": {
"ui_text:ui_textured_and_glcolor": {
"fragmentShader": "shaders/text.fragment"
},

Expand Down
12 changes: 3 additions & 9 deletions platforms/input/xinput/GameControllerHandler_xinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ void GameControllerHandler_xinput::_initButtonMap()
m[XINPUT_GAMEPAD_START] = GameController::BUTTON_START;
}

Keyboard::KeyState _getKeyState(bool value)
{
return value ? Keyboard::DOWN : Keyboard::UP;
}

void GameControllerHandler_xinput::_processButton(GameController::ID controllerId, const XINPUT_STATE& state, GameController::NativeButtonID nativeBtn, GameController::EngineButtonID engineBtn, bool& joinGameAlreadyFired)
{
bool bButtonPressed = (state.Gamepad.wButtons & nativeBtn) != 0;
Expand All @@ -63,8 +58,7 @@ void GameControllerHandler_xinput::_processButton(GameController::ID controllerI
joinGameAlreadyFired = true;
}

// @TODO: should call GameControllerManager::feedButton() instead
Keyboard::feed(_getKeyState(bButtonPressed), engineBtn);
GameControllerManager::feedButton(btnState, engineBtn);

lastBtnState = btnState;
}
Expand Down Expand Up @@ -95,9 +89,9 @@ void GameControllerHandler_xinput::refresh()
{
XINPUT_STATE& inputState = m_inputStates.m_inputState[id];
bool joinGameAlreadyFired = false;
for (ButtonIDMap::const_iterator it = m_buttonIdMap.begin(); it != m_buttonIdMap.end(); it++)
for (ButtonIDMap::iterator it = m_buttonIdMap.begin(); it != m_buttonIdMap.end(); it++)
{
_processButton(id, inputState, it->first, it->second, joinGameAlreadyFired);
_processButton(id, inputState, it.key(), it.value(), joinGameAlreadyFired);
}

GameControllerManager::feedTrigger(1, (float)inputState.Gamepad.bLeftTrigger / 255.0f);
Expand Down
31 changes: 30 additions & 1 deletion platforms/sdl/base/AppPlatform_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,39 @@ void AppPlatform_sdl::handleKeyEvent(const SDL_Event& event)
return _handleKeyEvent(key, state);
}

static GameController::EngineButtonID _getEngineButton(uint8_t button)
{
switch (button)
{
case SDL_CONTROLLER_BUTTON_A: return GameController::BUTTON_A;
case SDL_CONTROLLER_BUTTON_B: return GameController::BUTTON_B;
case SDL_CONTROLLER_BUTTON_X: return GameController::BUTTON_X;
case SDL_CONTROLLER_BUTTON_Y: return GameController::BUTTON_Y;
case SDL_CONTROLLER_BUTTON_DPAD_UP: return GameController::BUTTON_DPAD_UP;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return GameController::BUTTON_DPAD_DOWN;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return GameController::BUTTON_DPAD_LEFT;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return GameController::BUTTON_DPAD_RIGHT;
case SDL_CONTROLLER_BUTTON_LEFTSTICK: return GameController::BUTTON_LEFTSTICK;
case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return GameController::BUTTON_RIGHTSTICK;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return GameController::BUTTON_LEFTSHOULDER;
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return GameController::BUTTON_RIGHTSHOULDER;
case SDL_CONTROLLER_BUTTON_BACK: return GameController::BUTTON_BACK;
case SDL_CONTROLLER_BUTTON_START: return GameController::BUTTON_START;
case SDL_CONTROLLER_BUTTON_GUIDE: return GameController::BUTTON_GUIDE;
case SDL_CONTROLLER_BUTTON_MISC1: return GameController::BUTTON_MISC1;
case SDL_CONTROLLER_BUTTON_PADDLE1: return GameController::BUTTON_PADDLE1;
case SDL_CONTROLLER_BUTTON_PADDLE2: return GameController::BUTTON_PADDLE2;
case SDL_CONTROLLER_BUTTON_PADDLE3: return GameController::BUTTON_PADDLE3;
case SDL_CONTROLLER_BUTTON_PADDLE4: return GameController::BUTTON_PADDLE4;
case SDL_CONTROLLER_BUTTON_TOUCHPAD: return GameController::BUTTON_TOUCHPAD;
default: return GameController::BUTTON_NONE;
}
}

void AppPlatform_sdl::handleControllerButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state)
{
// Normal Key Press
Keyboard::feed(GetKeyState(state), button);
GameControllerManager::feedButton(state == SDL_PRESSED ? GameController::BTN_STATE_DOWN : GameController::BTN_STATE_UP, _getEngineButton(button));
}

void AppPlatform_sdl::handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value)
Expand Down
1 change: 1 addition & 0 deletions platforms/sdl/base/AppPlatform_sdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "client/player/input/Mouse.hpp"
#include "client/player/input/Keyboard.hpp"
#include "client/player/input/GameController.hpp"
#include "common/Logger.hpp"

class AppPlatform_sdl : public AppPlatform
Expand Down
6 changes: 4 additions & 2 deletions platforms/sdl/sdl2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ static void handle_events()
float x = event.button.x * scale;
float y = event.button.y * scale;
Mouse::feed(type, state, x, y);
Multitouch::feed(type, state, x, y, 0);
if (g_pAppPlatform->isTouchscreen())
Multitouch::feed(type, state, x, y, 0);
}
break;
}
Expand All @@ -244,7 +245,8 @@ static void handle_events()
float scale = g_fPointToPixelScale;
float x = event.motion.x * scale;
float y = event.motion.y * scale;
Multitouch::feed(MOUSE_BUTTON_NONE, false, x, y, 0);
if (g_pAppPlatform->isTouchscreen())
Multitouch::feed(MOUSE_BUTTON_NONE, false, x, y, 0);
Mouse::feed(MOUSE_BUTTON_NONE, false, x, y);
g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
posY = Mouse::getY();
}
Mouse::feed(buttonType, buttonState, posX, posY);
Multitouch::feed(buttonType, buttonState, posX, posY, 0);
if (g_AppPlatform.isTouchscreen())
Multitouch::feed(buttonType, buttonState, posX, posY, 0);
break;
}

Expand Down
1 change: 1 addition & 0 deletions platforms/windows/projects/Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<ClInclude Include="$(MC_ROOT)\source\common\utility\JsonParser.hpp" />
<ClInclude Include="$(MC_ROOT)\source\common\utility\Singleton.hpp" />
<ClInclude Include="$(MC_ROOT)\source\common\threading\AsyncTask.hpp" />
<ClInclude Include="$(MC_ROOT)\source\common\utility\HashMap.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
3 changes: 3 additions & 0 deletions platforms/windows/projects/Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,8 @@
<ClInclude Include="$(MC_ROOT)\source\common\threading\AsyncTask.hpp">
<Filter>Header Files\Threading</Filter>
</ClInclude>
<ClInclude Include="$(MC_ROOT)\source\common\utility\HashMap.hpp">
<Filter>Header Files\Utility</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading