Skip to content

Commit

Permalink
add NO_XBOX because windows phone does not support XInput. Are you fk…
Browse files Browse the repository at this point in the history
…ing kidding me MS?
  • Loading branch information
duchuule committed Jun 11, 2015
1 parent 7fdddb9 commit 4a6104d
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CXBOXController.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "CXBOXController.h"

#ifndef NO_XBOX
namespace VBA10
{
CXBOXController::CXBOXController(int playerNumber)
Expand Down Expand Up @@ -33,4 +33,5 @@ namespace VBA10

XInputSetState(this->controllerNumber, &vibration);
}
}
}
#endif
5 changes: 5 additions & 0 deletions CXBOXController.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@


#ifndef CXBOXCONTROLLER_H_
#define CXBOXCONTROLLER_H_

#ifndef NO_XBOX
#include <Windows.h>
#include <Xinput.h>

Expand All @@ -20,4 +23,6 @@ namespace VBA10
};
}

#endif

#endif
4 changes: 3 additions & 1 deletion ControllerInput.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifndef NO_XBOX
#include "ControllerInput.h"

namespace VBA10
Expand Down Expand Up @@ -47,4 +48,5 @@ namespace VBA10
}
}

}
}
#endif
6 changes: 5 additions & 1 deletion ControllerInput.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

#pragma once

#ifndef NO_XBOX

#include "Input.h"
#include "CXBOXController.h"
#include "EmulatorInput.h"
Expand All @@ -20,4 +23,5 @@ namespace VBA10
ControllerState state;
CXBOXController *xboxPad;
};
}
}
#endif
7 changes: 5 additions & 2 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ void DirectXPage::NavMenuList_ItemInvoked(Object^ sender, ListViewItem^ listView
void DirectXPage::TogglePaneButton_UnChecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{

//unload the content of app frame
AppFrame->Content = nullptr;
//change the size of app frame to zero to hide content
AppFrame->Width = 0.0f;

//unselect item
NavMenuList->SetSelectedItem(nullptr);
Expand Down Expand Up @@ -446,6 +446,9 @@ void DirectXPage::NavMenuItemContainerContentChanging(ListViewBase^ sender, Cont

void DirectXPage::TogglePaneButton_Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
//change width to 100%, NAN means auto
AppFrame->Width = NAN;

//navigate to the first item
auto item = NavMenuList->ContainerFromItem(NavMenuList->Items->GetAt(0));
NavMenuList->InvokeItem(item);
Expand Down
9 changes: 8 additions & 1 deletion Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ namespace VBA10

void EmulatorGame::ReleaseAllResources(void)
{
#ifndef NO_XBOX
delete this->p1Controller;
#endif
delete this->keyboard;
delete this->virtualInput;

Expand All @@ -91,7 +93,9 @@ namespace VBA10

void EmulatorGame::Initialize()
{
#ifndef NO_XBOX
this->p1Controller = new ControllerInput(1);
#endif
this->keyboard = new KeyboardInput();
this->virtualInput = new VirtualControllerInput();

Expand Down Expand Up @@ -170,11 +174,12 @@ namespace VBA10
{
return this->keyboard;
}

#ifndef NO_XBOX
ControllerInput *EmulatorGame::GetControllerInput(void) const
{
return this->p1Controller;
}
#endif

void EmulatorGame::FocusChanged(bool focus)
{
Expand Down Expand Up @@ -284,7 +289,9 @@ namespace VBA10
void EmulatorGame::Update(void)
{
this->keyboard->Update();
#ifndef NO_XBOX
this->p1Controller->Update();
#endif
this->virtualInput->Update();

/*if(timeMeasured && IsROMLoaded() && (!Settings.StopEmulation || autosaving))
Expand Down
4 changes: 4 additions & 0 deletions Emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ namespace VBA10
static EmulatorGame *GetInstance();
VirtualControllerInput *GetVirtualController(void) const;
KeyboardInput *GetKeyboardInput(void) const;
#ifndef NO_XBOX
ControllerInput *GetControllerInput(void) const;
#endif
int GetWidth(void);
int GetHeight(void);
void FocusChanged(bool focus);
Expand All @@ -67,7 +69,9 @@ namespace VBA10
bool focus;
bool graphicsResourcesReleased;
bool restoreState;
#ifndef NO_XBOX
ControllerInput *p1Controller;
#endif
KeyboardInput *keyboard;
VirtualControllerInput *virtualInput;
int updateCount;
Expand Down
4 changes: 2 additions & 2 deletions VBA10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Link>
<AdditionalDependencies>d2d1.lib;d3d11.lib;XInput.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib</AdditionalLibraryDirectories>
</Link>
<ClCompile>
Expand All @@ -143,7 +143,7 @@
<AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/bigobj /Zm120 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);METRO_APP;__WIN32__;C_CORE;NO_ASM;NO_OGL;NO_OAL;NO_LINK;NO_PNG;_CRT_SECURE_NO_WARNINGS;DNO_DEFLATE;FINAL_VERSION;NO_DEFLATE</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);METRO_APP;__WIN32__;C_CORE;NO_ASM;NO_OGL;NO_OAL;NO_LINK;NO_PNG;NO_XBOX;_CRT_SECURE_NO_WARNINGS;DNO_DEFLATE;FINAL_VERSION;NO_DEFLATE</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
</ClCompile>
Expand Down
2 changes: 0 additions & 2 deletions VBA10.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@
<Filter>Controls</Filter>
</ClCompile>
<ClCompile Include="NavMenuItem.cpp" />
<ClCompile Include="AppShell.xaml.cpp" />
<ClCompile Include="BasicPage.xaml.cpp" />
<ClCompile Include="PageHeader.xaml.cpp" />
</ItemGroup>
Expand Down Expand Up @@ -491,7 +490,6 @@
<Filter>Controls</Filter>
</ClInclude>
<ClInclude Include="NavMenuItem.h" />
<ClInclude Include="AppShell.xaml.h" />
<ClInclude Include="BasicPage.xaml.h" />
<ClInclude Include="PageHeader.xaml.h" />
</ItemGroup>
Expand Down
15 changes: 14 additions & 1 deletion vbaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,28 @@ u32 systemReadJoypad(int gamepad)

EmulatorGame *emulator = EmulatorGame::GetInstance();
KeyboardInput *keyboard = emulator->GetKeyboardInput();
#ifndef NO_XBOX
ControllerInput *controller = emulator->GetControllerInput();
#endif

VirtualControllerInput *vController = VirtualControllerInput::GetInstance();
if(!controller || !vController || !keyboard)
if (
#ifndef NO_XBOX
!controller ||
#endif
!vController || !keyboard)
return res;

//const ControllerState *state = controller->GetControllerState();
const ControllerState *keyboardState = keyboard->GetControllerState();
#ifndef NO_XBOX
const ControllerState *controllerState = controller->GetControllerState();
#else

ControllerState controllerState1 = { false, false, false, false, false, false, false, false, false, false, false, false, false, false };
const ControllerState *controllerState = &controllerState1;
#endif

const ControllerState *vControllerState = vController->GetControllerState();

if(keyboardState->APressed || controllerState->APressed || vControllerState->APressed)
Expand Down

0 comments on commit 4a6104d

Please sign in to comment.