diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
index 3e6f06b2..96c4fbf3 100644
--- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj
+++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
@@ -329,6 +329,7 @@
+
diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
index 5fa23f97..8cf54293 100644
--- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
+++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
@@ -624,6 +624,9 @@
Header Files
+
+ Header Files\steam
+
diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp
index 6326d949..d66a763e 100644
--- a/Adventures in Lestoria/AdventuresInLestoria.cpp
+++ b/Adventures in Lestoria/AdventuresInLestoria.cpp
@@ -74,7 +74,7 @@ All rights reserved.
#include "InventoryScrollableWindowComponent.h"
#ifndef __EMSCRIPTEN__
#include "discord.h"
- #include
+ #include "steam/steam_api.h"
#endif
#include "GameSettings.h"
#include "LoadingScreen.h"
@@ -323,15 +323,17 @@ bool AiL::OnUserCreate(){
#endif
State_OverworldMap::SetStageMarker("starting_map_name"_S);
- if(SteamInput()!=nullptr){
+ STEAMINPUT(
SteamInput()->Init(false);
Input::LoadSteamButtonIcons();
Input::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
- }
+ )
- if(steamKeyboardCallbackListener==nullptr){
- steamKeyboardCallbackListener=new SteamKeyboardCallbackHandler();
- }
+ #ifndef __EMSCRIPTEN__
+ if(steamKeyboardCallbackListener==nullptr){
+ steamKeyboardCallbackListener=new SteamKeyboardCallbackHandler();
+ }
+ #endif
utils::datafile::INITIAL_SETUP_COMPLETE=true;
@@ -353,10 +355,10 @@ bool AiL::OnUserCreate(){
bool AiL::OnUserUpdate(float fElapsedTime){
levelTime+=fElapsedTime;
SteamAPI_RunCallbacks();
- if(SteamInput()){
+ STEAMINPUT(
ActivateActionSetForAllControllers(Input::ingameControlsHandle);
Input::UpdateSteamInput();
- }
+ )
if(GetMousePos()!=lastMousePos){
lastMouseMovement=0.f;
@@ -2127,10 +2129,10 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
GetPlayer()->SetInvisible(false);
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::ingameControlsHandle=SteamInput()->GetActionSetHandle("InGameControls");
- }
+ )
ZONE_LIST=game->MAP_DATA[game->GetCurrentLevel()].ZoneData;
return true;
@@ -2683,25 +2685,29 @@ datafiledoubledata AiL::GetDoubleList(std::string key){
}
bool Steam_Init(){
- if(SteamAPI_Init()){
- if(SteamUtils()!=nullptr){
- SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
- LOG(std::format("STEAM[{}]: {}",severity,std::string(message)));
- });
+ #ifndef __EMSCRIPTEN__
+ if(SteamAPI_Init()){
+ if(SteamUtils()!=nullptr){
+ SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
+ LOG(std::format("STEAM[{}]: {}",severity,std::string(message)));
+ });
+ }
+ return true;
}
- return true;
- }
+ #endif
return false;
}
int main()
{
- if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
- if(Steam_Init()){
- LOG("Steam API Initialized successfully!");
- }else{
- LOG("Steam API failed to initialize!");
- }
+ #ifndef __EMSCRIPTEN__
+ if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
+ if(Steam_Init()){
+ LOG("Steam API Initialized successfully!");
+ }else{
+ LOG("Steam API failed to initialize!");
+ }
+ #endif
{
AiL demo;
@@ -2870,7 +2876,9 @@ bool AiL::IsReflectiveTile(TilesheetData tileSheet,int tileID){
}
bool AiL::OnUserDestroy(){
- SteamAPI_Shutdown();
+ #ifndef __EMSCRIPTEN__
+ SteamAPI_Shutdown();
+ #endif
GFX.Reset();
for(auto&[key,value]:MAP_DATA){
if(MAP_DATA[key].optimizedTile!=nullptr){
@@ -3871,7 +3879,9 @@ int AiL::GetLoadoutSize()const{
}
void AiL::ActivateActionSetForAllControllers(InputActionSetHandle_t actionSetHandle){
- for(int i=0;iActivateActionSet(Input::steamControllers[i],actionSetHandle);
- }
+ STEAMINPUT(
+ for(int i=0;iActivateActionSet(Input::steamControllers[i],actionSetHandle);
+ }
+ )
}
\ No newline at end of file
diff --git a/Adventures in Lestoria/ClassSelectionWindow.cpp b/Adventures in Lestoria/ClassSelectionWindow.cpp
index 66581bcf..a45f1e97 100644
--- a/Adventures in Lestoria/ClassSelectionWindow.cpp
+++ b/Adventures in Lestoria/ClassSelectionWindow.cpp
@@ -46,7 +46,7 @@ All rights reserved.
#include "TextEntryLabel.h"
#include "Checkbox.h"
#ifndef __EMSCRIPTEN__
- #include
+ #include "steam/isteamutils.h"
#endif
INCLUDE_game
@@ -74,9 +74,9 @@ void Menu::InitializeClassSelectionWindow(){
vf2d textboxWindowPos=data.component.lock()->rect.pos*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());
- }
+ )
return true;
},vf2d{2.f,2.f})END;
diff --git a/Adventures in Lestoria/Error.h b/Adventures in Lestoria/Error.h
index 15e57a46..cde8038d 100644
--- a/Adventures in Lestoria/Error.h
+++ b/Adventures in Lestoria/Error.h
@@ -91,11 +91,15 @@ inline std::ofstream debugLogger;
std::stringstream errStream; \
errStream<input)->bool{
diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp
index 076f6e61..722f92a9 100644
--- a/Adventures in Lestoria/Key.cpp
+++ b/Adventures in Lestoria/Key.cpp
@@ -60,85 +60,87 @@ uint8_t Input::controllerCount{0};
std::vectorInput::leftStickActionSets{Steam::MOVE};
std::vectorInput::rightStickActionSets{Steam::SCROLL};
-std::array>,16>Input::enumToActionName;
+std::array>,STEAM_INPUT_MAX_COUNT>Input::enumToActionName;
std::unordered_mapInput::steamIconToGameIcon{
- {k_EInputActionOrigin_SteamController_A,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_XBoxOne_A,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_XBox360_A,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_Switch_A,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_Switch_JoyConButton_S,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_SteamDeck_A,"themes/button_d_xb.png"},
- {k_EInputActionOrigin_SteamController_B,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_XBoxOne_B,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_XBox360_B,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_Switch_B,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_Switch_JoyConButton_W,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_SteamDeck_B,"themes/button_r_xb.png"},
- {k_EInputActionOrigin_SteamController_X,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_XBoxOne_X,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_XBox360_X,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_Switch_X,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_Switch_JoyConButton_E,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_SteamDeck_X,"themes/button_l_xb.png"},
- {k_EInputActionOrigin_SteamController_Y,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_XBoxOne_Y,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_XBox360_Y,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_Switch_Y,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_Switch_JoyConButton_N,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_SteamDeck_Y,"themes/button_u_xb.png"},
- {k_EInputActionOrigin_SteamController_LeftBumper,"themes/button_l1.png"},
- {k_EInputActionOrigin_PS4_LeftBumper,"themes/button_l1.png"},
- {k_EInputActionOrigin_XBoxOne_LeftBumper,"themes/button_l1.png"},
- {k_EInputActionOrigin_XBox360_LeftBumper,"themes/button_l1.png"},
- {k_EInputActionOrigin_Switch_LeftBumper,"themes/button_l1.png"},
- {k_EInputActionOrigin_SteamDeck_L1,"themes/button_l1.png"},
- {k_EInputActionOrigin_SteamController_RightBumper,"themes/button_r1.png"},
- {k_EInputActionOrigin_PS4_RightBumper,"themes/button_r1.png"},
- {k_EInputActionOrigin_XBoxOne_RightBumper,"themes/button_r1.png"},
- {k_EInputActionOrigin_XBox360_RightBumper,"themes/button_r1.png"},
- {k_EInputActionOrigin_Switch_RightBumper,"themes/button_r1.png"},
- {k_EInputActionOrigin_SteamDeck_R1,"themes/button_r1.png"},
- {k_EInputActionOrigin_SteamController_RightTrigger_Pull,"themes/button_r2.png"},
- {k_EInputActionOrigin_PS4_RightTrigger_Pull,"themes/button_r2.png"},
- {k_EInputActionOrigin_XBoxOne_RightTrigger_Pull,"themes/button_r2.png"},
- {k_EInputActionOrigin_XBox360_RightTrigger_Pull,"themes/button_r2.png"},
- {k_EInputActionOrigin_Switch_RightTrigger_Pull,"themes/button_r2.png"},
- {k_EInputActionOrigin_SteamDeck_R2_SoftPull,"themes/button_r2.png"},
- {k_EInputActionOrigin_SteamController_RightTrigger_Click,"themes/button_r2.png"},
- {k_EInputActionOrigin_PS4_RightTrigger_Click,"themes/button_r2.png"},
- {k_EInputActionOrigin_XBoxOne_RightTrigger_Click,"themes/button_r2.png"},
- {k_EInputActionOrigin_XBox360_RightTrigger_Click,"themes/button_r2.png"},
- {k_EInputActionOrigin_Switch_RightTrigger_Click,"themes/button_r2.png"},
- {k_EInputActionOrigin_SteamDeck_R2,"themes/button_r2.png"},
- {k_EInputActionOrigin_SteamController_LeftTrigger_Pull,"themes/button_l2.png"},
- {k_EInputActionOrigin_PS4_LeftTrigger_Pull,"themes/button_l2.png"},
- {k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull,"themes/button_l2.png"},
- {k_EInputActionOrigin_XBox360_LeftTrigger_Pull,"themes/button_l2.png"},
- {k_EInputActionOrigin_Switch_LeftTrigger_Pull,"themes/button_l2.png"},
- {k_EInputActionOrigin_SteamDeck_L2_SoftPull,"themes/button_l2.png"},
- {k_EInputActionOrigin_SteamController_LeftTrigger_Click,"themes/button_l2.png"},
- {k_EInputActionOrigin_PS4_LeftTrigger_Click,"themes/button_l2.png"},
- {k_EInputActionOrigin_XBoxOne_LeftTrigger_Click,"themes/button_l2.png"},
- {k_EInputActionOrigin_XBox360_LeftTrigger_Click,"themes/button_l2.png"},
- {k_EInputActionOrigin_Switch_LeftTrigger_Click,"themes/button_l2.png"},
- {k_EInputActionOrigin_SteamDeck_L2,"themes/button_l2.png"},
- {k_EInputActionOrigin_PS4_X,"themes/button_d_ps.png"},
- {k_EInputActionOrigin_PS4_Circle,"themes/button_r_ps.png"},
- {k_EInputActionOrigin_PS4_Triangle,"themes/button_u_ps.png"},
- {k_EInputActionOrigin_PS4_Square,"themes/button_l_ps.png"},
- {k_EInputActionOrigin_SteamController_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_PS4_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_PS4_RightStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_XBoxOne_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_XBoxOne_RightStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_XBox360_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_XBox360_RightStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_Switch_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_Switch_RightStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_PS5_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_PS5_RightStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_SteamDeck_LeftStick_Move,"themes/button_analogstick.png"},
- {k_EInputActionOrigin_SteamDeck_RightStick_Move,"themes/button_analogstick.png"},
+ #ifndef __EMSCRIPTEN__
+ {k_EInputActionOrigin_SteamController_A,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_XBoxOne_A,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_XBox360_A,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_Switch_A,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_Switch_JoyConButton_S,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_SteamDeck_A,"themes/button_d_xb.png"},
+ {k_EInputActionOrigin_SteamController_B,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_XBoxOne_B,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_XBox360_B,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_Switch_B,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_Switch_JoyConButton_W,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_SteamDeck_B,"themes/button_r_xb.png"},
+ {k_EInputActionOrigin_SteamController_X,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_XBoxOne_X,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_XBox360_X,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_Switch_X,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_Switch_JoyConButton_E,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_SteamDeck_X,"themes/button_l_xb.png"},
+ {k_EInputActionOrigin_SteamController_Y,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_XBoxOne_Y,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_XBox360_Y,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_Switch_Y,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_Switch_JoyConButton_N,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_SteamDeck_Y,"themes/button_u_xb.png"},
+ {k_EInputActionOrigin_SteamController_LeftBumper,"themes/button_l1.png"},
+ {k_EInputActionOrigin_PS4_LeftBumper,"themes/button_l1.png"},
+ {k_EInputActionOrigin_XBoxOne_LeftBumper,"themes/button_l1.png"},
+ {k_EInputActionOrigin_XBox360_LeftBumper,"themes/button_l1.png"},
+ {k_EInputActionOrigin_Switch_LeftBumper,"themes/button_l1.png"},
+ {k_EInputActionOrigin_SteamDeck_L1,"themes/button_l1.png"},
+ {k_EInputActionOrigin_SteamController_RightBumper,"themes/button_r1.png"},
+ {k_EInputActionOrigin_PS4_RightBumper,"themes/button_r1.png"},
+ {k_EInputActionOrigin_XBoxOne_RightBumper,"themes/button_r1.png"},
+ {k_EInputActionOrigin_XBox360_RightBumper,"themes/button_r1.png"},
+ {k_EInputActionOrigin_Switch_RightBumper,"themes/button_r1.png"},
+ {k_EInputActionOrigin_SteamDeck_R1,"themes/button_r1.png"},
+ {k_EInputActionOrigin_SteamController_RightTrigger_Pull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_PS4_RightTrigger_Pull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_XBoxOne_RightTrigger_Pull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_XBox360_RightTrigger_Pull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_Switch_RightTrigger_Pull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_SteamDeck_R2_SoftPull,"themes/button_r2.png"},
+ {k_EInputActionOrigin_SteamController_RightTrigger_Click,"themes/button_r2.png"},
+ {k_EInputActionOrigin_PS4_RightTrigger_Click,"themes/button_r2.png"},
+ {k_EInputActionOrigin_XBoxOne_RightTrigger_Click,"themes/button_r2.png"},
+ {k_EInputActionOrigin_XBox360_RightTrigger_Click,"themes/button_r2.png"},
+ {k_EInputActionOrigin_Switch_RightTrigger_Click,"themes/button_r2.png"},
+ {k_EInputActionOrigin_SteamDeck_R2,"themes/button_r2.png"},
+ {k_EInputActionOrigin_SteamController_LeftTrigger_Pull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_PS4_LeftTrigger_Pull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_XBoxOne_LeftTrigger_Pull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_XBox360_LeftTrigger_Pull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_Switch_LeftTrigger_Pull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_SteamDeck_L2_SoftPull,"themes/button_l2.png"},
+ {k_EInputActionOrigin_SteamController_LeftTrigger_Click,"themes/button_l2.png"},
+ {k_EInputActionOrigin_PS4_LeftTrigger_Click,"themes/button_l2.png"},
+ {k_EInputActionOrigin_XBoxOne_LeftTrigger_Click,"themes/button_l2.png"},
+ {k_EInputActionOrigin_XBox360_LeftTrigger_Click,"themes/button_l2.png"},
+ {k_EInputActionOrigin_Switch_LeftTrigger_Click,"themes/button_l2.png"},
+ {k_EInputActionOrigin_SteamDeck_L2,"themes/button_l2.png"},
+ {k_EInputActionOrigin_PS4_X,"themes/button_d_ps.png"},
+ {k_EInputActionOrigin_PS4_Circle,"themes/button_r_ps.png"},
+ {k_EInputActionOrigin_PS4_Triangle,"themes/button_u_ps.png"},
+ {k_EInputActionOrigin_PS4_Square,"themes/button_l_ps.png"},
+ {k_EInputActionOrigin_SteamController_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_PS4_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_PS4_RightStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_XBoxOne_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_XBoxOne_RightStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_XBox360_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_XBox360_RightStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_Switch_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_Switch_RightStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_PS5_LeftStick_Move,"themes/button_analogstick.png"},
+ {k_EInputActionOrigin_PS5_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)
@@ -174,24 +176,26 @@ void Input::Initialize(){
void Input::LoadSteamButtonIcons(){
GFX.Unlock();
- for(int i=1;iGetGlyphPNGForActionOrigin(EInputActionOrigin(i),k_ESteamInputGlyphSize_Small,0U)};
- if(imageName!=nullptr){
- std::string loadImage{imageName};
- if(loadImage.length()>0&&(!GFX.count(loadImage)||GFX.at(loadImage).Decal()==nullptr)){
- LOG(std::format("Loading steam image {}",loadImage));
- if(!GFX.count(loadImage))GFX[loadImage];
- if(GFX.at(loadImage).Load(loadImage)!=rcode::OK){
- LOG(std::format("WARNING! Failed to load steam image {}!",loadImage));
+ #ifndef __EMSCRIPTEN__
+ for(int i=1;iGetGlyphPNGForActionOrigin(EInputActionOrigin(i),k_ESteamInputGlyphSize_Small,0U)};
+ if(imageName!=nullptr){
+ std::string loadImage{imageName};
+ if(loadImage.length()>0&&(!GFX.count(loadImage)||GFX.at(loadImage).Decal()==nullptr)){
+ LOG(std::format("Loading steam image {}",loadImage));
+ if(!GFX.count(loadImage))GFX[loadImage];
+ if(GFX.at(loadImage).Load(loadImage)!=rcode::OK){
+ LOG(std::format("WARNING! Failed to load steam image {}!",loadImage));
+ }
}
}
}
- }
+ #endif
GFX.SetInitialized();
}
void Input::UpdateSteamInput(){
- if(SteamInput()){
+ STEAMINPUT(
uint8_t prevControllerCount=controllerCount;
controllerCount=SteamInput()->GetConnectedControllers(steamControllers.data());
if(controllerCountGetAnalogActionOrigins(steamControllers[activeSteamControllerIndex],ingameControlsHandle,analogInputHnd,steamGameInputToAnalogOrigin[input].second.data());
}
}
- }
+ )
}
bool Input::Pressed(){
@@ -238,14 +242,16 @@ bool Input::Pressed(){
inputPressed=game->GetMouse(key).bPressed;
}break;
case CONTROLLER:{
- if(!SteamInput()){
+ STEAMINPUT()else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected&&gamepad->getButton(static_cast(key)).bPressed)inputPressed=true;
}
}
}break;
case STEAM:{
- if(enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bPressed)inputPressed=true;
+ STEAMINPUT(
+ if(enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bPressed)inputPressed=true;
+ )
}break;
case ANALOG:{
//An analog input can never be "pressed". No-op.
@@ -255,7 +261,7 @@ bool Input::Pressed(){
}
}
if(inputPressed){
- usingGamepad=type==CONTROLLER||type==STEAM;
+ SetUsingGamepad(type==CONTROLLER||type==STEAM);
return true;
}
return false;
@@ -272,14 +278,16 @@ bool Input::Held(){
inputHeld|=game->GetMouse(key).bHeld;
}break;
case CONTROLLER:{
- if(!SteamInput()){
+ STEAMINPUT()else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected)inputHeld|=gamepad->getButton(static_cast(key)).bHeld;
}
}
}break;
case STEAM:{
- inputHeld|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bHeld;
+ STEAMINPUT(
+ inputHeld|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bHeld;
+ )
}break;
case ANALOG:{
//An analog input can never be "held". No-op.
@@ -289,7 +297,7 @@ bool Input::Held(){
}
}
if(inputHeld){
- usingGamepad=type==CONTROLLER||type==STEAM;
+ SetUsingGamepad(type==CONTROLLER||type==STEAM);
return true;
}
return false;
@@ -306,14 +314,16 @@ bool Input::Released(){
inputReleased|=game->GetMouse(key).bReleased;
}break;
case CONTROLLER:{
- if(!SteamInput()){
+ STEAMINPUT()else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected)inputReleased|=gamepad->getButton(static_cast(key)).bReleased;
}
}
}break;
case STEAM:{
- inputReleased|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bReleased;
+ STEAMINPUT(
+ inputReleased|=enumToActionName[activeSteamControllerIndex][Steam::SteamInput(key)].second.bReleased;
+ )
}break;
case ANALOG:{
//An analog input can never be "released". No-op.
@@ -323,7 +333,7 @@ bool Input::Released(){
}
}
if(inputReleased){
- usingGamepad=type==CONTROLLER||type==STEAM;
+ SetUsingGamepad(type==CONTROLLER||type==STEAM);
return true;
}
return false;
@@ -333,18 +343,7 @@ float Input::Analog(){
if(!game->IsFocused())return false;
switch(type){
case ANALOG:{
- if(!SteamInput()){
- for(GamePad*gamepad:GamePad::getGamepads()){
- if(gamepad->stillConnected){
- float axisVal=gamepad->getAxis(static_cast(key));
- if(axisVal!=0.f){
- usingGamepad=true;
- return axisVal;
- }
- }
- }
- }else{
-
+ STEAMINPUT(
auto GetAnalogStickVal=[&](uint8_t controller,Steam::SteamInput input,Axis axis){
InputAnalogActionHandle_t inputHnd=SteamInput()->GetAnalogActionHandle(enumToActionName[controller][input].first.c_str());
InputAnalogActionData_t data=SteamInput()->GetAnalogActionData(steamControllers[controller],inputHnd);
@@ -412,6 +411,16 @@ float Input::Analog(){
case GPAxes::DY:{}break;//Unused. No-op
}
}
+ )else{
+ for(GamePad*gamepad:GamePad::getGamepads()){
+ if(gamepad->stillConnected){
+ float axisVal=gamepad->getAxis(static_cast(key));
+ if(axisVal!=0.f){
+ usingGamepad=true;
+ return axisVal;
+ }
+ }
+ }
}
}break;
case KEY:
@@ -702,10 +711,10 @@ void InputGroup::DrawPrimaryInput(const std::variant0){
- if(steamIconToGameIcon.count(action)){
- return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
- }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));
+ #ifndef __EMSCRIPTEN__
+ EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).second[0];
+ EInputActionOrigin analogAction=Input::steamGameInputToAnalogOrigin.at(Steam::SteamInput(key)).second[0];
+ if(Input::steamGameInputToOrigin.count(Steam::SteamInput(key))&&
+ Input::steamGameInputToOrigin.at(Steam::SteamInput(key)).first>0){
+ if(steamIconToGameIcon.count(action)){
+ return GFX.at(GetProperIconName(steamIconToGameIcon[action]));
+ }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));
+ }
}
- }
+ #endif
}
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
}
@@ -1060,14 +1071,14 @@ const bool Input::UsingGamepad(){
const bool Input::AxesActive(){
float xAxis=0.f,yAxis=0.f;
- if(SteamInput()){
+ STEAMINPUT(
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
return true;
}
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
return true;
}
- }else{
+ )else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
if(fabs(gamepad->getAxis(GPAxes::RX))>0.f){
@@ -1085,9 +1096,9 @@ const bool Input::AxesActive(){
void Input::StartVibration(const bool override){
if(!GameSettings::RumbleEnabled(override))return;
if(UsingGamepad()){
- if(SteamInput()){
+ STEAMINPUT(
SteamInput()->TriggerVibration(steamControllers[activeSteamControllerIndex],std::numeric_limits::max(),std::numeric_limits::max());
- }else{
+ )else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
gamepad->startVibration();
@@ -1097,11 +1108,11 @@ void Input::StartVibration(const bool override){
}
}
void Input::StopVibration(){
- if(SteamInput()){
+ STEAMINPUT(
for(int i=0;iTriggerVibration(steamControllers[i],0U,0U);
}
- }else{
+ )else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
gamepad->stopVibration();
@@ -1224,9 +1235,9 @@ const bool InputEngageGroup::GetLabelVisible()const{
}
void Input::SetLightbar(const Pixel col){
- if(SteamInput()){
+ STEAMINPUT(
for(int i=0;iSetLEDColor(steamControllers[i],col.r,col.g,col.b,0);
}
- }
+ )
}
\ No newline at end of file
diff --git a/Adventures in Lestoria/Key.h b/Adventures in Lestoria/Key.h
index 63e47250..79ae7652 100644
--- a/Adventures in Lestoria/Key.h
+++ b/Adventures in Lestoria/Key.h
@@ -46,7 +46,10 @@ All rights reserved.
#include "IconType.h"
#include "olcPGEX_ViewPort.h"
#include "UndefKeys.h"
-#include
+#ifndef __EMSCRIPTEN__
+ #include "steam/isteaminput.h"
+#endif
+#include "emscripten_compat.h"
class AiL;
@@ -111,7 +114,7 @@ class Input{
static std::unordered_map>>steamGameInputToAnalogOrigin;
static void Initialize();
static void UpdateSteamInput();
- static std::arraysteamControllers;
+ static std::arraysteamControllers;
static uint8_t activeSteamControllerIndex;
static uint8_t controllerCount;
static std::vectorleftStickActionSets;
diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp
index 13f7e976..98170254 100644
--- a/Adventures in Lestoria/Player.cpp
+++ b/Adventures in Lestoria/Player.cpp
@@ -1389,20 +1389,15 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
if(UsingAutoAim()){
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
- if(SteamInput()){
+ STEAMINPUT(
if(fabs(game->KEY_SCROLLHORZ_R.Analog())>0.f){
xAxis=game->KEY_SCROLLHORZ_R.Analog();
}
if(fabs(game->KEY_SCROLLVERT_R.Analog())>0.f){
yAxis=game->KEY_SCROLLVERT_R.Analog();
}
- }else{
+ )else{
for(GamePad*gamepad:GamePad::getGamepads()){
if(gamepad->stillConnected){
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){
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
}else{
- //Find the closest monster target.
- vf2d closestPoint={std::numeric_limits::max(),std::numeric_limits::max()};
- for(Monster&m:MONSTER_LIST){
- if(m.IsAlive()){
- float distToMonster=geom2d::line(GetPos(),m.GetPos()).length();
- geom2d::lineaimingLine=geom2d::line(GetPos(),m.GetPos());
- vf2d aimingPoint=aimingLine.rpoint((invert?-1.f:1.f)*operator""_Pixels("Player.Aiming Cursor Max Distance"_F));
- float distToClosestPoint=geom2d::line(GetPos(),closestPoint).length();
- if(distToClosestPoint>distToMonster&&distToMonster<=operator""_Pixels("Player.Auto Aim Detection Distance"_F)){
- closestPoint=aimingPoint;
+
+ if(useWalkDir&&movementVelocity!=vf2d{0,0}){
+ xAxis=aimingAngle.cart().x;
+ yAxis=aimingAngle.cart().y;
+ }
+
+ if(xAxis!=0.f||yAxis!=0.f){
+ return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
+ }else{
+ //Find the closest monster target.
+ vf2d closestPoint={std::numeric_limits::max(),std::numeric_limits::max()};
+ for(Monster&m:MONSTER_LIST){
+ if(m.IsAlive()){
+ float distToMonster=geom2d::line(GetPos(),m.GetPos()).length();
+ geom2d::lineaimingLine=geom2d::line(GetPos(),m.GetPos());
+ vf2d aimingPoint=aimingLine.rpoint((invert?-1.f:1.f)*operator""_Pixels("Player.Aiming Cursor Max Distance"_F));
+ float distToClosestPoint=geom2d::line(GetPos(),closestPoint).length();
+ if(distToClosestPoint>distToMonster&&distToMonster<=operator""_Pixels("Player.Auto Aim Detection Distance"_F)){
+ closestPoint=aimingPoint;
+ }
}
}
+ if(closestPoint!=vf2d{std::numeric_limits::max(),std::numeric_limits::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::max(),std::numeric_limits::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{
return game->GetMousePos();
diff --git a/Adventures in Lestoria/SettingsWindow.cpp b/Adventures in Lestoria/SettingsWindow.cpp
index aa9d51aa..9911b0c8 100644
--- a/Adventures in Lestoria/SettingsWindow.cpp
+++ b/Adventures in Lestoria/SettingsWindow.cpp
@@ -224,9 +224,9 @@ void Menu::InitializeSettingsWindow(){
settingsList->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,168.f},vf2d{settingsList->rect.size.x-12-56,24}},"Controller Bindings",[&](MenuFuncData data){
ChangeKeybindDisplayType(CONTROLLER);
Component(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
- if(SteamInput()){
+ STEAMINPUT(
SteamInput()->ShowBindingPanel(Input::steamControllers[Input::activeSteamControllerIndex]);
- }else{
+ )else{
Menu::OpenMenu(INPUT_KEY_DISPLAY);
}
return true;
diff --git a/Adventures in Lestoria/SteamKeyboardCallbackHandler.cpp b/Adventures in Lestoria/SteamKeyboardCallbackHandler.cpp
index 40f7b446..94122862 100644
--- a/Adventures in Lestoria/SteamKeyboardCallbackHandler.cpp
+++ b/Adventures in Lestoria/SteamKeyboardCallbackHandler.cpp
@@ -37,19 +37,22 @@ All rights reserved.
#pragma endregion
#include "SteamKeyboardCallbackHandler.h"
-
-void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
- if(SteamUtils()){
- if(pCallback->m_bSubmitted){
- char enteredText[17];
- SteamUtils()->GetEnteredGamepadTextInput(enteredText,16);
- Component(SAVE_FILE_NAME,"Save File Name Text Entry")->SetInput(std::string(enteredText));
- if(std::string(enteredText).length()>0){
- Component(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(false);
- Component(SAVE_FILE_NAME,"Continue Button")->Click();
- }else{
- Component(SAVE_FILE_NAME,"Back Button")->Click();
- }
- }else Component(SAVE_FILE_NAME,"Back Button")->Click();
- }
-};
\ No newline at end of file
+#include "emscripten_compat.h"
+
+#ifndef __EMSCRIPTEN__
+ void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
+ STEAMUTILS(
+ if(pCallback->m_bSubmitted){
+ char enteredText[17];
+ SteamUtils()->GetEnteredGamepadTextInput(enteredText,16);
+ Component(SAVE_FILE_NAME,"Save File Name Text Entry")->SetInput(std::string(enteredText));
+ if(std::string(enteredText).length()>0){
+ Component(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(false);
+ Component(SAVE_FILE_NAME,"Continue Button")->Click();
+ }else{
+ Component(SAVE_FILE_NAME,"Back Button")->Click();
+ }
+ }else Component(SAVE_FILE_NAME,"Back Button")->Click();
+ )
+ };
+#endif
\ No newline at end of file
diff --git a/Adventures in Lestoria/SteamKeyboardCallbackHandler.h b/Adventures in Lestoria/SteamKeyboardCallbackHandler.h
index eda3f90a..40c7438e 100644
--- a/Adventures in Lestoria/SteamKeyboardCallbackHandler.h
+++ b/Adventures in Lestoria/SteamKeyboardCallbackHandler.h
@@ -37,11 +37,13 @@ All rights reserved.
#pragma endregion
#pragma once
#ifndef __EMSCRIPTEN__
- #include
+ #include "steam/steam_api.h"
#endif
#include
#include "TextEntryLabel.h"
+#ifndef __EMSCRIPTEN__
class SteamKeyboardCallbackHandler{
STEAM_CALLBACK(SteamKeyboardCallbackHandler,TextEntryComplete,GamepadTextInputDismissed_t);
-};
\ No newline at end of file
+};
+#endif
\ No newline at end of file
diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt
index 91dc03ac..64b27a3d 100644
--- a/Adventures in Lestoria/TODO.txt
+++ b/Adventures in Lestoria/TODO.txt
@@ -1,5 +1,6 @@
Equip Gear using Start menu tutorial
-Add in vsync system option
+
+Manual aim does not override movement choice.
============================================
diff --git a/Adventures in Lestoria/Tutorial.h b/Adventures in Lestoria/Tutorial.h
index 71586722..86e5da6e 100644
--- a/Adventures in Lestoria/Tutorial.h
+++ b/Adventures in Lestoria/Tutorial.h
@@ -183,9 +183,9 @@ private:
virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{
if(Input::UsingGamepad()){
- if(SteamInput()){
+ STEAMINPUT(
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);
}
}else{
@@ -217,9 +217,9 @@ private:
virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{
if(Input::UsingGamepad()){
- if(SteamInput()){
+ STEAMINPUT(
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);
}
}else{
@@ -245,9 +245,9 @@ private:
virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{
if(Input::UsingGamepad()){
- if(SteamInput()){
+ STEAMINPUT(
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);
}
}else{
@@ -285,9 +285,9 @@ private:
virtual inline void OnComplete()override final{}
virtual inline void Draw()const override final{
if(Input::UsingGamepad()){
- if(SteamInput()){
+ STEAMINPUT(
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);
}
}else{
diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h
index 6d977418..e08456b1 100644
--- a/Adventures in Lestoria/Version.h
+++ b/Adventures in Lestoria/Version.h
@@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_PATCH 0
-#define VERSION_BUILD 8464
+#define VERSION_BUILD 8465
#define stringify(a) stringify_(a)
#define stringify_(a) #a
diff --git a/Adventures in Lestoria/emscripten_compat.h b/Adventures in Lestoria/emscripten_compat.h
new file mode 100644
index 00000000..78dd0604
--- /dev/null
+++ b/Adventures in Lestoria/emscripten_compat.h
@@ -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
diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe
index bf4d28c6..8917f01e 100644
Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ