Permalink
Browse files

git-svn-id: https://jarenaissance.svn.sourceforge.net/svnroot/jarenai…

…ssance/trunk@51 7d4315b7-3a6b-433c-8ee3-f64c52bfdc48
  • Loading branch information...
1 parent f26c050 commit 33f91d34212e62870bc320478deb869ed32ce456 @mrwonko committed Aug 10, 2011
Showing with 167 additions and 291 deletions.
  1. +3 −3 code/03-testsnshit/03-testsnshit.cbp
  2. +3 −2 code/Jedi Academy Renaissance.workspace
  3. +3 −2 code/jarlib/include/jar/input/Event.hpp
  4. +12 −3 code/jarlib/include/jar/input/InputDeviceJoystick.hpp
  5. +9 −1 code/jarlib/include/jar/input/InputDeviceManager.hpp
  6. +5 −0 code/jarlib/include/jar/input/InputImpl.hpp
  7. +5 −2 code/jarlib/include/jar/input/Windows/WinJoystickDirectInput.hpp
  8. +3 −1 code/jarlib/include/jar/input/Windows/WinJoystickXInput.hpp
  9. +0 −37 code/jarlib/include/jar/luabind/FileSystem.hpp
  10. +0 −33 code/jarlib/include/jar/luabind/STL.hpp
  11. +0 −4 code/jarlib/jar-core.cbp
  12. +3 −0 code/jarlib/jar-input.cbp
  13. +2 −2 code/jarlib/src/jar/core/CoreImpl.cpp
  14. +1 −0 code/jarlib/src/jar/core/FileSystem.cpp
  15. +5 −5 code/jarlib/src/jar/input/InputDeviceJoystick.cpp
  16. +15 −2 code/jarlib/src/jar/input/InputDeviceManager.cpp
  17. +8 −6 code/jarlib/src/jar/input/InputImpl.cpp
  18. +14 −1 code/jarlib/src/jar/input/Windows/WinJoystickDirectInput.cpp
  19. +7 −1 code/jarlib/src/jar/input/Windows/WinJoystickXInput.cpp
  20. +3 −2 code/jarlib/src/jar/input/luabind/Event.cpp
  21. +17 −0 code/jarlib/src/jar/input/luabind/InputDeviceJoystick.cpp
  22. +16 −0 code/jarlib/src/jar/input/luabind/InputDeviceManager.cpp
  23. +17 −0 code/jarlib/src/jar/input/luabind/InputImpl.cpp
  24. +0 −123 code/jarlib/src/jar/luabind/FileSystem.cpp
  25. +0 −54 code/jarlib/src/jar/luabind/STL.cpp
  26. +1 −0 dependencies.txt
  27. +1 −0 renaissance/addons/shootemup/code/Enemy.lua
  28. +2 −2 renaissance/addons/shootemup/code/Gamefield.lua
  29. +2 −0 renaissance/addons/shootemup/code/Main.lua
  30. +3 −0 renaissance/addons/shootemup/code/Shot.lua
  31. +1 −1 renaissance/addons/shootemup/code/init/shootemup_init.lua
  32. +5 −0 renaissance/config/InactiveMods.lua
  33. +1 −4 what to do next.txt
@@ -2,12 +2,12 @@
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
- <Option title="03-testsnshit" />
+ <Option title="03-main" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug Win32">
- <Option output="..\..\renaissance\bin\03-testsnshit" prefix_auto="1" extension_auto="1" />
+ <Option output="..\..\renaissance\bin\03-main" prefix_auto="1" extension_auto="1" />
<Option working_dir="..\..\renaissance\bin" />
<Option object_output="obj\Debug\" />
<Option type="1" />
@@ -24,7 +24,7 @@
</Linker>
</Target>
<Target title="Release Win32">
- <Option output="..\..\renaissance\bin\03-testsnshit" prefix_auto="1" extension_auto="1" />
+ <Option output="..\..\renaissance\bin\03-main" prefix_auto="1" extension_auto="1" />
<Option working_dir="..\..\renaissance\bin" />
<Option object_output="obj\Release\" />
<Option type="1" />
@@ -5,7 +5,7 @@
<Project filename="jarlib/jar-input.cbp">
<Depends filename="jarlib/jar-core.cbp" />
</Project>
- <Project filename="jarlib/jar-graphics.cbp" active="1">
+ <Project filename="jarlib/jar-graphics.cbp">
<Depends filename="jarlib/jar-core.cbp" />
<Depends filename="jarlib/jar-input.cbp" />
</Project>
@@ -15,10 +15,11 @@
<Project filename="02-filesystem/02-filesytem.cbp">
<Depends filename="jarlib/jar-core.cbp" />
</Project>
- <Project filename="03-testsnshit/03-testsnshit.cbp">
+ <Project filename="03-testsnshit/03-testsnshit.cbp" active="1">
<Depends filename="jarlib/jar-core.cbp" />
<Depends filename="jarlib/jar-input.cbp" />
<Depends filename="jarlib/jar-graphics.cbp" />
+ <Depends filename="jarlib/jar-audio.cbp" />
</Project>
<Project filename="04-inputtest/04-inputtest.cbp">
<Depends filename="jarlib/jar-core.cbp" />
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "jar/input/API.hpp"
class lua_State;
+class InputDeviceJoystick;
namespace sf
{
@@ -105,15 +106,15 @@ struct JARINPUTAPI Event
**/
struct JARINPUTAPI JoyButtonEvent
{
- unsigned int JoyIndex; ///< The joystick index
+ InputDeviceJoystick* Joystick; ///< The joystick
unsigned int Button; ///< the button index
};
/** \brief Info for Event of EventType JoyAxisMoved
**/
struct JARINPUTAPI JoyAxisEvent
{
- unsigned int JoyIndex; ///< The joystick index
+ InputDeviceJoystick* Joystick; ///< The joystick
unsigned int Axis; ///< The axis index
float Position; ///< The Axis's position, in [-1; 1]
};
@@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <vector>
+class lua_State;
+
namespace jar {
class JARINPUTAPI InputDeviceJoystick : public InputDevice
@@ -38,8 +40,6 @@ class JARINPUTAPI InputDeviceJoystick : public InputDevice
virtual const DeviceType GetDeviceType() const { return DT_Joystick; }
- unsigned int Index;
-
const unsigned int GetNumRumblers() const;
/** \param value in range [0, 1]
@@ -55,8 +55,17 @@ class JARINPUTAPI InputDeviceJoystick : public InputDevice
/** \brief Enable or disable rumbling **/
void EnableRumble(const bool enable) { mRumbleEnabled = enable; }
+ const unsigned int GetIndex() const { return mIndex; }
+
+ /** \note While two Joysticks may have the same name, they'll never have the same UID. **/
+ virtual std::string GetUniqueID() const = 0;
+
+ static void Luabind(lua_State* L);
+
protected:
+ unsigned int mIndex;
+
/** \brief Whether rumbling is enabled (default: true) **/
bool mRumbleEnabled;
@@ -71,7 +80,7 @@ class JARINPUTAPI InputDeviceJoystick : public InputDevice
unsigned int mNumRumblers;
/** \brief Constructor **/
- InputDeviceJoystick();
+ InputDeviceJoystick(unsigned int index);
/** \brief Sends a JoyButtonPressed Event.
\param button index of the pressed button **/
@@ -28,6 +28,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "jar/core/Time.hpp"
#include "jar/input/API.hpp"
#include <set>
+#include <list>
+
+class lua_State;
namespace jar
{
@@ -69,15 +72,20 @@ class JARINPUTAPI InputDeviceManager : public EventListener
/** \brief Deinitializes, deletes and removes an InputDevice from the manager.
\param device The InputDevice
- \return Whether the device existed in the manager. Even if it didn't it still got deleted.
+ \return Whether the device existed in the manager. Even if it didn't it still gets deleted.
**/
const bool DeleteInputDevice(InputDevice* device);
/** \brief Retrieve a joystick of a given index
\return The joystick, or NULL if no such joystick exists. **/
InputDeviceJoystick* GetJoystick(const unsigned int index) const;
+ /** \note For luabind to be able to work with the returned list, it apparently mustn't be an object since Luabind only takes iterator ownership. **/
+ std::list<InputDeviceJoystick*>& GetAllJoysticks() const;
+
virtual void ReceiveEvent(const Event& event);
+
+ static void Luabind(lua_State* state);
private:
std::set<InputDevice*> mDevices;
bool mInitialized;
@@ -41,6 +41,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <vector>
#include <cassert>
+class lua_State;
+
namespace jar {
class InputDeviceManager;
@@ -77,6 +79,9 @@ class InputImpl : public Component
void OnWindowCreated();
+ /** \brief Exposes Input to Lua (not InputImpl!) **/
+ static void Luabind(lua_State* state);
+
private:
InputDeviceManager* mInputDeviceManager;
EventManager* mEventManager;
@@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <dinput.h>
#include <cmath>
+#include <boost/noncopyable.hpp>
#include "jar/input/InputDeviceJoystick.hpp"
@@ -44,10 +45,10 @@ namespace Windows {
\note The buttons 0-15 are reserved for DPad up (0/4/8/12), down (1/5/9/13), left (2/6/10/14), right (3/7/11/15).
**/
-class WinJoystickDirectInput : public jar::InputDeviceJoystick, public Updatable
+class WinJoystickDirectInput : public jar::InputDeviceJoystick, public Updatable, public boost::noncopyable
{
public:
- WinJoystickDirectInput();
+ WinJoystickDirectInput(unsigned int index);
virtual ~WinJoystickDirectInput();
const bool Init(LPDIRECTINPUT8 directInput, LPCDIDEVICEINSTANCE deviceInfo);
@@ -58,6 +59,8 @@ class WinJoystickDirectInput : public jar::InputDeviceJoystick, public Updatable
void OnFirstWindowCreated(HWND hwnd);
+ virtual std::string GetUniqueID() const;
+
struct AxisRangeInfo
{
int min;
@@ -56,7 +56,7 @@ namespace Windows {
class WinJoystickXInput : public InputDeviceJoystick, public Updatable
{
public:
- WinJoystickXInput();
+ WinJoystickXInput(unsigned int index);
virtual ~WinJoystickXInput();
/** \brief Initializes the joystick
@@ -69,6 +69,8 @@ class WinJoystickXInput : public InputDeviceJoystick, public Updatable
virtual void Update(TimeType deltaT);
+ virtual std::string GetUniqueID() const;
+
private:
/// XInput index of this Gamepad
DWORD mXIndex;
@@ -1,37 +0,0 @@
-/*
-===========================================================================
-Copyright (C) 2010 Willi Schinmeyer
-
-This file is part of the Jedi Academy: Renaissance source code.
-
-Jedi Academy: Renaissance source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Jedi Academy: Renaissance source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Jedi Academy: Renaissance source code; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#ifndef JAR_LUABIND_FILESYSTEM_HPP
-#define JAR_LUABIND_FILESYSTEM_HPP
-
-struct lua_State;
-
-namespace jar
-{
-
-/** \brief Binds some PhysFS and Minizip functionality to lua via luabind.
-**/
-void BindFileSystem(lua_State* L);
-}
-
-#endif //JAR_LUABIND_FILESYSTEM_HPP
-
@@ -1,33 +0,0 @@
-/*
-===========================================================================
-Copyright (C) 2010 Willi Schinmeyer
-
-This file is part of the Jedi Academy: Renaissance source code.
-
-Jedi Academy: Renaissance source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Jedi Academy: Renaissance source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Jedi Academy: Renaissance source code; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#ifndef JAR_LUABIND_STL_HPP
-#define JAR_LUABIND_STL_HPP
-
-struct lua_State;
-
-namespace jar
-{
-void BindSTL(lua_State* L);
-}
-
-#endif //JAR_LUABIND_STL_HPP
@@ -75,8 +75,6 @@
<Unit filename="include\jar\core\Updatable.hpp" />
<Unit filename="include\jar\core\VoidLogger.hpp" />
<Unit filename="include\jar\luabind\Core.hpp" />
- <Unit filename="include\jar\luabind\FileSystem.hpp" />
- <Unit filename="include\jar\luabind\STL.hpp" />
<Unit filename="src\jar\Core.cpp" />
<Unit filename="src\jar\core\CLArguments.cpp" />
<Unit filename="src\jar\core\Component.cpp" />
@@ -92,8 +90,6 @@
<Unit filename="src\jar\core\Time.cpp" />
<Unit filename="src\jar\core\Updatable.cpp" />
<Unit filename="src\jar\luabind\Core.cpp" />
- <Unit filename="src\jar\luabind\FileSystem.cpp" />
- <Unit filename="src\jar\luabind\STL.cpp" />
<Extensions>
<code_completion />
<envvars />
@@ -97,6 +97,9 @@
<Unit filename="src\jar\input\Windows\WinJoystickDirectInput.cpp" />
<Unit filename="src\jar\input\Windows\WinJoystickXInput.cpp" />
<Unit filename="src\jar\input\luabind\Event.cpp" />
+ <Unit filename="src\jar\input\luabind\InputDeviceJoystick.cpp" />
+ <Unit filename="src\jar\input\luabind\InputDeviceManager.cpp" />
+ <Unit filename="src\jar\input\luabind\InputImpl.cpp" />
<Extensions>
<code_completion />
<envvars />
@@ -99,13 +99,13 @@ const bool CoreImpl::Init(int argc, char** argv, const std::string& rootPath)
assert(argc > 0);
if(!fs::Init(argv[0]))
{
- Logger::GetDefaultLogger().Error(fs::GetLastError());
+ Logger::GetDefaultLogger().Error("Cannot initialize filesystem: " + fs::GetLastError());
Deinit();
return false;
}
if(not fs::SetWriteDir("./"))
{
- Logger::GetDefaultLogger().Error(fs::GetLastError());
+ Logger::GetDefaultLogger().Error("Cannot set write directory: " + fs::GetLastError());
Deinit();
return false;
}
@@ -45,6 +45,7 @@ const bool Deinit()
const bool SetWriteDir(const std::string& writedir)
{
+ //FIXME: does not work if directory has special characters, especially 'é' (Salathé)
return PHYSFS_setWriteDir((CLArguments::GetSingleton().GetWorkingDirectory() + Core::GetSingleton().GetRootPath() + writedir).c_str());
}
@@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
namespace jar {
-InputDeviceJoystick::InputDeviceJoystick() :
- Index(0),
+InputDeviceJoystick::InputDeviceJoystick(unsigned int index) :
+ mIndex(index),
mRumbleEnabled(true),
mNumRumblers(0)
{
@@ -89,7 +89,7 @@ void InputDeviceJoystick::JoyButtonPressed(unsigned int button)
Event e;
e.Type = Event::JoyButtonPressed;
e.JoyButton.Button = button;
- e.JoyButton.JoyIndex = Index;
+ e.JoyButton.Joystick = this;
SendEvent(e);
}
@@ -98,7 +98,7 @@ void InputDeviceJoystick::JoyButtonReleased(unsigned int button)
Event e;
e.Type = Event::JoyButtonReleased;
e.JoyButton.Button = button;
- e.JoyButton.JoyIndex = Index;
+ e.JoyButton.Joystick = this;
SendEvent(e);
}
@@ -108,7 +108,7 @@ void InputDeviceJoystick::JoyAxisMoved(unsigned int axis, float position)
e.Type = Event::JoyAxisMoved;
e.JoyAxis.Axis = axis;
e.JoyAxis.Position = position;
- e.JoyButton.JoyIndex = Index;
+ e.JoyButton.Joystick = this;
SendEvent(e);
}
Oops, something went wrong.

0 comments on commit 33f91d3

Please sign in to comment.