@@ -33,7 +33,7 @@ static TUSPiLibrary *s_pLibrary = 0;
33
33
34
34
int USPiInitialize (void )
35
35
{
36
- assert (s_pLibrary == 0 );
36
+ if (s_pLibrary != 0 ) return 1 ;
37
37
s_pLibrary = (TUSPiLibrary * ) malloc (sizeof (TUSPiLibrary ));
38
38
assert (s_pLibrary != 0 );
39
39
@@ -92,7 +92,7 @@ int USPiInitialize (void)
92
92
93
93
int USPiKeyboardAvailable (void )
94
94
{
95
- assert (s_pLibrary != 0 );
95
+ if (s_pLibrary == 0 ) return 0 ;
96
96
return s_pLibrary -> pUKBD1 != 0 ;
97
97
}
98
98
@@ -119,7 +119,7 @@ void USPiKeyboardRegisterKeyStatusHandlerRaw (TKeyStatusHandlerRaw *pKeyStatusHa
119
119
120
120
int USPiMouseAvailable (void )
121
121
{
122
- assert (s_pLibrary != 0 );
122
+ if (s_pLibrary == 0 ) return 0 ;
123
123
return s_pLibrary -> pUMouse1 != 0 ;
124
124
}
125
125
@@ -132,7 +132,7 @@ void USPiMouseRegisterStatusHandler (TUSPiMouseStatusHandler *pStatusHandler)
132
132
133
133
int USPiMassStorageDeviceAvailable (void )
134
134
{
135
- assert (s_pLibrary != 0 );
135
+ if (s_pLibrary == 0 ) return 0 ;
136
136
137
137
unsigned i ;
138
138
for (i = 0 ; i < MAX_DEVICES ; i ++ )
@@ -197,7 +197,7 @@ unsigned USPiMassStorageDeviceGetCapacity (unsigned nDeviceIndex)
197
197
198
198
int USPiEthernetAvailable (void )
199
199
{
200
- assert (s_pLibrary != 0 );
200
+ if (s_pLibrary == 0 ) return 0 ;
201
201
return s_pLibrary -> pEth0 != 0 ;
202
202
}
203
203
@@ -227,7 +227,7 @@ int USPiReceiveFrame (void *pBuffer, unsigned *pResultLength)
227
227
228
228
int USPiGamePadAvailable (void )
229
229
{
230
- assert (s_pLibrary != 0 );
230
+ if (s_pLibrary == 0 ) return 0 ;
231
231
232
232
unsigned i ;
233
233
for (i = 0 ; i < MAX_DEVICES ; i ++ )
@@ -272,7 +272,7 @@ const USPiGamePadState *USPiGamePadGetStatus (unsigned nDeviceIndex)
272
272
273
273
int USPiDeviceGetInformation (unsigned nClass , unsigned nDeviceIndex , TUSPiDeviceInformation * pInfo )
274
274
{
275
- assert (s_pLibrary != 0 );
275
+ if (s_pLibrary == 0 ) return 0 ;
276
276
277
277
TUSBDevice * pUSBDevice = 0 ;
278
278
0 commit comments