Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
U-inolen-PC\inolen
authored and
U-inolen-PC\inolen
committed
Feb 8, 2012
1 parent
00d25dd
commit 6e9f15f
Showing
11 changed files
with
252 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.sublime-* | ||
*.o | ||
*.so | ||
build/ | ||
bootstrap/ | ||
ioquake3/* | ||
!ioquake3/Makefile.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "GameProcessWin.h" | ||
#include <boost/filesystem/operations.hpp> | ||
//#include <glib.h> | ||
//#include <sys/wait.h> | ||
#include "PluginWindow.h" | ||
#include "PluginWindowWin.h" | ||
|
||
namespace fs = boost::filesystem; | ||
|
||
GameProcessWin::GameProcessWin(FB::PluginWindow *window, const std::string& path) : | ||
/*gamepid_(0),*/ | ||
GameProcess(window, path) { | ||
} | ||
|
||
GameProcessWin::~GameProcessWin() { | ||
Kill(); | ||
} | ||
|
||
bool GameProcessWin::SpawnNativeProcess() { | ||
/*FB::PluginWindowWin *window = dynamic_cast<FB::PluginWindowWin*>(window_); | ||
// SDL hijacking! Setting the SDL_WINDOWID environment variable will cause any | ||
// subsequent calls to SDL_SetVideoMade (like the one made in the ioquake3 | ||
// initialization) use the specified window id for rendering, instead of | ||
// creating a new one. | ||
const int xid = window->getWindow(); | ||
std::ostringstream sxid; | ||
sxid << xid; | ||
setenv("SDL_WINDOWID", sxid.str().c_str(), TRUE); | ||
// Install the shim. This shim gets loaded before any other shared assemblies, | ||
// allowing us to override functions in subsequently loaded assemblies. We use | ||
// this to do things such as intercepting the SDL event polling and | ||
// injecting our own translated events from GTK. | ||
fs::path p(path_); | ||
std::ostringstream shimPath; | ||
shimPath << p.parent_path() << "/libq3pluginshim.so"; | ||
setenv("LD_PRELOAD", shimPath.str().c_str(), TRUE); | ||
// Launch game. | ||
g_spawn_async(NULL, (gchar**)argv_, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &gamepid_, NULL);*/ | ||
return true; | ||
} | ||
|
||
void GameProcessWin::KillNativeProcess() { | ||
/*if (gamepid_ != 0) { | ||
// Request the child process terminate. | ||
kill(gamepid_, SIGTERM); | ||
// Wait for it to. | ||
waitpid(gamepid_, NULL, 0); | ||
// Close process resource. | ||
g_spawn_close_pid(gamepid_); | ||
gamepid_ = 0; | ||
}*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef GAMEPROCESSWIN_H | ||
#define GAMEPROCESSWIN_H | ||
|
||
#include "../GameProcess.h" | ||
|
||
class GameProcessWin : public GameProcess { | ||
public: | ||
GameProcessWin(FB::PluginWindow *window, const std::string& path); | ||
virtual ~GameProcessWin(); | ||
|
||
protected: | ||
virtual bool SpawnNativeProcess(); | ||
virtual void KillNativeProcess(); | ||
|
||
private: | ||
//pid_t gamepid_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#include "Q3PluginWin.h" | ||
#include <SDL.h> | ||
#include "PluginEvents/KeyCodes.h" | ||
#include "PluginWindowWin.h" | ||
#include "../Q3PluginApi.h" | ||
|
||
/*static int fb_to_sdl(FB::FBKeyCode key) { | ||
switch (key) { | ||
case FB::FBKEY_PAGEUP: | ||
return SDLK_PAGEUP; | ||
case FB::FBKEY_PAGEDOWN: | ||
return SDLK_PAGEDOWN; | ||
case FB::FBKEY_RETURN: | ||
return SDLK_RETURN; | ||
} | ||
return -1; | ||
}*/ | ||
|
||
Q3PluginWin::Q3PluginWin() { | ||
} | ||
|
||
Q3PluginWin::~Q3PluginWin() { | ||
} | ||
|
||
void Q3PluginWin::ProcessMessage(message_t& msg) { | ||
/*Q3Plugin::ProcessMessage(msg); | ||
if (msg.type == MOUSELOCK) { | ||
mouseLocked_ = msg.mouselock.lock; | ||
}*/ | ||
} | ||
|
||
bool Q3PluginWin::onKeyDown(FB::KeyDownEvent *evt, FB::PluginWindow *window) { | ||
/*int key = evt->m_os_key_code >= 0 && evt->m_os_key_code <= 255 ? evt->m_os_key_code : fb_to_sdl(evt->m_key_code); | ||
if (key != -1) { | ||
message_t msg; | ||
msg.type = SDLEVENT; | ||
msg.sdlevent.event.type = SDL_KEYDOWN; | ||
msg.sdlevent.event.key.keysym.sym = (SDLKey)key; | ||
msg.sdlevent.event.key.keysym.unicode = key; | ||
SendMessage(msg); | ||
} | ||
return true;*/ | ||
return false; | ||
} | ||
|
||
bool Q3PluginWin::onKeyUp(FB::KeyUpEvent *evt, FB::PluginWindow *window) { | ||
/*int key = evt->m_os_key_code >= 0 && evt->m_os_key_code <= 255 ? evt->m_os_key_code : fb_to_sdl(evt->m_key_code); | ||
if (key != -1) { | ||
message_t msg; | ||
msg.type = SDLEVENT; | ||
msg.sdlevent.event.type = SDL_KEYUP; | ||
msg.sdlevent.event.key.keysym.sym = (SDLKey)key; | ||
msg.sdlevent.event.key.keysym.unicode = key; | ||
SendMessage(msg); | ||
} | ||
return true;*/ | ||
return false; | ||
} | ||
|
||
bool Q3PluginWin::onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *window) { | ||
/*message_t msg; | ||
msg.type = SDLEVENT; | ||
msg.sdlevent.event.type = SDL_MOUSEBUTTONDOWN; | ||
switch (evt->m_Btn) { | ||
case 0: | ||
msg.sdlevent.event.button.button = 1; | ||
break; | ||
case 1: | ||
msg.sdlevent.event.button.button = 2; | ||
break; | ||
case 2: | ||
msg.sdlevent.event.button.button = 3; | ||
break; | ||
} | ||
SendMessage(msg); | ||
return true;*/ | ||
return false; | ||
} | ||
|
||
bool Q3PluginWin::onMouseUp(FB::MouseUpEvent *evt, FB::PluginWindow *window) { | ||
/*message_t msg; | ||
msg.type = SDLEVENT; | ||
msg.sdlevent.event.type = SDL_MOUSEBUTTONUP; | ||
switch (evt->m_Btn) { | ||
case 0: | ||
msg.sdlevent.event.button.button = 1; | ||
break; | ||
case 1: | ||
msg.sdlevent.event.button.button = 2; | ||
break; | ||
case 2: | ||
msg.sdlevent.event.button.button = 3; | ||
break; | ||
} | ||
SendMessage(msg); | ||
return true;*/ | ||
return false; | ||
} | ||
|
||
bool Q3PluginWin::onMouseMove(FB::MouseMoveEvent *evt, FB::PluginWindow *window) { | ||
/*if (mouseLocked_) { | ||
// Forward the event. | ||
message_t msg; | ||
msg.type = SDLEVENT; | ||
msg.sdlevent.event.type = SDL_MOUSEMOTION; | ||
msg.sdlevent.event.motion.xrel = evt->m_x - window->getWindowWidth()/2; | ||
msg.sdlevent.event.motion.yrel = evt->m_y - window->getWindowHeight()/2; | ||
SendMessage(msg); | ||
// Center the mouse. | ||
FB::PluginWindowX11 *window = dynamic_cast<FB::PluginWindowX11*>(GetWindow()); | ||
GtkWidget *widget = window->getWidget(); | ||
Display *xdsp = GDK_WINDOW_XDISPLAY(widget->window); | ||
Window xwnd = GDK_WINDOW_XWINDOW(widget->window); | ||
XWarpPointer(xdsp, None, xwnd, 0,0,0,0, window->getWindowWidth()/2, window->getWindowHeight()/2); | ||
} | ||
return true;*/ | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef Q3PLUGINWIN_H | ||
#define Q3PLUGINWIN_H | ||
|
||
#include "../Q3Plugin.h" | ||
|
||
class Q3PluginWin : public Q3Plugin { | ||
public: | ||
Q3PluginWin(); | ||
virtual ~Q3PluginWin(); | ||
|
||
protected: | ||
virtual void ProcessMessage(message_t& msg); | ||
|
||
virtual bool onKeyDown(FB::KeyDownEvent *evt, FB::PluginWindow *window); | ||
virtual bool onKeyUp(FB::KeyUpEvent *evt, FB::PluginWindow *window); | ||
virtual bool onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *window); | ||
virtual bool onMouseUp(FB::MouseUpEvent *evt, FB::PluginWindow *window); | ||
virtual bool onMouseMove(FB::MouseMoveEvent *evt, FB::PluginWindow *window); | ||
|
||
private: | ||
bool mouseLocked_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters