mirror of
https://github.com/libretro/pcsx2.git
synced 2024-12-23 10:19:10 +00:00
GSnull: Modularise things a bit more, so we don't have a bunch of platform-specific code in the main code. (Note: the Linux side hasn't been tested yet. I'll be doing that a bit later.)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1238 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
f9cf905155
commit
82f0143d23
@ -29,15 +29,6 @@ using namespace std;
|
||||
#include "GS.h"
|
||||
#include "null/GSnull.h"
|
||||
|
||||
#ifdef __LINUX__
|
||||
Display *display;
|
||||
int screen;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HINSTANCE HInst;
|
||||
HWND GShwnd;
|
||||
#endif
|
||||
|
||||
const unsigned char version = PS2E_GS_VERSION;
|
||||
const unsigned char revision = 0;
|
||||
const unsigned char build = 1; // increase that with each version
|
||||
@ -129,64 +120,24 @@ EXPORT_C_(void) GSshutdown()
|
||||
SysPrintf("Shutting down GSnull\n");
|
||||
}
|
||||
|
||||
#ifndef __LINUX__
|
||||
LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
EXPORT_C_(s32) GSopen(void *pDsp, char *Title, int multithread)
|
||||
{
|
||||
int err = 0;
|
||||
#ifdef GS_LOG
|
||||
GS_LOG("GS open\n");
|
||||
#endif
|
||||
//assert( GSirq != NULL );
|
||||
|
||||
#ifdef __LINUX__
|
||||
display = XOpenDisplay(0);
|
||||
screen = DefaultScreen(display);
|
||||
err = GSOpenWindow(pDsp, Title);
|
||||
|
||||
if( pDsp != NULL ) *(Display**)pDsp = display;
|
||||
#else
|
||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
|
||||
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
|
||||
"PS2EMU_GSNULL", NULL };
|
||||
RegisterClassEx( &wc );
|
||||
|
||||
GShwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", "The title of my window",
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL);
|
||||
|
||||
if(GShwnd == NULL)
|
||||
{
|
||||
GS_LOG("Failed to create window. Exiting...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( pDsp != NULL ) *(int*)pDsp = (int)GShwnd;
|
||||
#endif
|
||||
SysPrintf("Opening GSnull\n");
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSclose()
|
||||
{
|
||||
SysPrintf("Closing GSnull\n");
|
||||
#ifdef __LINUX__
|
||||
XCloseDisplay(display);
|
||||
#endif
|
||||
GSCloseWindow();
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSirqCallback(void (*callback)())
|
||||
@ -205,37 +156,9 @@ EXPORT_C_(s32) GStest()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ProcessMessages()
|
||||
{
|
||||
#ifdef __LINUX__
|
||||
if ( GSKeyEvent )
|
||||
{
|
||||
int myKeyEvent = GSKeyEvent;
|
||||
bool myShift = GSShift;
|
||||
GSKeyEvent = 0;
|
||||
|
||||
switch ( myKeyEvent )
|
||||
{
|
||||
case XK_F5:
|
||||
OnKeyboardF5(myShift);
|
||||
break;
|
||||
case XK_F6:
|
||||
OnKeyboardF6(myShift);
|
||||
break;
|
||||
case XK_F7:
|
||||
OnKeyboardF7(myShift);
|
||||
break;
|
||||
case XK_F9:
|
||||
OnKeyboardF9(myShift);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSvsync(int field)
|
||||
{
|
||||
ProcessMessages();
|
||||
GSProcessMessages();
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr)
|
||||
@ -276,43 +199,7 @@ EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc)
|
||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||
EXPORT_C_(void) GSkeyEvent(keyEvent *ev)
|
||||
{
|
||||
#ifdef __LINUX__
|
||||
switch(ev->evt) {
|
||||
case KEYPRESS:
|
||||
switch(ev->key) {
|
||||
case XK_F5:
|
||||
case XK_F6:
|
||||
case XK_F7:
|
||||
case XK_F9:
|
||||
GSKeyEvent = ev->key ;
|
||||
break;
|
||||
case XK_Escape:
|
||||
break;
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
//bShift = true;
|
||||
GSShift = true;
|
||||
break;
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
GSAlt = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case KEYRELEASE:
|
||||
switch(ev->key) {
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
//bShift = false;
|
||||
GSShift = false;
|
||||
break;
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
GSAlt = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HandleKeyEvent(ev);
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSchangeSaveState(int, const char* filename)
|
||||
@ -370,10 +257,3 @@ EXPORT_C_(void) GSwriteCSR(u32 value)
|
||||
EXPORT_C_(void) GSgetDriverInfo(GSdriverInfo *info)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
EXPORT_C_(s32) GSsetWindowInfo(winInfo *info)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -22,16 +22,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "Windows/GSwin.h"
|
||||
#else
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#include "Linux/GSLinux.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
104
plugins/GSnull/Linux/GSLinux.cpp
Normal file
104
plugins/GSnull/Linux/GSLinux.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/* GSnull
|
||||
* Copyright (C) 2004-2009 PCSX2 Team
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "GSLinux.h"
|
||||
|
||||
Display *display;
|
||||
int screen;
|
||||
|
||||
int GSOpenWindow(void *pDsp, char *Title)
|
||||
{
|
||||
display = XOpenDisplay(0);
|
||||
screen = DefaultScreen(display);
|
||||
|
||||
if( pDsp != NULL )
|
||||
*(Display**)pDsp = display;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GSCloseWindow()
|
||||
{
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
|
||||
void GSProcessMessages()
|
||||
{
|
||||
if ( GSKeyEvent )
|
||||
{
|
||||
int myKeyEvent = GSKeyEvent;
|
||||
bool myShift = GSShift;
|
||||
GSKeyEvent = 0;
|
||||
|
||||
switch ( myKeyEvent )
|
||||
{
|
||||
case XK_F5:
|
||||
OnKeyboardF5(myShift);
|
||||
break;
|
||||
case XK_F6:
|
||||
OnKeyboardF6(myShift);
|
||||
break;
|
||||
case XK_F7:
|
||||
OnKeyboardF7(myShift);
|
||||
break;
|
||||
case XK_F9:
|
||||
OnKeyboardF9(myShift);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HandleKeyEvent(keyEvent *ev)
|
||||
{
|
||||
switch(ev->evt) {
|
||||
case KEYPRESS:
|
||||
switch(ev->key) {
|
||||
case XK_F5:
|
||||
case XK_F6:
|
||||
case XK_F7:
|
||||
case XK_F9:
|
||||
GSKeyEvent = ev->key ;
|
||||
break;
|
||||
case XK_Escape:
|
||||
break;
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
GSShift = true;
|
||||
break;
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
GSAlt = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case KEYRELEASE:
|
||||
switch(ev->key) {
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
GSShift = false;
|
||||
break;
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
GSAlt = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
27
plugins/GSnull/Linux/GSLinux.h
Normal file
27
plugins/GSnull/Linux/GSLinux.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* GSnull
|
||||
* Copyright (C) 2004-2009 PCSX2 Team
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include "../GS.h"
|
||||
|
||||
int GSOpenWindow(void *pDsp, char *Title);
|
||||
void GSCloseWindow();
|
||||
void GSProcessMessages();
|
||||
void HandleKeyEvent(keyEvent *ev);
|
@ -22,12 +22,14 @@ libGSnull_LDFLAGS= @SHARED_LDFLAGS@
|
||||
libGSnull_LDFLAGS+=-Wl,-soname,@libGSnull_SONAME@
|
||||
libGSnull_LDADD=$(libGSnull_a_OBJECTS)
|
||||
|
||||
libGSnull_a_SOURCES = GS.cpp Linux/Config.cpp Linux/Linux.cpp \
|
||||
FW.h Linux/Config.h Linux/Linux.h
|
||||
libGSnull_a_SOURCES = \
|
||||
GS.cpp \
|
||||
Linux/Config.cpp Linux/Linux.cpp Linux/GSLinux.cpp
|
||||
Linux/GSLinux.h Linux/Config.h Linux/Linux.h \
|
||||
GifTransfer.cpp GifTransfer.h \
|
||||
null/GSnull.cpp null/GSnull.h
|
||||
|
||||
libGSnull_a_SOURCES += \
|
||||
Linux/interface.h Linux/support.c \
|
||||
Linux/interface.c Linux/support.h \
|
||||
Linux/callbacks.h \
|
||||
GifTransfer.cpp GifTransfer.h \
|
||||
null/GSnull.cpp null/GSnull.h
|
||||
Linux/callbacks.h
|
@ -160,16 +160,40 @@
|
||||
RelativePath=".\Config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\GifTransfer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\GS.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Linux\GSLinux.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\null\GSnull.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\GifTransfer.cpp"
|
||||
RelativePath=".\GSwin.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -181,18 +205,42 @@
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\GS.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\GifTransfer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\GS.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Linux\GSLinux.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\null\GSnull.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSwin.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
|
77
plugins/GSnull/Windows/GSwin.cpp
Normal file
77
plugins/GSnull/Windows/GSwin.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/* GSnull
|
||||
* Copyright (C) 2004-2009 PCSX2 Team
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "GSwin.h"
|
||||
|
||||
HINSTANCE HInst;
|
||||
HWND GShwnd;
|
||||
|
||||
LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GSOpenWindow(void *pDsp, char *Title)
|
||||
{
|
||||
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
|
||||
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
|
||||
"PS2EMU_GSNULL", NULL };
|
||||
RegisterClassEx( &wc );
|
||||
|
||||
GShwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "PS2EMU_GSNULL", Title,
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, wc.hInstance, NULL);
|
||||
|
||||
if(GShwnd == NULL)
|
||||
{
|
||||
GS_LOG("Failed to create window. Exiting...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( pDsp != NULL ) *(int*)pDsp = (int)GShwnd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GSCloseWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void GSProcessMessages()
|
||||
{
|
||||
}
|
||||
|
||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||
void HandleKeyEvent(keyEvent *ev)
|
||||
{
|
||||
}
|
||||
|
||||
EXPORT_C_(s32) GSsetWindowInfo(winInfo *info)
|
||||
{
|
||||
return 0;
|
||||
}
|
36
plugins/GSnull/Windows/GSwin.h
Normal file
36
plugins/GSnull/Windows/GSwin.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* GSnull
|
||||
* Copyright (C) 2004-2009 PCSX2 Team
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include "../GS.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#define GSdefs
|
||||
#include "PS2Edefs.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int GSOpenWindow(void *pDsp, char *Title);
|
||||
void GSCloseWindow();
|
||||
void GSProcessMessages();
|
||||
void HandleKeyEvent(keyEvent *ev);
|
Loading…
Reference in New Issue
Block a user