Added emscripten compatiblity fix for all Steam API changes. Fix bug where walking direction took priority over manual aim when using controller aiming. Release Build 8465.
This commit is contained in:
parent
68ed4d2b5d
commit
05abf6c3e9
@ -329,6 +329,7 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Effect.h" />
|
<ClInclude Include="Effect.h" />
|
||||||
<ClInclude Include="Emitter.h" />
|
<ClInclude Include="Emitter.h" />
|
||||||
|
<ClInclude Include="emscripten_compat.h" />
|
||||||
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h" />
|
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h" />
|
||||||
<ClInclude Include="EnhancementStatsLabel.h">
|
<ClInclude Include="EnhancementStatsLabel.h">
|
||||||
<SubType>
|
<SubType>
|
||||||
|
|||||||
@ -624,6 +624,9 @@
|
|||||||
<ClInclude Include="SteamKeyboardCallbackHandler.h">
|
<ClInclude Include="SteamKeyboardCallbackHandler.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="emscripten_compat.h">
|
||||||
|
<Filter>Header Files\steam</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Player.cpp">
|
<ClCompile Include="Player.cpp">
|
||||||
|
|||||||
@ -74,7 +74,7 @@ All rights reserved.
|
|||||||
#include "InventoryScrollableWindowComponent.h"
|
#include "InventoryScrollableWindowComponent.h"
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
#include "discord.h"
|
#include "discord.h"
|
||||||
#include <steam_api.h>
|
#include "steam/steam_api.h"
|
||||||
#endif
|
#endif
|
||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "LoadingScreen.h"
|
#include "LoadingScreen.h"
|
||||||
@ -323,15 +323,17 @@ bool AiL::OnUserCreate(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
State_OverworldMap::SetStageMarker("starting_map_name"_S);
|
State_OverworldMap::SetStageMarker("starting_map_name"_S);
|
||||||
if(SteamInput()!=nullptr){
|
STEAMINPUT(
|
||||||
SteamInput()->Init(false);
|
SteamInput()->Init(false);
|
||||||
Input::LoadSteamButtonIcons();
|
Input::LoadSteamButtonIcons();
|
||||||
Input::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
|
Input::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
|
||||||
}
|
)
|
||||||
|
|
||||||
if(steamKeyboardCallbackListener==nullptr){
|
#ifndef __EMSCRIPTEN__
|
||||||
steamKeyboardCallbackListener=new SteamKeyboardCallbackHandler();
|
if(steamKeyboardCallbackListener==nullptr){
|
||||||
}
|
steamKeyboardCallbackListener=new SteamKeyboardCallbackHandler();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
utils::datafile::INITIAL_SETUP_COMPLETE=true;
|
utils::datafile::INITIAL_SETUP_COMPLETE=true;
|
||||||
|
|
||||||
@ -353,10 +355,10 @@ bool AiL::OnUserCreate(){
|
|||||||
bool AiL::OnUserUpdate(float fElapsedTime){
|
bool AiL::OnUserUpdate(float fElapsedTime){
|
||||||
levelTime+=fElapsedTime;
|
levelTime+=fElapsedTime;
|
||||||
SteamAPI_RunCallbacks();
|
SteamAPI_RunCallbacks();
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
ActivateActionSetForAllControllers(Input::ingameControlsHandle);
|
ActivateActionSetForAllControllers(Input::ingameControlsHandle);
|
||||||
Input::UpdateSteamInput();
|
Input::UpdateSteamInput();
|
||||||
}
|
)
|
||||||
|
|
||||||
if(GetMousePos()!=lastMousePos){
|
if(GetMousePos()!=lastMousePos){
|
||||||
lastMouseMovement=0.f;
|
lastMouseMovement=0.f;
|
||||||
@ -2127,10 +2129,10 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
|
|||||||
GetPlayer()->SetInvisible(false);
|
GetPlayer()->SetInvisible(false);
|
||||||
GetPlayer()->ResetVelocity();
|
GetPlayer()->ResetVelocity();
|
||||||
|
|
||||||
if(SteamInput()){ //This is kind of a hack to refresh the in-game controls handle and button icons if for some reason it's not setup correctly.
|
STEAMINPUT( //This is kind of a hack to refresh the in-game controls handle and button icons if for some reason it's not setup correctly.
|
||||||
Input::LoadSteamButtonIcons();
|
Input::LoadSteamButtonIcons();
|
||||||
Input::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
|
Input::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
|
||||||
}
|
)
|
||||||
|
|
||||||
ZONE_LIST=game->MAP_DATA[game->GetCurrentLevel()].ZoneData;
|
ZONE_LIST=game->MAP_DATA[game->GetCurrentLevel()].ZoneData;
|
||||||
return true;
|
return true;
|
||||||
@ -2683,25 +2685,29 @@ datafiledoubledata AiL::GetDoubleList(std::string key){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Steam_Init(){
|
bool Steam_Init(){
|
||||||
if(SteamAPI_Init()){
|
#ifndef __EMSCRIPTEN__
|
||||||
if(SteamUtils()!=nullptr){
|
if(SteamAPI_Init()){
|
||||||
SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
|
if(SteamUtils()!=nullptr){
|
||||||
LOG(std::format("STEAM[{}]: {}",severity,std::string(message)));
|
SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
|
||||||
});
|
LOG(std::format("STEAM[{}]: {}",severity,std::string(message)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
#endif
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
|
#ifndef __EMSCRIPTEN__
|
||||||
if(Steam_Init()){
|
if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
|
||||||
LOG("Steam API Initialized successfully!");
|
if(Steam_Init()){
|
||||||
}else{
|
LOG("Steam API Initialized successfully!");
|
||||||
LOG("Steam API failed to initialize!");
|
}else{
|
||||||
}
|
LOG("Steam API failed to initialize!");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
AiL demo;
|
AiL demo;
|
||||||
|
|
||||||
@ -2870,7 +2876,9 @@ bool AiL::IsReflectiveTile(TilesheetData tileSheet,int tileID){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AiL::OnUserDestroy(){
|
bool AiL::OnUserDestroy(){
|
||||||
SteamAPI_Shutdown();
|
#ifndef __EMSCRIPTEN__
|
||||||
|
SteamAPI_Shutdown();
|
||||||
|
#endif
|
||||||
GFX.Reset();
|
GFX.Reset();
|
||||||
for(auto&[key,value]:MAP_DATA){
|
for(auto&[key,value]:MAP_DATA){
|
||||||
if(MAP_DATA[key].optimizedTile!=nullptr){
|
if(MAP_DATA[key].optimizedTile!=nullptr){
|
||||||
@ -3871,7 +3879,9 @@ int AiL::GetLoadoutSize()const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AiL::ActivateActionSetForAllControllers(InputActionSetHandle_t actionSetHandle){
|
void AiL::ActivateActionSetForAllControllers(InputActionSetHandle_t actionSetHandle){
|
||||||
for(int i=0;i<Input::controllerCount;i++){
|
STEAMINPUT(
|
||||||
SteamInput()->ActivateActionSet(Input::steamControllers[i],actionSetHandle);
|
for(int i=0;i<Input::controllerCount;i++){
|
||||||
}
|
SteamInput()->ActivateActionSet(Input::steamControllers[i],actionSetHandle);
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ All rights reserved.
|
|||||||
#include "TextEntryLabel.h"
|
#include "TextEntryLabel.h"
|
||||||
#include "Checkbox.h"
|
#include "Checkbox.h"
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
#include <isteamutils.h>
|
#include "steam/isteamutils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
@ -74,9 +74,9 @@ void Menu::InitializeClassSelectionWindow(){
|
|||||||
vf2d textboxWindowPos=data.component.lock()->rect.pos*game->GetPixelSize();
|
vf2d textboxWindowPos=data.component.lock()->rect.pos*game->GetPixelSize();
|
||||||
vf2d textboxWindowSize=data.component.lock()->rect.size*game->GetPixelSize();
|
vf2d textboxWindowSize=data.component.lock()->rect.size*game->GetPixelSize();
|
||||||
|
|
||||||
if(SteamUtils()){
|
STEAMUTILS(
|
||||||
SteamUtils()->ShowGamepadTextInput(k_EGamepadTextInputModeNormal,k_EGamepadTextInputLineModeSingleLine,"Character Name:",16U,std::string(SaveFile::GetSaveFileName()).c_str());
|
SteamUtils()->ShowGamepadTextInput(k_EGamepadTextInputModeNormal,k_EGamepadTextInputLineModeSingleLine,"Character Name:",16U,std::string(SaveFile::GetSaveFileName()).c_str());
|
||||||
}
|
)
|
||||||
return true;
|
return true;
|
||||||
},vf2d{2.f,2.f})END;
|
},vf2d{2.f,2.f})END;
|
||||||
|
|
||||||
|
|||||||
@ -91,11 +91,15 @@ inline std::ofstream debugLogger;
|
|||||||
std::stringstream errStream; \
|
std::stringstream errStream; \
|
||||||
errStream<<err; \
|
errStream<<err; \
|
||||||
Error::log(errStream,std::source_location::current());}
|
Error::log(errStream,std::source_location::current());}
|
||||||
|
#define LOG(err) { \
|
||||||
|
std::stringstream errStream; \
|
||||||
|
errStream<<err; \
|
||||||
|
Error::log(errStream,std::source_location::current());}
|
||||||
|
|
||||||
class Error{
|
class Error{
|
||||||
public:
|
public:
|
||||||
inline static void log(std::stringstream&str,std::source_location loc){
|
inline static void log(std::stringstream&str,std::source_location loc){
|
||||||
LOG(loc.file_name()<<"("<<loc.line()<<":"<<loc.column()<<") "<<loc.function_name()<<": "<<str.str());
|
std::cout<<loc.file_name()<<"("<<loc.line()<<":"<<loc.column()<<") "<<loc.function_name()<<": "<<str.str();
|
||||||
#ifdef __DEBUG__
|
#ifdef __DEBUG__
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -64,7 +64,7 @@ const InputType InputHelper::InputMode()const{
|
|||||||
|
|
||||||
void InputHelper::Draw(){
|
void InputHelper::Draw(){
|
||||||
InputType mode=InputMode();
|
InputType mode=InputMode();
|
||||||
if(mode==CONTROLLER&&SteamInput())mode=STEAM;
|
STEAMINPUT(if(mode==CONTROLLER){mode=STEAM;})
|
||||||
if(mode==MOUSE)mode=KEY; //We're going to make it so the keyboard controls always show up when navigating using a mouse.
|
if(mode==MOUSE)mode=KEY; //We're going to make it so the keyboard controls always show up when navigating using a mouse.
|
||||||
|
|
||||||
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
|
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
|
||||||
|
|||||||
@ -60,85 +60,87 @@ uint8_t Input::controllerCount{0};
|
|||||||
std::vector<Steam::SteamInput>Input::leftStickActionSets{Steam::MOVE};
|
std::vector<Steam::SteamInput>Input::leftStickActionSets{Steam::MOVE};
|
||||||
std::vector<Steam::SteamInput>Input::rightStickActionSets{Steam::SCROLL};
|
std::vector<Steam::SteamInput>Input::rightStickActionSets{Steam::SCROLL};
|
||||||
|
|
||||||
std::array<std::unordered_map<Steam::SteamInput,std::pair<std::string,HWButton>>,16>Input::enumToActionName;
|
std::array<std::unordered_map<Steam::SteamInput,std::pair<std::string,HWButton>>,STEAM_INPUT_MAX_COUNT>Input::enumToActionName;
|
||||||
std::unordered_map<EInputActionOrigin,std::string>Input::steamIconToGameIcon{
|
std::unordered_map<EInputActionOrigin,std::string>Input::steamIconToGameIcon{
|
||||||
{k_EInputActionOrigin_SteamController_A,"themes/button_d_xb.png"},
|
#ifndef __EMSCRIPTEN__
|
||||||
{k_EInputActionOrigin_XBoxOne_A,"themes/button_d_xb.png"},
|
{k_EInputActionOrigin_SteamController_A,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_XBox360_A,"themes/button_d_xb.png"},
|
{k_EInputActionOrigin_XBoxOne_A,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_A,"themes/button_d_xb.png"},
|
{k_EInputActionOrigin_XBox360_A,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_JoyConButton_S,"themes/button_d_xb.png"},
|
{k_EInputActionOrigin_Switch_A,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_A,"themes/button_d_xb.png"},
|
{k_EInputActionOrigin_Switch_JoyConButton_S,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamController_B,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_SteamDeck_A,"themes/button_d_xb.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_B,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_SteamController_B,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_XBox360_B,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_XBoxOne_B,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_B,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_XBox360_B,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_JoyConButton_W,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_Switch_B,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_B,"themes/button_r_xb.png"},
|
{k_EInputActionOrigin_Switch_JoyConButton_W,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamController_X,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_SteamDeck_B,"themes/button_r_xb.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_X,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_SteamController_X,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_XBox360_X,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_XBoxOne_X,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_X,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_XBox360_X,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_JoyConButton_E,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_Switch_X,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_X,"themes/button_l_xb.png"},
|
{k_EInputActionOrigin_Switch_JoyConButton_E,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamController_Y,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_SteamDeck_X,"themes/button_l_xb.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_Y,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_SteamController_Y,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_XBox360_Y,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_XBoxOne_Y,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_Y,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_XBox360_Y,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_Switch_JoyConButton_N,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_Switch_Y,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_Y,"themes/button_u_xb.png"},
|
{k_EInputActionOrigin_Switch_JoyConButton_N,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_SteamController_LeftBumper,"themes/button_l1.png"},
|
{k_EInputActionOrigin_SteamDeck_Y,"themes/button_u_xb.png"},
|
||||||
{k_EInputActionOrigin_PS4_LeftBumper,"themes/button_l1.png"},
|
{k_EInputActionOrigin_SteamController_LeftBumper,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_LeftBumper,"themes/button_l1.png"},
|
{k_EInputActionOrigin_PS4_LeftBumper,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_XBox360_LeftBumper,"themes/button_l1.png"},
|
{k_EInputActionOrigin_XBoxOne_LeftBumper,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_Switch_LeftBumper,"themes/button_l1.png"},
|
{k_EInputActionOrigin_XBox360_LeftBumper,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_L1,"themes/button_l1.png"},
|
{k_EInputActionOrigin_Switch_LeftBumper,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_SteamController_RightBumper,"themes/button_r1.png"},
|
{k_EInputActionOrigin_SteamDeck_L1,"themes/button_l1.png"},
|
||||||
{k_EInputActionOrigin_PS4_RightBumper,"themes/button_r1.png"},
|
{k_EInputActionOrigin_SteamController_RightBumper,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_RightBumper,"themes/button_r1.png"},
|
{k_EInputActionOrigin_PS4_RightBumper,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_XBox360_RightBumper,"themes/button_r1.png"},
|
{k_EInputActionOrigin_XBoxOne_RightBumper,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_Switch_RightBumper,"themes/button_r1.png"},
|
{k_EInputActionOrigin_XBox360_RightBumper,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_R1,"themes/button_r1.png"},
|
{k_EInputActionOrigin_Switch_RightBumper,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_SteamController_RightTrigger_Pull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_SteamDeck_R1,"themes/button_r1.png"},
|
||||||
{k_EInputActionOrigin_PS4_RightTrigger_Pull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_SteamController_RightTrigger_Pull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_RightTrigger_Pull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_PS4_RightTrigger_Pull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_XBox360_RightTrigger_Pull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_XBoxOne_RightTrigger_Pull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_Switch_RightTrigger_Pull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_XBox360_RightTrigger_Pull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_R2_SoftPull,"themes/button_r2.png"},
|
{k_EInputActionOrigin_Switch_RightTrigger_Pull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_SteamController_RightTrigger_Click,"themes/button_r2.png"},
|
{k_EInputActionOrigin_SteamDeck_R2_SoftPull,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_PS4_RightTrigger_Click,"themes/button_r2.png"},
|
{k_EInputActionOrigin_SteamController_RightTrigger_Click,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_RightTrigger_Click,"themes/button_r2.png"},
|
{k_EInputActionOrigin_PS4_RightTrigger_Click,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_XBox360_RightTrigger_Click,"themes/button_r2.png"},
|
{k_EInputActionOrigin_XBoxOne_RightTrigger_Click,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_Switch_RightTrigger_Click,"themes/button_r2.png"},
|
{k_EInputActionOrigin_XBox360_RightTrigger_Click,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_R2,"themes/button_r2.png"},
|
{k_EInputActionOrigin_Switch_RightTrigger_Click,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_SteamController_LeftTrigger_Pull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_SteamDeck_R2,"themes/button_r2.png"},
|
||||||
{k_EInputActionOrigin_PS4_LeftTrigger_Pull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_SteamController_LeftTrigger_Pull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_PS4_LeftTrigger_Pull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_XBox360_LeftTrigger_Pull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_Switch_LeftTrigger_Pull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_XBox360_LeftTrigger_Pull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_L2_SoftPull,"themes/button_l2.png"},
|
{k_EInputActionOrigin_Switch_LeftTrigger_Pull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_SteamController_LeftTrigger_Click,"themes/button_l2.png"},
|
{k_EInputActionOrigin_SteamDeck_L2_SoftPull,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_PS4_LeftTrigger_Click,"themes/button_l2.png"},
|
{k_EInputActionOrigin_SteamController_LeftTrigger_Click,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_LeftTrigger_Click,"themes/button_l2.png"},
|
{k_EInputActionOrigin_PS4_LeftTrigger_Click,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_XBox360_LeftTrigger_Click,"themes/button_l2.png"},
|
{k_EInputActionOrigin_XBoxOne_LeftTrigger_Click,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_Switch_LeftTrigger_Click,"themes/button_l2.png"},
|
{k_EInputActionOrigin_XBox360_LeftTrigger_Click,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_L2,"themes/button_l2.png"},
|
{k_EInputActionOrigin_Switch_LeftTrigger_Click,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_PS4_X,"themes/button_d_ps.png"},
|
{k_EInputActionOrigin_SteamDeck_L2,"themes/button_l2.png"},
|
||||||
{k_EInputActionOrigin_PS4_Circle,"themes/button_r_ps.png"},
|
{k_EInputActionOrigin_PS4_X,"themes/button_d_ps.png"},
|
||||||
{k_EInputActionOrigin_PS4_Triangle,"themes/button_u_ps.png"},
|
{k_EInputActionOrigin_PS4_Circle,"themes/button_r_ps.png"},
|
||||||
{k_EInputActionOrigin_PS4_Square,"themes/button_l_ps.png"},
|
{k_EInputActionOrigin_PS4_Triangle,"themes/button_u_ps.png"},
|
||||||
{k_EInputActionOrigin_SteamController_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_PS4_Square,"themes/button_l_ps.png"},
|
||||||
{k_EInputActionOrigin_PS4_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_SteamController_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_PS4_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_PS4_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_PS4_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_XBoxOne_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_XBoxOne_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_XBox360_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_XBoxOne_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_XBox360_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_XBox360_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_Switch_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_XBox360_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_Switch_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_Switch_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_PS5_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_Switch_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_PS5_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_PS5_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_LeftStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_PS5_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
{k_EInputActionOrigin_SteamDeck_RightStick_Move,"themes/button_analogstick.png"},
|
{k_EInputActionOrigin_SteamDeck_LeftStick_Move,"themes/button_analogstick.png"},
|
||||||
|
{k_EInputActionOrigin_SteamDeck_RightStick_Move,"themes/button_analogstick.png"},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
Input::Input(InputType type,int key)
|
Input::Input(InputType type,int key)
|
||||||
@ -174,24 +176,26 @@ void Input::Initialize(){
|
|||||||
|
|
||||||
void Input::LoadSteamButtonIcons(){
|
void Input::LoadSteamButtonIcons(){
|
||||||
GFX.Unlock();
|
GFX.Unlock();
|
||||||
for(int i=1;i<k_EInputActionOrigin_Count;i++){
|
#ifndef __EMSCRIPTEN__
|
||||||
const char*imageName{SteamInput()->GetGlyphPNGForActionOrigin(EInputActionOrigin(i),k_ESteamInputGlyphSize_Small,0U)};
|
for(int i=1;i<k_EInputActionOrigin_Count;i++){
|
||||||
if(imageName!=nullptr){
|
const char*imageName{SteamInput()->GetGlyphPNGForActionOrigin(EInputActionOrigin(i),k_ESteamInputGlyphSize_Small,0U)};
|
||||||
std::string loadImage{imageName};
|
if(imageName!=nullptr){
|
||||||
if(loadImage.length()>0&&(!GFX.count(loadImage)||GFX.at(loadImage).Decal()==nullptr)){
|
std::string loadImage{imageName};
|
||||||
LOG(std::format("Loading steam image {}",loadImage));
|
if(loadImage.length()>0&&(!GFX.count(loadImage)||GFX.at(loadImage).Decal()==nullptr)){
|
||||||
if(!GFX.count(loadImage))GFX[loadImage];
|
LOG(std::format("Loading steam image {}",loadImage));
|
||||||
if(GFX.at(loadImage).Load(loadImage)!=rcode::OK){
|
if(!GFX.count(loadImage))GFX[loadImage];
|
||||||
LOG(std::format("WARNING! Failed to load steam image {}!",loadImage));
|
if(GFX.at(loadImage).Load(loadImage)!=rcode::OK){
|
||||||
|
LOG(std::format("WARNING! Failed to load steam image {}!",loadImage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
GFX.SetInitialized();
|
GFX.SetInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::UpdateSteamInput(){
|
void Input::UpdateSteamInput(){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
uint8_t prevControllerCount=controllerCount;
|
uint8_t prevControllerCount=controllerCount;
|
||||||
controllerCount=SteamInput()->GetConnectedControllers(steamControllers.data());
|
controllerCount=SteamInput()->GetConnectedControllers(steamControllers.data());
|
||||||
if(controllerCount<prevControllerCount&&Menu::stack.size()==0&&GameState::STATE==GameState::states[States::GAME_RUN])Menu::OpenMenu(MenuType::PAUSE); //We unplugged a controller so we will automatically pause the game.
|
if(controllerCount<prevControllerCount&&Menu::stack.size()==0&&GameState::STATE==GameState::states[States::GAME_RUN])Menu::OpenMenu(MenuType::PAUSE); //We unplugged a controller so we will automatically pause the game.
|
||||||
@ -224,7 +228,7 @@ void Input::UpdateSteamInput(){
|
|||||||
steamGameInputToAnalogOrigin[input].first=SteamInput()->GetAnalogActionOrigins(steamControllers[activeSteamControllerIndex],ingameControlsHandle,analogInputHnd,steamGameInputToAnalogOrigin[input].second.data());
|
steamGameInputToAnalogOrigin[input].first=SteamInput()->GetAnalogActionOrigins(steamControllers[activeSteamControllerIndex],ingameControlsHandle,analogInputHnd,steamGameInputToAnalogOrigin[input].second.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::Pressed(){
|
bool Input::Pressed(){
|
||||||
@ -238,14 +242,16 @@ bool Input::Pressed(){
|
|||||||
inputPressed=game->GetMouse(key).bPressed;
|
inputPressed=game->GetMouse(key).bPressed;
|
||||||
}break;
|
}break;
|
||||||
case CONTROLLER:{
|
case CONTROLLER:{
|
||||||
if(!SteamInput()){
|
STEAMINPUT()else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected&&gamepad->getButton(static_cast<GPButtons>(key)).bPressed)inputPressed=true;
|
if(gamepad->stillConnected&&gamepad->getButton(static_cast<GPButtons>(key)).bPressed)inputPressed=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case STEAM:{
|
case STEAM:{
|
||||||
if(enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bPressed)inputPressed=true;
|
STEAMINPUT(
|
||||||
|
if(enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bPressed)inputPressed=true;
|
||||||
|
)
|
||||||
}break;
|
}break;
|
||||||
case ANALOG:{
|
case ANALOG:{
|
||||||
//An analog input can never be "pressed". No-op.
|
//An analog input can never be "pressed". No-op.
|
||||||
@ -255,7 +261,7 @@ bool Input::Pressed(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(inputPressed){
|
if(inputPressed){
|
||||||
usingGamepad=type==CONTROLLER||type==STEAM;
|
SetUsingGamepad(type==CONTROLLER||type==STEAM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -272,14 +278,16 @@ bool Input::Held(){
|
|||||||
inputHeld|=game->GetMouse(key).bHeld;
|
inputHeld|=game->GetMouse(key).bHeld;
|
||||||
}break;
|
}break;
|
||||||
case CONTROLLER:{
|
case CONTROLLER:{
|
||||||
if(!SteamInput()){
|
STEAMINPUT()else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected)inputHeld|=gamepad->getButton(static_cast<GPButtons>(key)).bHeld;
|
if(gamepad->stillConnected)inputHeld|=gamepad->getButton(static_cast<GPButtons>(key)).bHeld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case STEAM:{
|
case STEAM:{
|
||||||
inputHeld|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bHeld;
|
STEAMINPUT(
|
||||||
|
inputHeld|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bHeld;
|
||||||
|
)
|
||||||
}break;
|
}break;
|
||||||
case ANALOG:{
|
case ANALOG:{
|
||||||
//An analog input can never be "held". No-op.
|
//An analog input can never be "held". No-op.
|
||||||
@ -289,7 +297,7 @@ bool Input::Held(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(inputHeld){
|
if(inputHeld){
|
||||||
usingGamepad=type==CONTROLLER||type==STEAM;
|
SetUsingGamepad(type==CONTROLLER||type==STEAM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -306,14 +314,16 @@ bool Input::Released(){
|
|||||||
inputReleased|=game->GetMouse(key).bReleased;
|
inputReleased|=game->GetMouse(key).bReleased;
|
||||||
}break;
|
}break;
|
||||||
case CONTROLLER:{
|
case CONTROLLER:{
|
||||||
if(!SteamInput()){
|
STEAMINPUT()else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected)inputReleased|=gamepad->getButton(static_cast<GPButtons>(key)).bReleased;
|
if(gamepad->stillConnected)inputReleased|=gamepad->getButton(static_cast<GPButtons>(key)).bReleased;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case STEAM:{
|
case STEAM:{
|
||||||
inputReleased|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bReleased;
|
STEAMINPUT(
|
||||||
|
inputReleased|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bReleased;
|
||||||
|
)
|
||||||
}break;
|
}break;
|
||||||
case ANALOG:{
|
case ANALOG:{
|
||||||
//An analog input can never be "released". No-op.
|
//An analog input can never be "released". No-op.
|
||||||
@ -323,7 +333,7 @@ bool Input::Released(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(inputReleased){
|
if(inputReleased){
|
||||||
usingGamepad=type==CONTROLLER||type==STEAM;
|
SetUsingGamepad(type==CONTROLLER||type==STEAM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -333,18 +343,7 @@ float Input::Analog(){
|
|||||||
if(!game->IsFocused())return false;
|
if(!game->IsFocused())return false;
|
||||||
switch(type){
|
switch(type){
|
||||||
case ANALOG:{
|
case ANALOG:{
|
||||||
if(!SteamInput()){
|
STEAMINPUT(
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
|
||||||
if(gamepad->stillConnected){
|
|
||||||
float axisVal=gamepad->getAxis(static_cast<GPAxes>(key));
|
|
||||||
if(axisVal!=0.f){
|
|
||||||
usingGamepad=true;
|
|
||||||
return axisVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
|
|
||||||
auto GetAnalogStickVal=[&](uint8_t controller,Steam::SteamInput input,Axis axis){
|
auto GetAnalogStickVal=[&](uint8_t controller,Steam::SteamInput input,Axis axis){
|
||||||
InputAnalogActionHandle_t inputHnd=SteamInput()->GetAnalogActionHandle(enumToActionName[controller][input].first.c_str());
|
InputAnalogActionHandle_t inputHnd=SteamInput()->GetAnalogActionHandle(enumToActionName[controller][input].first.c_str());
|
||||||
InputAnalogActionData_t data=SteamInput()->GetAnalogActionData(steamControllers[controller],inputHnd);
|
InputAnalogActionData_t data=SteamInput()->GetAnalogActionData(steamControllers[controller],inputHnd);
|
||||||
@ -412,6 +411,16 @@ float Input::Analog(){
|
|||||||
case GPAxes::DY:{}break;//Unused. No-op
|
case GPAxes::DY:{}break;//Unused. No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
)else{
|
||||||
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
|
if(gamepad->stillConnected){
|
||||||
|
float axisVal=gamepad->getAxis(static_cast<GPAxes>(key));
|
||||||
|
if(axisVal!=0.f){
|
||||||
|
usingGamepad=true;
|
||||||
|
return axisVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case KEY:
|
case KEY:
|
||||||
@ -702,10 +711,10 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
|||||||
|
|
||||||
switch(type){
|
switch(type){
|
||||||
case CONTROLLER:{
|
case CONTROLLER:{
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
primaryKey=GetPrimaryKey(STEAM);
|
primaryKey=GetPrimaryKey(STEAM);
|
||||||
type=STEAM;
|
type=STEAM;
|
||||||
}else{
|
)else{
|
||||||
primaryKey=GetPrimaryKey(CONTROLLER);
|
primaryKey=GetPrimaryKey(CONTROLLER);
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
@ -879,24 +888,26 @@ const bool Input::HasExtendedIcons()const{
|
|||||||
}
|
}
|
||||||
const Renderable&Input::GetIcon()const{
|
const Renderable&Input::GetIcon()const{
|
||||||
if(type==STEAM){
|
if(type==STEAM){
|
||||||
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
|
#ifndef __EMSCRIPTEN__
|
||||||
EInputActionOrigin analogAction=Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(key)).second[0];
|
EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
|
||||||
if(Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
|
EInputActionOrigin analogAction=Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(key)).second[0];
|
||||||
Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).first>0){
|
if(Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
|
||||||
if(steamIconToGameIcon.count(action)){
|
Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).first>0){
|
||||||
return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
|
if(steamIconToGameIcon.count(action)){
|
||||||
}else{
|
return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
|
||||||
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,0));
|
}else{
|
||||||
|
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(action,k_ESteamInputGlyphSize_Small,0));
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
if(Input::steamGameInputToAnalogOrigin.count(Steam::SteamInput(key))&&
|
||||||
|
Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(key)).first>0){
|
||||||
|
if(steamIconToGameIcon.count(analogAction)){
|
||||||
|
return GFX.at(GetProperIconName(steamIconToGameIcon[analogAction]));
|
||||||
|
}else{
|
||||||
|
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(analogAction,k_ESteamInputGlyphSize_Small,0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else
|
#endif
|
||||||
if(Input::steamGameInputToAnalogOrigin.count(Steam::SteamInput(key))&&
|
|
||||||
Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(key)).first>0){
|
|
||||||
if(steamIconToGameIcon.count(analogAction)){
|
|
||||||
return GFX.at(GetProperIconName(steamIconToGameIcon[analogAction]));
|
|
||||||
}else{
|
|
||||||
return GFX.at(SteamInput()->GetGlyphPNGForActionOrigin(analogAction,k_ESteamInputGlyphSize_Small,0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
|
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
|
||||||
}
|
}
|
||||||
@ -1060,14 +1071,14 @@ const bool Input::UsingGamepad(){
|
|||||||
|
|
||||||
const bool Input::AxesActive(){
|
const bool Input::AxesActive(){
|
||||||
float xAxis=0.f,yAxis=0.f;
|
float xAxis=0.f,yAxis=0.f;
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
|
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
|
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
)else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected){
|
if(gamepad->stillConnected){
|
||||||
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
|
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
|
||||||
@ -1085,9 +1096,9 @@ const bool Input::AxesActive(){
|
|||||||
void Input::StartVibration(const bool override){
|
void Input::StartVibration(const bool override){
|
||||||
if(!GameSettings::RumbleEnabled(override))return;
|
if(!GameSettings::RumbleEnabled(override))return;
|
||||||
if(UsingGamepad()){
|
if(UsingGamepad()){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
SteamInput()->TriggerVibration(steamControllers[activeSteamControllerIndex],std::numeric_limits<unsigned short>::max(),std::numeric_limits<unsigned short>::max());
|
SteamInput()->TriggerVibration(steamControllers[activeSteamControllerIndex],std::numeric_limits<unsigned short>::max(),std::numeric_limits<unsigned short>::max());
|
||||||
}else{
|
)else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected){
|
if(gamepad->stillConnected){
|
||||||
gamepad->startVibration();
|
gamepad->startVibration();
|
||||||
@ -1097,11 +1108,11 @@ void Input::StartVibration(const bool override){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Input::StopVibration(){
|
void Input::StopVibration(){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
for(int i=0;i<controllerCount;i++){
|
for(int i=0;i<controllerCount;i++){
|
||||||
SteamInput()->TriggerVibration(steamControllers[i],0U,0U);
|
SteamInput()->TriggerVibration(steamControllers[i],0U,0U);
|
||||||
}
|
}
|
||||||
}else{
|
)else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected){
|
if(gamepad->stillConnected){
|
||||||
gamepad->stopVibration();
|
gamepad->stopVibration();
|
||||||
@ -1224,9 +1235,9 @@ const bool InputEngageGroup::GetLabelVisible()const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Input::SetLightbar(const Pixel col){
|
void Input::SetLightbar(const Pixel col){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
for(int i=0;i<controllerCount;i++){
|
for(int i=0;i<controllerCount;i++){
|
||||||
SteamInput()->SetLEDColor(steamControllers[i],col.r,col.g,col.b,0);
|
SteamInput()->SetLEDColor(steamControllers[i],col.r,col.g,col.b,0);
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
@ -46,7 +46,10 @@ All rights reserved.
|
|||||||
#include "IconType.h"
|
#include "IconType.h"
|
||||||
#include "olcPGEX_ViewPort.h"
|
#include "olcPGEX_ViewPort.h"
|
||||||
#include "UndefKeys.h"
|
#include "UndefKeys.h"
|
||||||
#include <isteaminput.h>
|
#ifndef __EMSCRIPTEN__
|
||||||
|
#include "steam/isteaminput.h"
|
||||||
|
#endif
|
||||||
|
#include "emscripten_compat.h"
|
||||||
|
|
||||||
class AiL;
|
class AiL;
|
||||||
|
|
||||||
@ -111,7 +114,7 @@ class Input{
|
|||||||
static std::unordered_map<Steam::SteamInput,std::pair<NumOfOrigins,std::array<EInputActionOrigin,STEAM_INPUT_MAX_ORIGINS>>>steamGameInputToAnalogOrigin;
|
static std::unordered_map<Steam::SteamInput,std::pair<NumOfOrigins,std::array<EInputActionOrigin,STEAM_INPUT_MAX_ORIGINS>>>steamGameInputToAnalogOrigin;
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static void UpdateSteamInput();
|
static void UpdateSteamInput();
|
||||||
static std::array<InputHandle_t,16>steamControllers;
|
static std::array<InputHandle_t,STEAM_INPUT_MAX_COUNT>steamControllers;
|
||||||
static uint8_t activeSteamControllerIndex;
|
static uint8_t activeSteamControllerIndex;
|
||||||
static uint8_t controllerCount;
|
static uint8_t controllerCount;
|
||||||
static std::vector<Steam::SteamInput>leftStickActionSets;
|
static std::vector<Steam::SteamInput>leftStickActionSets;
|
||||||
|
|||||||
@ -1389,20 +1389,15 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
|
|||||||
if(UsingAutoAim()){
|
if(UsingAutoAim()){
|
||||||
float xAxis=0.f,yAxis=0.f;
|
float xAxis=0.f,yAxis=0.f;
|
||||||
|
|
||||||
if(useWalkDir&&movementVelocity!=vf2d{0,0}){
|
|
||||||
xAxis=aimingAngle.cart().x;
|
|
||||||
yAxis=aimingAngle.cart().y;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma region Manual Aiming
|
#pragma region Manual Aiming
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
|
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
|
||||||
xAxis=game->KEY_SCROLLHORZ_R.Analog();
|
xAxis=game->KEY_SCROLLHORZ_R.Analog();
|
||||||
}
|
}
|
||||||
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
|
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
|
||||||
yAxis=game->KEY_SCROLLVERT_R.Analog();
|
yAxis=game->KEY_SCROLLVERT_R.Analog();
|
||||||
}
|
}
|
||||||
}else{
|
)else{
|
||||||
for(GamePad*gamepad:GamePad::getGamepads()){
|
for(GamePad*gamepad:GamePad::getGamepads()){
|
||||||
if(gamepad->stillConnected){
|
if(gamepad->stillConnected){
|
||||||
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
|
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
|
||||||
@ -1421,23 +1416,33 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
|
|||||||
if(xAxis!=0.f||yAxis!=0.f){
|
if(xAxis!=0.f||yAxis!=0.f){
|
||||||
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
|
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
|
||||||
}else{
|
}else{
|
||||||
//Find the closest monster target.
|
|
||||||
vf2d closestPoint={std::numeric_limits<float>::max(),std::numeric_limits<float>::max()};
|
if(useWalkDir&&movementVelocity!=vf2d{0,0}){
|
||||||
for(Monster&m:MONSTER_LIST){
|
xAxis=aimingAngle.cart().x;
|
||||||
if(m.IsAlive()){
|
yAxis=aimingAngle.cart().y;
|
||||||
float distToMonster=geom2d::line<float>(GetPos(),m.GetPos()).length();
|
}
|
||||||
geom2d::line<float>aimingLine=geom2d::line<float>(GetPos(),m.GetPos());
|
|
||||||
vf2d aimingPoint=aimingLine.rpoint((invert?-1.f:1.f)*operator""_Pixels("Player.Aiming Cursor Max Distance"_F));
|
if(xAxis!=0.f||yAxis!=0.f){
|
||||||
float distToClosestPoint=geom2d::line<float>(GetPos(),closestPoint).length();
|
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
|
||||||
if(distToClosestPoint>distToMonster&&distToMonster<=operator""_Pixels("Player.Auto Aim Detection Distance"_F)){
|
}else{
|
||||||
closestPoint=aimingPoint;
|
//Find the closest monster target.
|
||||||
|
vf2d closestPoint={std::numeric_limits<float>::max(),std::numeric_limits<float>::max()};
|
||||||
|
for(Monster&m:MONSTER_LIST){
|
||||||
|
if(m.IsAlive()){
|
||||||
|
float distToMonster=geom2d::line<float>(GetPos(),m.GetPos()).length();
|
||||||
|
geom2d::line<float>aimingLine=geom2d::line<float>(GetPos(),m.GetPos());
|
||||||
|
vf2d aimingPoint=aimingLine.rpoint((invert?-1.f:1.f)*operator""_Pixels("Player.Aiming Cursor Max Distance"_F));
|
||||||
|
float distToClosestPoint=geom2d::line<float>(GetPos(),closestPoint).length();
|
||||||
|
if(distToClosestPoint>distToMonster&&distToMonster<=operator""_Pixels("Player.Auto Aim Detection Distance"_F)){
|
||||||
|
closestPoint=aimingPoint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(closestPoint!=vf2d{std::numeric_limits<float>::max(),std::numeric_limits<float>::max()}){
|
||||||
|
return game->GetScreenSize()/2+closestPoint-GetPos();
|
||||||
|
}else
|
||||||
|
return game->GetScreenSize()/2+vf2d{float(operator""_Pixels("Player.Aiming Cursor Max Distance"_F)),aimingAngle.y}.cart();
|
||||||
}
|
}
|
||||||
if(closestPoint!=vf2d{std::numeric_limits<float>::max(),std::numeric_limits<float>::max()}){
|
|
||||||
return game->GetScreenSize()/2+closestPoint-GetPos();
|
|
||||||
}else
|
|
||||||
return game->GetScreenSize()/2+vf2d{float(operator""_Pixels("Player.Aiming Cursor Max Distance"_F)),aimingAngle.y}.cart();
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return game->GetMousePos();
|
return game->GetMousePos();
|
||||||
|
|||||||
@ -224,9 +224,9 @@ void Menu::InitializeSettingsWindow(){
|
|||||||
settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,168.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){
|
settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,168.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){
|
||||||
ChangeKeybindDisplayType(CONTROLLER);
|
ChangeKeybindDisplayType(CONTROLLER);
|
||||||
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
|
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
SteamInput()->ShowBindingPanel(Input::steamControllers[Input::activeSteamControllerIndex]);
|
SteamInput()->ShowBindingPanel(Input::steamControllers[Input::activeSteamControllerIndex]);
|
||||||
}else{
|
)else{
|
||||||
Menu::OpenMenu(INPUT_KEY_DISPLAY);
|
Menu::OpenMenu(INPUT_KEY_DISPLAY);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -37,19 +37,22 @@ All rights reserved.
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#include "SteamKeyboardCallbackHandler.h"
|
#include "SteamKeyboardCallbackHandler.h"
|
||||||
|
#include "emscripten_compat.h"
|
||||||
|
|
||||||
void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
|
#ifndef __EMSCRIPTEN__
|
||||||
if(SteamUtils()){
|
void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
|
||||||
if(pCallback->m_bSubmitted){
|
STEAMUTILS(
|
||||||
char enteredText[17];
|
if(pCallback->m_bSubmitted){
|
||||||
SteamUtils()->GetEnteredGamepadTextInput(enteredText,16);
|
char enteredText[17];
|
||||||
Component<TextEntryLabel>(SAVE_FILE_NAME,"Save File Name Text Entry")->SetInput(std::string(enteredText));
|
SteamUtils()->GetEnteredGamepadTextInput(enteredText,16);
|
||||||
if(std::string(enteredText).length()>0){
|
Component<TextEntryLabel>(SAVE_FILE_NAME,"Save File Name Text Entry")->SetInput(std::string(enteredText));
|
||||||
Component<MenuComponent>(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(false);
|
if(std::string(enteredText).length()>0){
|
||||||
Component<MenuComponent>(SAVE_FILE_NAME,"Continue Button")->Click();
|
Component<MenuComponent>(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(false);
|
||||||
}else{
|
Component<MenuComponent>(SAVE_FILE_NAME,"Continue Button")->Click();
|
||||||
Component<MenuComponent>(SAVE_FILE_NAME,"Back Button")->Click();
|
}else{
|
||||||
}
|
Component<MenuComponent>(SAVE_FILE_NAME,"Back Button")->Click();
|
||||||
}else Component<MenuComponent>(SAVE_FILE_NAME,"Back Button")->Click();
|
}
|
||||||
}
|
}else Component<MenuComponent>(SAVE_FILE_NAME,"Back Button")->Click();
|
||||||
};
|
)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@ -37,11 +37,13 @@ All rights reserved.
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
#include <steam_api.h>
|
#include "steam/steam_api.h"
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "TextEntryLabel.h"
|
#include "TextEntryLabel.h"
|
||||||
|
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
class SteamKeyboardCallbackHandler{
|
class SteamKeyboardCallbackHandler{
|
||||||
STEAM_CALLBACK(SteamKeyboardCallbackHandler,TextEntryComplete,GamepadTextInputDismissed_t);
|
STEAM_CALLBACK(SteamKeyboardCallbackHandler,TextEntryComplete,GamepadTextInputDismissed_t);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
@ -1,5 +1,6 @@
|
|||||||
Equip Gear using Start menu tutorial
|
Equip Gear using Start menu tutorial
|
||||||
Add in vsync system option
|
|
||||||
|
Manual aim does not override movement choice.
|
||||||
|
|
||||||
============================================
|
============================================
|
||||||
|
|
||||||
|
|||||||
@ -183,9 +183,9 @@ private:
|
|||||||
virtual inline void OnComplete()override final{}
|
virtual inline void OnComplete()override final{}
|
||||||
virtual inline void Draw()const override final{
|
virtual inline void Draw()const override final{
|
||||||
if(Input::UsingGamepad()){
|
if(Input::UsingGamepad()){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::STEAM);
|
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::STEAM);
|
||||||
}else{
|
)else{
|
||||||
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::CONTROLLER);
|
attackGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Attack",180,InputType::CONTROLLER);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -217,9 +217,9 @@ private:
|
|||||||
virtual inline void OnComplete()override final{}
|
virtual inline void OnComplete()override final{}
|
||||||
virtual inline void Draw()const override final{
|
virtual inline void Draw()const override final{
|
||||||
if(Input::UsingGamepad()){
|
if(Input::UsingGamepad()){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::STEAM);
|
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::STEAM);
|
||||||
}else{
|
)else{
|
||||||
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::CONTROLLER);
|
abilityGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Abilities",180,InputType::CONTROLLER);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -245,9 +245,9 @@ private:
|
|||||||
virtual inline void OnComplete()override final{}
|
virtual inline void OnComplete()override final{}
|
||||||
virtual inline void Draw()const override final{
|
virtual inline void Draw()const override final{
|
||||||
if(Input::UsingGamepad()){
|
if(Input::UsingGamepad()){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::STEAM);
|
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::STEAM);
|
||||||
}else{
|
)else{
|
||||||
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::CONTROLLER);
|
defensiveGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Defensive Ability",180,InputType::CONTROLLER);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -285,9 +285,9 @@ private:
|
|||||||
virtual inline void OnComplete()override final{}
|
virtual inline void OnComplete()override final{}
|
||||||
virtual inline void Draw()const override final{
|
virtual inline void Draw()const override final{
|
||||||
if(Input::UsingGamepad()){
|
if(Input::UsingGamepad()){
|
||||||
if(SteamInput()){
|
STEAMINPUT(
|
||||||
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::STEAM);
|
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::STEAM);
|
||||||
}else{
|
)else{
|
||||||
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::CONTROLLER);
|
itemsGroup.DrawInput(game,{game->ScreenWidth()/2.f,48.f},"Use Consumables",180,InputType::CONTROLLER);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 8464
|
#define VERSION_BUILD 8465
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
21
Adventures in Lestoria/emscripten_compat.h
Normal file
21
Adventures in Lestoria/emscripten_compat.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "olcPixelGameEngine.h"
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#define STEAM_INPUT_MAX_COUNT 0
|
||||||
|
#define STEAM_INPUT_MAX_ORIGINS 0
|
||||||
|
#define STEAM_CALLBACK(arg1,arg2,arg3)
|
||||||
|
enum EInputActionOrigin{};
|
||||||
|
using InputHandle_t=uint64_t;
|
||||||
|
using InputActionSetHandle_t=uint64_t;
|
||||||
|
|
||||||
|
class GamepadTextInputDismissed_t{};
|
||||||
|
|
||||||
|
inline void SteamAPI_RunCallbacks(){};
|
||||||
|
|
||||||
|
#define STEAMINPUT(statement) if(false){}
|
||||||
|
#define STEAMUTILS(statement) if(false){}
|
||||||
|
#else
|
||||||
|
#define STEAMINPUT(statement) if(SteamInput()){statement}
|
||||||
|
#define STEAMUTILS(statement) if(SteamUtils()){statement}
|
||||||
|
#endif
|
||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user