/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/PadNull/Pad.cpp
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/PadNull/Pad.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22