/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta/plugins/PadNull/Pad.cpp
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta/plugins/PadNull/Pad.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (10 years, 8 months ago) by william
File size: 3256 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
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/Padnull.ini";
30
31 FILE *padLog;
32 Config conf;
33 keyEvent event;
34 static keyEvent s_event;
35
36 EXPORT_C_(u32) PS2EgetLibType()
37 {
38 return PS2E_LT_PAD;
39 }
40
41 EXPORT_C_(char*) PS2EgetLibName()
42 {
43 return libraryName;
44 }
45
46 EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
47 {
48 return (version<<16) | (revision<<8) | build;
49 }
50
51 void __Log(const char *fmt, ...)
52 {
53 va_list list;
54
55 if (padLog == NULL) return;
56 va_start(list, fmt);
57 vfprintf(padLog, fmt, list);
58 va_end(list);
59 }
60
61 void __LogToConsole(const char *fmt, ...)
62 {
63 va_list list;
64
65 va_start(list, fmt);
66
67 if (padLog != NULL) vfprintf(padLog, fmt, list);
68
69 printf("PadNull: ");
70 vprintf(fmt, list);
71 va_end(list);
72 }
73
74 EXPORT_C_(s32) PADinit(u32 flags)
75 {
76 LoadConfig();
77
78 #ifdef PAD_LOG
79 if (padLog == NULL)
80 {
81 padLog = fopen("logs/padLog.txt", "w");
82 if (padLog) setvbuf(padLog, NULL, _IONBF, 0);
83 }
84 PAD_LOG("PADinit\n");
85 #endif
86
87 return 0;
88 }
89
90 EXPORT_C_(void) PADshutdown()
91 {
92 #ifdef PAD_LOG
93 if (padLog != NULL)
94 {
95 fclose(padLog);
96 padLog = NULL;
97 }
98 #endif
99 }
100
101 EXPORT_C_(s32) PADopen(void *pDsp)
102 {
103 memset(&event, 0, sizeof(event));
104
105 return _PADOpen(pDsp);
106 }
107
108 EXPORT_C_(void) PADclose()
109 {
110 _PADClose();
111 }
112
113 // PADkeyEvent is called every vsync (return NULL if no event)
114 EXPORT_C_(keyEvent*) PADkeyEvent()
115 {
116
117 s_event = event;
118 event.evt = 0;
119
120 return &s_event;
121 }
122
123 EXPORT_C_(u8) PADstartPoll(int pad)
124 {
125 return 0;
126 }
127
128 EXPORT_C_(u8) PADpoll(u8 value)
129 {
130 return 0;
131 }
132
133 // call to give a hint to the PAD plugin to query for the keyboard state. A
134 // good plugin will query the OS for keyboard state ONLY in this function.
135 // This function is necessary when multithreading because otherwise
136 // the PAD plugin can get into deadlocks with the thread that really owns
137 // the window (and input). Note that PADupdate can be called from a different
138 // thread than the other functions, so mutex or other multithreading primitives
139 // have to be added to maintain data integrity.
140 EXPORT_C_(u32) PADquery()
141 // returns: 1 if supported pad1
142 // 2 if supported pad2
143 // 3 if both are supported
144 {
145 return 3;
146 }
147
148 EXPORT_C_(void) PADupdate(int pad)
149 {
150 _PadUpdate(pad);
151 }
152
153 EXPORT_C_(void) PADgsDriverInfo(GSdriverInfo *info)
154 {
155 }
156
157 EXPORT_C_(s32) PADfreeze(int mode, freezeData *data)
158 {
159 return 0;
160 }
161
162 EXPORT_C_(s32) PADtest()
163 {
164 return 0;
165 }

  ViewVC Help
Powered by ViewVC 1.1.22