1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
|
/* PadNull
* Copyright (C) 2004-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 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 PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <string>
using namespace std;
#include "svnrev.h"
#include "Pad.h"
const u8 version = PS2E_PAD_VERSION;
const u8 revision = 0;
const u8 build = 1; // increase that with each version
#ifdef _MSC_VER
#define snprintf sprintf_s
#endif
static char libraryName[256];
string s_strIniPath = "inis";
string s_strLogPath = "logs";
FILE *padLog;
Config conf;
keyEvent event;
static keyEvent s_event;
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_PAD;
}
EXPORT_C_(const char *)
PS2EgetLibName()
{
snprintf(libraryName, 255, "Padnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName;
}
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
void __Log(const char *fmt, ...)
{
va_list list;
if (padLog == NULL)
return;
va_start(list, fmt);
vfprintf(padLog, fmt, list);
va_end(list);
}
void __LogToConsole(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (padLog != NULL)
vfprintf(padLog, fmt, list);
printf("PadNull: ");
vprintf(fmt, list);
va_end(list);
}
EXPORT_C_(void)
PADsetSettingsDir(const char *dir)
{
s_strIniPath = (dir == NULL) ? "inis" : dir;
}
bool OpenLog()
{
bool result = true;
#ifdef PAD_LOG
if (padLog)
return result;
const std::string LogFile(s_strLogPath + "/padnull.log");
padLog = fopen(LogFile.c_str(), "w");
if (padLog != NULL)
setvbuf(padLog, NULL, _IONBF, 0);
else {
fprintf(stderr, "Can't create log file %s\n", LogFile.c_str());
result = false;
}
PAD_LOG("PADinit\n");
#endif
return result;
}
EXPORT_C_(void)
PADsetLogDir(const char *dir)
{
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path
if (padLog) {
fclose(padLog);
padLog = NULL;
}
OpenLog();
}
EXPORT_C_(s32)
PADinit(u32 flags)
{
LoadConfig();
OpenLog();
return 0;
}
EXPORT_C_(void)
PADshutdown()
{
#ifdef PAD_LOG
if (padLog) {
fclose(padLog);
padLog = NULL;
}
#endif
}
EXPORT_C_(s32)
PADopen(void *pDsp)
{
memset(&event, 0, sizeof(event));
return _PADOpen(pDsp);
}
EXPORT_C_(void)
PADclose()
{
_PADClose();
}
// PADkeyEvent is called every vsync (return NULL if no event)
EXPORT_C_(keyEvent *)
PADkeyEvent()
{
s_event = event;
event.evt = 0;
event.key = 0;
return &s_event;
}
EXPORT_C_(u8)
PADstartPoll(int pad)
{
return 0;
}
EXPORT_C_(u8)
PADpoll(u8 value)
{
return 0;
}
// call to give a hint to the PAD plugin to query for the keyboard state. A
// good plugin will query the OS for keyboard state ONLY in this function.
// This function is necessary when multithreading because otherwise
// the PAD plugin can get into deadlocks with the thread that really owns
// the window (and input). Note that PADupdate can be called from a different
// thread than the other functions, so mutex or other multithreading primitives
// have to be added to maintain data integrity.
EXPORT_C_(u32)
PADquery()
// returns: 1 if supported pad1
// 2 if supported pad2
// 3 if both are supported
{
return 3;
}
EXPORT_C_(void)
PADupdate(int pad)
{
_PadUpdate(pad);
}
EXPORT_C_(void)
PADgsDriverInfo(GSdriverInfo *info)
{
}
EXPORT_C_(s32)
PADfreeze(int mode, freezeData *data)
{
return 0;
}
EXPORT_C_(s32)
PADtest()
{
return 0;
}
|