| @@ -70,7 +70,8 @@ endif | |||||
| if HAVE_XBOX | if HAVE_XBOX | ||||
| xbox_sources = \ | xbox_sources = \ | ||||
| platform/xbox/xboxapp.cpp platform/xbox/xboxapp.h | |||||
| platform/xbox/xboxapp.cpp platform/xbox/xboxapp.h \ | |||||
| platform/xbox/xboxinput.cpp platform/xbox/xboxinput.h | |||||
| endif | endif | ||||
| android_sources = \ | android_sources = \ | ||||
| @@ -17,8 +17,8 @@ | |||||
| #endif | #endif | ||||
| #include "core.h" | #include "core.h" | ||||
| #include "lolgl.h" | |||||
| #include "xboxapp.h" | #include "xboxapp.h" | ||||
| #include "xboxinput.h" | |||||
| #if defined _XBOX | #if defined _XBOX | ||||
| extern D3DDevice *g_d3ddevice; | extern D3DDevice *g_d3ddevice; | ||||
| @@ -50,6 +50,9 @@ XboxApp::XboxApp(char const *title, ivec2 res, float fps) : | |||||
| #if defined _XBOX | #if defined _XBOX | ||||
| Ticker::Setup(fps); | Ticker::Setup(fps); | ||||
| Video::Setup(res); | Video::Setup(res); | ||||
| /* Autoreleased objects */ | |||||
| new XboxInput(); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -0,0 +1,102 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
| // | |||||
| #if defined HAVE_CONFIG_H | |||||
| # include "config.h" | |||||
| #endif | |||||
| #if defined _XBOX | |||||
| # include <xtl.h> | |||||
| # include <xbdm.h> | |||||
| #endif | |||||
| #include "core.h" | |||||
| #include "xboxinput.h" | |||||
| namespace lol | |||||
| { | |||||
| /* | |||||
| * Xbox Input implementation class | |||||
| */ | |||||
| class XboxInputData | |||||
| { | |||||
| friend class XboxInput; | |||||
| private: | |||||
| #if defined _XBOX | |||||
| Array<int, Stick *> m_joysticks; | |||||
| #endif | |||||
| }; | |||||
| /* | |||||
| * Public XboxInput class | |||||
| */ | |||||
| XboxInput::XboxInput() | |||||
| : m_data(new XboxInputData()) | |||||
| { | |||||
| #if defined _XBOX | |||||
| for (int i = 0; i < XUSER_MAX_COUNT; i++) | |||||
| { | |||||
| XINPUT_STATE state; | |||||
| if (XInputGetState(i, &state) != ERROR_SUCCESS) | |||||
| continue; | |||||
| Stick *stick = Input::CreateStick(); | |||||
| stick->SetAxisCount(4); | |||||
| stick->SetButtonCount(0); | |||||
| m_data->m_joysticks.Push(i, stick); | |||||
| } | |||||
| #endif | |||||
| m_gamegroup = GAMEGROUP_BEFORE; | |||||
| } | |||||
| XboxInput::~XboxInput() | |||||
| { | |||||
| #if defined _XBOX | |||||
| /* Unregister all the joysticks we added */ | |||||
| while (m_data->m_joysticks.Count()) | |||||
| { | |||||
| Input::DestroyStick(m_data->m_joysticks[0].m2); | |||||
| m_data->m_joysticks.Remove(0); | |||||
| } | |||||
| #endif | |||||
| delete m_data; | |||||
| } | |||||
| void XboxInput::TickGame(float seconds) | |||||
| { | |||||
| Entity::TickGame(seconds); | |||||
| } | |||||
| void XboxInput::TickDraw(float seconds) | |||||
| { | |||||
| Entity::TickDraw(seconds); | |||||
| #if defined _XBOX | |||||
| for (int i = 0; i < m_data->m_joysticks.Count(); i++) | |||||
| { | |||||
| XINPUT_STATE state; | |||||
| if (XInputGetState(m_data->m_joysticks[i].m1, &state) != ERROR_SUCCESS) | |||||
| continue; | |||||
| m_data->m_joysticks[i].m2->SetAxis(0, (float)state.Gamepad.sThumbLX / 32768.f); | |||||
| m_data->m_joysticks[i].m2->SetAxis(1, -(float)state.Gamepad.sThumbLY / 32768.f); | |||||
| m_data->m_joysticks[i].m2->SetAxis(2, (float)state.Gamepad.sThumbRX / 32768.f); | |||||
| m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f); | |||||
| } | |||||
| #endif | |||||
| } | |||||
| } /* namespace lol */ | |||||
| @@ -0,0 +1,43 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
| // | |||||
| // | |||||
| // The XboxInput class | |||||
| // ------------------- | |||||
| // | |||||
| #if !defined __LOL_XBOXINPUT_H__ | |||||
| #define __LOL_XBOXINPUT_H__ | |||||
| #include "entity.h" | |||||
| namespace lol | |||||
| { | |||||
| class XboxInputData; | |||||
| class XboxInput : public Entity | |||||
| { | |||||
| public: | |||||
| XboxInput(); | |||||
| virtual ~XboxInput(); | |||||
| protected: | |||||
| virtual void TickGame(float seconds); | |||||
| virtual void TickDraw(float seconds); | |||||
| private: | |||||
| XboxInputData *m_data; | |||||
| }; | |||||
| } /* namespace lol */ | |||||
| #endif // __LOL_XBOXINPUT_H__ | |||||
| @@ -111,6 +111,7 @@ | |||||
| <ClCompile Include="..\src\platform\sdl\sdlapp.cpp" /> | <ClCompile Include="..\src\platform\sdl\sdlapp.cpp" /> | ||||
| <ClCompile Include="..\src\platform\sdl\sdlinput.cpp" /> | <ClCompile Include="..\src\platform\sdl\sdlinput.cpp" /> | ||||
| <ClCompile Include="..\src\platform\xbox\xboxapp.cpp" /> | <ClCompile Include="..\src\platform\xbox\xboxapp.cpp" /> | ||||
| <ClCompile Include="..\src\platform\xbox\xboxinput.cpp" /> | |||||
| <ClCompile Include="..\src\profiler.cpp" /> | <ClCompile Include="..\src\profiler.cpp" /> | ||||
| <ClCompile Include="..\src\sample.cpp" /> | <ClCompile Include="..\src\sample.cpp" /> | ||||
| <ClCompile Include="..\src\sampler.cpp" /> | <ClCompile Include="..\src\sampler.cpp" /> | ||||
| @@ -169,6 +170,7 @@ | |||||
| <ClInclude Include="..\src\platform\sdl\sdlapp.h" /> | <ClInclude Include="..\src\platform\sdl\sdlapp.h" /> | ||||
| <ClInclude Include="..\src\platform\sdl\sdlinput.h" /> | <ClInclude Include="..\src\platform\sdl\sdlinput.h" /> | ||||
| <ClInclude Include="..\src\platform\xbox\xboxapp.h" /> | <ClInclude Include="..\src\platform\xbox\xboxapp.h" /> | ||||
| <ClInclude Include="..\src\platform\xbox\xboxinput.h" /> | |||||
| <ClInclude Include="..\src\profiler.h" /> | <ClInclude Include="..\src\profiler.h" /> | ||||
| <ClInclude Include="..\src\sample.h" /> | <ClInclude Include="..\src\sample.h" /> | ||||
| <ClInclude Include="..\src\sampler.h" /> | <ClInclude Include="..\src\sampler.h" /> | ||||
| @@ -193,6 +193,9 @@ | |||||
| <ClCompile Include="..\src\platform\xbox\xboxapp.cpp"> | <ClCompile Include="..\src\platform\xbox\xboxapp.cpp"> | ||||
| <Filter>src\platform\xbox</Filter> | <Filter>src\platform\xbox</Filter> | ||||
| </ClCompile> | </ClCompile> | ||||
| <ClCompile Include="..\src\platform\xbox\xboxinput.cpp"> | |||||
| <Filter>src\platform\xbox</Filter> | |||||
| </ClCompile> | |||||
| <ClCompile Include="..\src\gpu\indexbuffer.cpp"> | <ClCompile Include="..\src\gpu\indexbuffer.cpp"> | ||||
| <Filter>src\gpu</Filter> | <Filter>src\gpu</Filter> | ||||
| </ClCompile> | </ClCompile> | ||||
| @@ -366,6 +369,9 @@ | |||||
| <ClInclude Include="..\src\platform\xbox\xboxapp.h"> | <ClInclude Include="..\src\platform\xbox\xboxapp.h"> | ||||
| <Filter>src\platform\xbox</Filter> | <Filter>src\platform\xbox</Filter> | ||||
| </ClInclude> | </ClInclude> | ||||
| <ClInclude Include="..\src\platform\xbox\xboxinput.h"> | |||||
| <Filter>src\platform\xbox</Filter> | |||||
| </ClInclude> | |||||
| <ClInclude Include="..\src\gpu\indexbuffer.h"> | <ClInclude Include="..\src\gpu\indexbuffer.h"> | ||||
| <Filter>src\gpu</Filter> | <Filter>src\gpu</Filter> | ||||
| </ClInclude> | </ClInclude> | ||||
| @@ -382,4 +388,4 @@ | |||||
| <Filter>src\input</Filter> | <Filter>src\input</Filter> | ||||
| </ClInclude> | </ClInclude> | ||||
| </ItemGroup> | </ItemGroup> | ||||
| </Project> | |||||
| </Project> | |||||
| @@ -259,8 +259,8 @@ Global | |||||
| {B1E10086-A1DA-401A-834D-969C9DBB5CC1} = {E0491194-35E3-4513-9D31-608EA3165ECF} | {B1E10086-A1DA-401A-834D-969C9DBB5CC1} = {E0491194-35E3-4513-9D31-608EA3165ECF} | ||||
| {80F81C11-8DA2-4990-91CB-9807783BA46E} = {E0491194-35E3-4513-9D31-608EA3165ECF} | {80F81C11-8DA2-4990-91CB-9807783BA46E} = {E0491194-35E3-4513-9D31-608EA3165ECF} | ||||
| {B92ABADC-45BE-4CC5-B724-9426053123A1} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | {B92ABADC-45BE-4CC5-B724-9426053123A1} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | ||||
| {6BF81B39-EDC2-4227-9992-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||||
| {7B083DA2-FE08-4F6D-BFDD-195D5C2783EB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | {7B083DA2-FE08-4F6D-BFDD-195D5C2783EB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | ||||
| {6BF81B39-EDC2-4227-9992-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||||
| {32F3F8CF-D22E-45E4-BEB8-AD909E8C5515} = {33704AA4-F2B5-4138-A40D-E3E77F89ED46} | {32F3F8CF-D22E-45E4-BEB8-AD909E8C5515} = {33704AA4-F2B5-4138-A40D-E3E77F89ED46} | ||||
| {EE203B88-44CF-4859-9D42-7A5F40FECB52} = {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} | {EE203B88-44CF-4859-9D42-7A5F40FECB52} = {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} | ||||
| EndGlobalSection | EndGlobalSection | ||||