-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathlibpad.c
More file actions
843 lines (704 loc) · 17.7 KB
/
libpad.c
File metadata and controls
843 lines (704 loc) · 17.7 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/
/**
* @file
* Pad library functions
* Quite easy rev engineered from util demos..
* Find any bugs? Mail me: pukko@home.se
*/
#include <tamtypes.h>
#include <kernel.h>
#include <stdio.h>
#include <string.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <sifcmd.h>
#include "libpad.h"
/*
* Defines
*/
#ifdef _XPAD
#define PAD_BIND_RPC_ID1 0x80000100
#define PAD_BIND_RPC_ID2 0x80000101
#define PAD_RPCCMD_OPEN 0x01
#define PAD_RPCCMD_SET_MMODE 0x06
#define PAD_RPCCMD_SET_ACTDIR 0x07
#define PAD_RPCCMD_SET_ACTALIGN 0x08
#define PAD_RPCCMD_GET_BTNMASK 0x09
#define PAD_RPCCMD_SET_BTNINFO 0x0A
#define PAD_RPCCMD_SET_VREF 0x0B
#define PAD_RPCCMD_GET_PORTMAX 0x0C
#define PAD_RPCCMD_GET_SLOTMAX 0x0D
#define PAD_RPCCMD_CLOSE 0x0E
#define PAD_RPCCMD_END 0x0F
#define PAD_RPCCMD_INIT 0x10
#define PAD_RPCCMD_GET_MODVER 0x12
#else
#define PAD_BIND_RPC_ID1 0x8000010f
#define PAD_BIND_RPC_ID2 0x8000011f
#define PAD_RPCCMD_OPEN 0x80000100
#define PAD_RPCCMD_INFO_ACT 0x80000102
#define PAD_RPCCMD_INFO_COMB 0x80000103
#define PAD_RPCCMD_INFO_MODE 0x80000104
#define PAD_RPCCMD_SET_MMODE 0x80000105
#define PAD_RPCCMD_SET_ACTDIR 0x80000106
#define PAD_RPCCMD_SET_ACTALIGN 0x80000107
#define PAD_RPCCMD_GET_BTNMASK 0x80000108
#define PAD_RPCCMD_SET_BTNINFO 0x80000109
#define PAD_RPCCMD_SET_VREF 0x8000010a
#define PAD_RPCCMD_GET_PORTMAX 0x8000010b
#define PAD_RPCCMD_GET_SLOTMAX 0x8000010c
#define PAD_RPCCMD_CLOSE 0x8000010d
#define PAD_RPCCMD_END 0x8000010e
#define PAD_RPCCMD_INIT 0x00000100
#endif
/*
* Types
*/
struct pad_state
{
int open;
unsigned int port;
unsigned int slot;
struct pad_data *padData;
unsigned char *padBuf;
};
#ifdef _XPAD
struct pad_data
{
u8 data[32];
u32 actDirData[2];
u32 actAlignData[2];
u8 actData[32];
u16 modeTable[4];
u32 frame;
u32 findPadRetries;
u32 length;
u8 modeConfig;
u8 modeCurId;
u8 model;
u8 buttonDataReady;
u8 nrOfModes;
u8 modeCurOffs;
u8 nrOfActuators;
u8 numActComb;
u8 val_c6;
u8 mode;
u8 lock;
u8 actDirSize;
u8 state;
u8 reqState;
u8 currentTask;
u8 runTask;
u8 stat70bit;
u8 padding[11];
};
struct open_slot
{
u32 frame;
u32 openSlots[2];
u8 padding[116];
};
#else
// rom0:padman has only 64 byte of pad data
struct pad_data
{
unsigned int frame;
unsigned char state;
unsigned char reqState;
unsigned char ok;
unsigned char unkn7;
unsigned char data[32];
unsigned int length;
unsigned char request;
/** CTP=1/no config; CTP=2/config, acts... */
unsigned char CTP;
/** 1, 2 or 3 */
unsigned char model;
/** the data in the buffer is already corrected */
unsigned char correction;
unsigned char errorCount;
unsigned char unk49[15];
};
#endif
extern int _iop_reboot_count;
/*
* Pad variables etc.
*/
static const char padStateString[8][16] = {"DISCONNECT", "FINDPAD",
"FINDCTP1", "", "", "EXECCMD",
"STABLE", "ERROR"};
static const char padReqStateString[3][16] = {"COMPLETE", "FAILED", "BUSY"};
static int padInitialised = 0;
// pad rpc call
static SifRpcClientData_t padsif[2] __attribute__((aligned(64)));
static union {
s32 command;
#ifdef _XPAD
struct {
s32 command;
s32 unused[3];
void *statBuf;
} padInitArgs;
#endif
struct {
s32 unknown[3];
s32 result;
s32 unknown2;
void *padBuf;
} padOpenResult;
struct {
s32 unknown[3];
s32 result;
} padResult;
struct {
s32 command;
s32 port, slot;
s32 unknown;
void *padArea;
} padOpenArgs;
struct {
s32 command;
s32 port, slot;
s32 unknown;
s32 mode;
} padCloseArgs;
struct {
s32 command;
s32 port;
} padSlotMaxArgs;
struct {
s32 command;
s32 port, slot;
s32 infoMode;
s32 index;
} padInfoModeArgs;
struct {
s32 command;
s32 port, slot;
s32 mode;
s32 lock;
} padSetMainModeArgs;
struct {
s32 unknown[5];
s32 result;
} padModeResult;
struct {
s32 command;
s32 port, slot;
} padGetButtonMaskArgs;
struct {
s32 command;
s32 port, slot;
s32 buttonInfo;
} padSetButtonInfoArgs;
struct {
s32 unknown[4];
s32 result;
} padSetButtonInfoResult;
struct {
s32 command;
s32 port, slot;
#ifndef _XPAD
s32 actuator;
s32 act_cmd;
} padInfoActArgs;
struct {
s32 command;
s32 port, slot;
#endif
s8 align[6];
} padActDirAlignArgs;
char buffer[128];
}
#ifdef _XPAD
buffer __attribute__((aligned(64)));
#else
buffer __attribute__((aligned(16)));
#endif
/** Port state data */
#ifdef _XPAD
static struct open_slot openSlot[2] __attribute__((aligned(64)));
#endif
static struct pad_state PadState[2][8];
/*
* Local functions
*/
/** Common helper */
static struct pad_data*
padGetDmaStr(int port, int slot)
{
struct pad_data *pdata;
pdata = PadState[port][slot].padData;
SyncDCache(pdata, (u8 *)pdata + 256);
if(pdata[0].frame < pdata[1].frame) {
return &pdata[1];
}
else {
return &pdata[0];
}
}
#ifdef _XPAD
/**
* Returns the data for pad (opened) status.
* This seems to have been removed from the official SDKs, very early during the PS2's lifetime.
*/
static struct open_slot*
padGetConnDmaStr(void)
{
SyncDCache(openSlot, (u8*)openSlot + sizeof(openSlot));
if(openSlot[0].frame < openSlot[1].frame)
return &openSlot[1];
else
return &openSlot[0];
}
#endif
/*
* Global functions
*/
/*
* Functions not implemented here
* padGetFrameCount() <- dunno if it's useful for someone..
* padInfoComb() <- see above
* padSetVrefParam() <- dunno
*/
int
padInit(int mode)
{
// Version check isn't used by default
// int ver;
static int _rb_count = 0;
int bind_retry = 100;
if (_rb_count != _iop_reboot_count)
{
_rb_count = _iop_reboot_count;
padInitialised = 0;
}
if(padInitialised)
return 0;
padInitialised = 1;
padsif[0].server = NULL;
padsif[1].server = NULL;
do {
if (SifBindRpc(&padsif[0], PAD_BIND_RPC_ID1, 0) < 0) {
return -1;
}
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
} while(!padsif[0].server);
bind_retry = 100;
do {
if (SifBindRpc(&padsif[1], PAD_BIND_RPC_ID2, 0) < 0) {
return -3;
}
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
} while(!padsif[1].server);
// If you require a special version of the padman, check for that here (uncomment)
// ver = padGetModVersion();
//At v1.3.4, this used to return 1 (and padPortInit is not used). But we are interested in the better design from release 1.4.
return padPortInit(mode);
}
int padPortInit(int mode)
{
#ifdef _XPAD //Unofficial: libpad EE client from v1.3.4 has this RPC function implemented, but is not implemented within its PADMAN module.
int ret;
#endif
int i;
(void)mode;
for(i = 0; i<8; i++)
{
PadState[0][i].open = 0;
PadState[0][i].port = 0;
PadState[0][i].slot = 0;
PadState[1][i].open = 0;
PadState[1][i].port = 0;
PadState[1][i].slot = 0;
}
#ifdef _XPAD //Unofficial: libpad EE client from v1.3.4 has this RPC function implemented, but is not implemented within its PADMAN module.
#ifdef _XPAD
buffer.padInitArgs.command = PAD_RPCCMD_INIT;
buffer.padInitArgs.statBuf = openSlot;
#else
buffer.command = PAD_RPCCMD_INIT;
#endif
ret = SifCallRpc( &padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL);
return(ret >= 0 ? buffer.padResult.result : 0);
#else
return 1;
#endif
}
int
padEnd(void)
{
int ret;
buffer.command=PAD_RPCCMD_END;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return -1;
ret = buffer.padResult.result;
if (ret == 1) {
padInitialised = 0;
}
return ret;
}
int
padPortOpen(int port, int slot, void *padArea)
{
int i;
struct pad_data *dma_buf = (struct pad_data *)padArea;
#ifndef _XPAD
// Check 16 byte alignment
if((u32)padArea & 0xf) {
printf("Address is not 16-byte aligned.\n");
return 0;
}
#else
// Check 64 byte alignment
if((u32)padArea & 0x3f) {
printf("Address is not 16-byte aligned.\n");
return 0;
}
#endif
for (i=0; i<2; i++) { // Pad data is double buffered
memset(dma_buf[i].data, 0xff, 32); // 'Clear' data area
dma_buf[i].frame = 0;
dma_buf[i].length = 0;
dma_buf[i].state = PAD_STATE_EXECCMD;
dma_buf[i].reqState = PAD_RSTAT_BUSY;
#ifndef _XPAD
dma_buf[i].ok = 0;
#endif
#ifdef _XPAD
dma_buf[i].currentTask = 0;
#endif
dma_buf[i].length = 0;
#ifdef _XPAD
dma_buf[i].buttonDataReady = 0; // Should be cleared in newer padman
#endif
}
buffer.padOpenArgs.command = PAD_RPCCMD_OPEN;
buffer.padOpenArgs.port = port;
buffer.padOpenArgs.slot = slot;
buffer.padOpenArgs.padArea = padArea;
if(SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
{
return 0;
}
PadState[port][slot].open = 1;
PadState[port][slot].padData = padArea;
PadState[port][slot].padBuf = buffer.padOpenResult.padBuf;
return buffer.padOpenResult.result;
}
int
padPortClose(int port, int slot)
{
int ret;
buffer.padCloseArgs.command = PAD_RPCCMD_CLOSE;
buffer.padCloseArgs.port = port;
buffer.padCloseArgs.slot = slot;
buffer.padCloseArgs.mode = 1;
ret = SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL);
if(ret < 0)
return ret;
else {
PadState[port][slot].open = 0;
return buffer.padResult.result;
}
}
unsigned char
padRead(int port, int slot, struct padButtonStatus *data)
{
struct pad_data *pdata;
pdata = padGetDmaStr(port, slot);
memcpy(data, pdata->data, pdata->length);
return pdata->length;
}
int
padGetState(int port, int slot)
{
struct pad_data *pdata;
unsigned char state;
pdata = padGetDmaStr(port, slot);
state = pdata->state;
#ifdef _XPAD
if (state == PAD_STATE_ERROR)
{
if (pdata->findPadRetries)
{
return PAD_STATE_FINDPAD;
}
}
#endif
if (state == PAD_STATE_STABLE) { // Ok
if (padGetReqState(port, slot) == PAD_RSTAT_BUSY) {
return PAD_STATE_EXECCMD;
}
}
return state;
}
unsigned char
padGetReqState(int port, int slot)
{
struct pad_data *pdata;
pdata = padGetDmaStr(port, slot);
return pdata->reqState;
}
int
padSetReqState(int port, int slot, int state)
{
struct pad_data *pdata;
pdata = padGetDmaStr(port, slot);
pdata->reqState = state;
return 1;
}
void
padStateInt2String(int state, char buf[16])
{
if(state < 8) {
strcpy(buf, padStateString[state]);
}
}
void
padReqStateInt2String(int state, char buf[16])
{
if(state < 3)
strcpy(buf, padReqStateString[state]);
}
int
padGetPortMax(void)
{
buffer.command = PAD_RPCCMD_GET_PORTMAX;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return -1;
return buffer.padResult.result;
}
int
padGetSlotMax(int port)
{
buffer.padSlotMaxArgs.command = PAD_RPCCMD_GET_SLOTMAX;
buffer.padSlotMaxArgs.port = port;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return -1;
return buffer.padResult.result;
}
int
padGetModVersion()
{
#ifdef _XPAD
buffer.command = PAD_RPCCMD_GET_MODVER;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return -1;
return buffer.padResult.result;
#else
return 1; // Well.. return a low version #
#endif
}
int
padInfoMode(int port, int slot, int infoMode, int index)
{
#ifdef _XPAD
struct pad_data *pdata;
pdata = padGetDmaStr(port, slot);
if (pdata->currentTask != 1)
return 0;
if (pdata->reqState == PAD_RSTAT_BUSY)
return 0;
switch(infoMode) {
case PAD_MODECURID:
if (pdata->modeCurId == 0xF3)
return 0;
else
return (pdata->modeCurId >> 4);
break;
case PAD_MODECUREXID:
if (pdata->modeConfig == pdata->currentTask)
return 0;
return pdata->modeTable[pdata->modeCurOffs];
break;
case PAD_MODECUROFFS:
if (pdata->modeConfig != 0)
return pdata->modeCurOffs;
else
return 0;
break;
case PAD_MODETABLE:
if (pdata->modeConfig != 0) {
if(index == -1) {
return pdata->nrOfModes;
}
else if (index < pdata->nrOfModes) {
return pdata->modeTable[index];
}
else {
return 0;
}
}
else
return 0;
break;
}
return 0;
#else
buffer.padInfoModeArgs.command = PAD_RPCCMD_INFO_MODE;
buffer.padInfoModeArgs.port = port;
buffer.padInfoModeArgs.slot = slot;
buffer.padInfoModeArgs.infoMode = infoMode;
buffer.padInfoModeArgs.index = index;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
if (buffer.padModeResult.result == 1) {
padSetReqState(port, slot, PAD_RSTAT_BUSY);
}
return buffer.padModeResult.result;
#endif
}
int
padSetMainMode(int port, int slot, int mode, int lock)
{
buffer.padSetMainModeArgs.command = PAD_RPCCMD_SET_MMODE;
buffer.padSetMainModeArgs.port = port;
buffer.padSetMainModeArgs.slot = slot;
buffer.padSetMainModeArgs.mode = mode;
buffer.padSetMainModeArgs.lock = lock;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
if (buffer.padModeResult.result == 1) {
padSetReqState(port, slot, PAD_RSTAT_BUSY);
}
return buffer.padModeResult.result;
}
int
padInfoPressMode(int port, int slot)
{
int mask;
mask = padGetButtonMask(port, slot);
if (mask^0x3ffff) {
return 0;
}
else {
return 1;
}
}
int
padEnterPressMode(int port, int slot)
{
return padSetButtonInfo(port, slot, 0xFFF);
}
int
padExitPressMode(int port, int slot)
{
return padSetButtonInfo(port, slot, 0);
}
int
padGetButtonMask(int port, int slot)
{
buffer.padGetButtonMaskArgs.command = PAD_RPCCMD_GET_BTNMASK;
buffer.padGetButtonMaskArgs.port = port;
buffer.padGetButtonMaskArgs.slot = slot;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
return buffer.padResult.result;
}
int
padSetButtonInfo(int port, int slot, int buttonInfo)
{
int val;
buffer.padSetButtonInfoArgs.command = PAD_RPCCMD_SET_BTNINFO;
buffer.padSetButtonInfoArgs.port = port;
buffer.padSetButtonInfoArgs.slot = slot;
buffer.padSetButtonInfoArgs.buttonInfo = buttonInfo;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
val = buffer.padSetButtonInfoResult.result;
if (val == 1) {
padSetReqState(port, slot, PAD_RSTAT_BUSY);
}
return buffer.padSetButtonInfoResult.result;
}
unsigned char
padInfoAct(int port, int slot, int actuator, int cmd)
{
#ifdef _XPAD
struct pad_data *pdata;
pdata = padGetDmaStr(port, slot);
if (pdata->currentTask != 1)
return 0;
if (pdata->modeConfig < 2)
return 0;
if (actuator >= pdata->nrOfActuators)
return 0;
if (actuator == -1)
return pdata->nrOfActuators; // # of acutators?
if (cmd >= 4)
return 0;
return pdata->actData[actuator*4+cmd];
#else
buffer.padInfoActArgs.command = PAD_RPCCMD_INFO_ACT;
buffer.padInfoActArgs.port = port;
buffer.padInfoActArgs.slot = slot;
buffer.padInfoActArgs.actuator = actuator;
buffer.padInfoActArgs.act_cmd = cmd;
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
if (buffer.padModeResult.result == 1) {
padSetReqState(port, slot, PAD_RSTAT_BUSY);
}
return buffer.padModeResult.result;
#endif
}
int
padSetActAlign(int port, int slot, const char actAlign[6])
{
int i;
s8 *ptr;
buffer.padActDirAlignArgs.command = PAD_RPCCMD_SET_ACTALIGN;
buffer.padActDirAlignArgs.port = port;
buffer.padActDirAlignArgs.slot = slot;
ptr = buffer.padActDirAlignArgs.align;
for (i=0; i<6; i++)
ptr[i]=actAlign[i];
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
if (buffer.padModeResult.result == 1) {
padSetReqState(port, slot, PAD_RSTAT_BUSY);
}
return buffer.padModeResult.result;
}
int
padSetActDirect(int port, int slot, char actAlign[6])
{
int i;
s8 *ptr;
buffer.padActDirAlignArgs.command = PAD_RPCCMD_SET_ACTDIR;
buffer.padActDirAlignArgs.port = port;
buffer.padActDirAlignArgs.slot = slot;
ptr = buffer.padActDirAlignArgs.align;
for (i=0; i<6; i++)
ptr[i]=actAlign[i];
if (SifCallRpc(&padsif[0], 1, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
return 0;
return buffer.padModeResult.result;
}
/*
* This seems to have been removed from the official SDKs, very early during the PS2's lifetime.
*/
int
padGetConnection(int port, int slot)
{
#ifdef _XPAD
struct open_slot *oslot;
oslot = padGetConnDmaStr();
return ((oslot->openSlots[port] >> slot) & 0x1);
#else
(void)port;
(void)slot;
return 1;
#endif
}