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 Include="Effect.h" />
|
||||
<ClInclude Include="Emitter.h" />
|
||||
<ClInclude Include="emscripten_compat.h" />
|
||||
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h" />
|
||||
<ClInclude Include="EnhancementStatsLabel.h">
|
||||
<SubType>
|
||||
|
@ -624,6 +624,9 @@
|
||||
<ClInclude Include="SteamKeyboardCallbackHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="emscripten_compat.h">
|
||||
<Filter>Header Files\steam</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
|
@ -74,7 +74,7 @@ All rights reserved.
|
||||
#include "InventoryScrollableWindowComponent.h"
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include "discord.h"
|
||||
#include <steam_api.h>
|
||||
#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");
|
||||
}
|
||||
)
|
||||
|
||||
#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,6 +2685,7 @@ datafiledoubledata AiL::GetDoubleList(std::string key){
|
||||
}
|
||||
|
||||
bool Steam_Init(){
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if(SteamAPI_Init()){
|
||||
if(SteamUtils()!=nullptr){
|
||||
SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
|
||||
@ -2691,17 +2694,20 @@ bool Steam_Init(){
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#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(){
|
||||
#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){
|
||||
STEAMINPUT(
|
||||
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 "Checkbox.h"
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <isteamutils.h>
|
||||
#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;
|
||||
|
||||
|
@ -91,11 +91,15 @@ inline std::ofstream debugLogger;
|
||||
std::stringstream errStream; \
|
||||
errStream<<err; \
|
||||
Error::log(errStream,std::source_location::current());}
|
||||
#define LOG(err) { \
|
||||
std::stringstream errStream; \
|
||||
errStream<<err; \
|
||||
Error::log(errStream,std::source_location::current());}
|
||||
|
||||
class Error{
|
||||
public:
|
||||
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__
|
||||
throw;
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@ const InputType InputHelper::InputMode()const{
|
||||
|
||||
void InputHelper::Draw(){
|
||||
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.
|
||||
|
||||
auto OriginalGameIcon=[](std::optional<Input>input)->bool{
|
||||
|
@ -60,8 +60,9 @@ uint8_t Input::controllerCount{0};
|
||||
std::vector<Steam::SteamInput>Input::leftStickActionSets{Steam::MOVE};
|
||||
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{
|
||||
#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"},
|
||||
@ -139,6 +140,7 @@ std::unordered_map<EInputActionOrigin,std::string>Input::steamIconToGameIcon{
|
||||
{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,6 +176,7 @@ void Input::Initialize(){
|
||||
|
||||
void Input::LoadSteamButtonIcons(){
|
||||
GFX.Unlock();
|
||||
#ifndef __EMSCRIPTEN__
|
||||
for(int i=1;i<k_EInputActionOrigin_Count;i++){
|
||||
const char*imageName{SteamInput()->GetGlyphPNGForActionOrigin(EInputActionOrigin(i),k_ESteamInputGlyphSize_Small,0U)};
|
||||
if(imageName!=nullptr){
|
||||
@ -187,11 +190,12 @@ void Input::LoadSteamButtonIcons(){
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
GFX.SetInitialized();
|
||||
}
|
||||
|
||||
void Input::UpdateSteamInput(){
|
||||
if(SteamInput()){
|
||||
STEAMINPUT(
|
||||
uint8_t prevControllerCount=controllerCount;
|
||||
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.
|
||||
@ -224,7 +228,7 @@ void Input::UpdateSteamInput(){
|
||||
steamGameInputToAnalogOrigin[input].first=SteamInput()->GetAnalogActionOrigins(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<GPButtons>(key)).bPressed)inputPressed=true;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case STEAM:{
|
||||
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<GPButtons>(key)).bHeld;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case STEAM:{
|
||||
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<GPButtons>(key)).bReleased;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case STEAM:{
|
||||
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<GPAxes>(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<GPAxes>(key));
|
||||
if(axisVal!=0.f){
|
||||
usingGamepad=true;
|
||||
return axisVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case KEY:
|
||||
@ -702,10 +711,10 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi
|
||||
|
||||
switch(type){
|
||||
case CONTROLLER:{
|
||||
if(SteamInput()){
|
||||
STEAMINPUT(
|
||||
primaryKey=GetPrimaryKey(STEAM);
|
||||
type=STEAM;
|
||||
}else{
|
||||
)else{
|
||||
primaryKey=GetPrimaryKey(CONTROLLER);
|
||||
}
|
||||
}break;
|
||||
@ -879,6 +888,7 @@ const bool Input::HasExtendedIcons()const{
|
||||
}
|
||||
const Renderable&Input::GetIcon()const{
|
||||
if(type==STEAM){
|
||||
#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))&&
|
||||
@ -897,6 +907,7 @@ const Renderable&Input::GetIcon()const{
|
||||
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<unsigned short>::max(),std::numeric_limits<unsigned short>::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;i<controllerCount;i++){
|
||||
SteamInput()->TriggerVibration(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;i<controllerCount;i++){
|
||||
SteamInput()->SetLEDColor(steamControllers[i],col.r,col.g,col.b,0);
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
@ -46,7 +46,10 @@ All rights reserved.
|
||||
#include "IconType.h"
|
||||
#include "olcPGEX_ViewPort.h"
|
||||
#include "UndefKeys.h"
|
||||
#include <isteaminput.h>
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include "steam/isteaminput.h"
|
||||
#endif
|
||||
#include "emscripten_compat.h"
|
||||
|
||||
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 void Initialize();
|
||||
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 controllerCount;
|
||||
static std::vector<Steam::SteamInput>leftStickActionSets;
|
||||
|
@ -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){
|
||||
@ -1418,6 +1413,15 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
if(xAxis!=0.f||yAxis!=0.f){
|
||||
return {(game->ScreenWidth()*xAxis)/2+game->ScreenWidth()/2,(game->ScreenHeight()*yAxis)/2+game->ScreenHeight()/2};
|
||||
}else{
|
||||
|
||||
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{
|
||||
@ -1439,6 +1443,7 @@ const vf2d Player::GetAimingLocation(bool useWalkDir,bool invert){
|
||||
}else
|
||||
return game->GetScreenSize()/2+vf2d{float(operator""_Pixels("Player.Aiming Cursor Max Distance"_F)),aimingAngle.y}.cart();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
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){
|
||||
ChangeKeybindDisplayType(CONTROLLER);
|
||||
Component<MenuLabel>(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;
|
||||
|
@ -37,9 +37,11 @@ All rights reserved.
|
||||
#pragma endregion
|
||||
|
||||
#include "SteamKeyboardCallbackHandler.h"
|
||||
#include "emscripten_compat.h"
|
||||
|
||||
void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
|
||||
if(SteamUtils()){
|
||||
#ifndef __EMSCRIPTEN__
|
||||
void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_t* pCallback ){
|
||||
STEAMUTILS(
|
||||
if(pCallback->m_bSubmitted){
|
||||
char enteredText[17];
|
||||
SteamUtils()->GetEnteredGamepadTextInput(enteredText,16);
|
||||
@ -51,5 +53,6 @@ void SteamKeyboardCallbackHandler::TextEntryComplete( GamepadTextInputDismissed_
|
||||
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 once
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <steam_api.h>
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
#include <string>
|
||||
#include "TextEntryLabel.h"
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
class SteamKeyboardCallbackHandler{
|
||||
STEAM_CALLBACK(SteamKeyboardCallbackHandler,TextEntryComplete,GamepadTextInputDismissed_t);
|
||||
};
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
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 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{
|
||||
|
@ -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
|
||||
|
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