Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/ogc/pad.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#define PAD_MOTOR_RUMBLE 1
#define PAD_MOTOR_STOP_HARD 2

#define PAD_FORCE_ON 3
#define PAD_FORCE_OFF 2

#define PAD_ERR_NONE 0
#define PAD_ERR_NO_CONTROLLER -1
#define PAD_ERR_NOT_READY -2
Expand All @@ -31,6 +34,7 @@
#define PAD_TRIGGER_Z 0x0010
#define PAD_TRIGGER_R 0x0020
#define PAD_TRIGGER_L 0x0040
#define PAD_PEDAL_CONNECT 0x0080
#define PAD_BUTTON_A 0x0100
#define PAD_BUTTON_B 0x0200
#define PAD_BUTTON_X 0x0400
Expand Down
39 changes: 37 additions & 2 deletions libogc/pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static void __pad_typeandstatuscallback(s32 chan,u32 type)

__pad_type[__pad_resettingchan] = (type&~0xff);
if(((type&SI_TYPE_MASK)-SI_TYPE_GC)
|| !(type&SI_GC_STANDARD)) {
|| (type == SI_GC_RECEIVER)) {
__pad_doreset();
return;
}
Expand Down Expand Up @@ -437,6 +437,12 @@ static void __pad_enable(u32 chan)
#endif
__pad_enabledbits |= PAD_CHAN_BIT(chan);
SI_GetResponse(chan,(void*)buf);
if (SI_GetType(chan) != SI_GC_KEYBOARD) {
SI_SetCommand(chan, (__pad_analogmode | 0x00400000));
}
else {
SI_SetCommand(chan, 0x00540000); //Keyboard-specific polling command
}
SI_SetCommand(chan,(__pad_analogmode|0x00400000));
SI_EnablePolling(__pad_enabledbits);
}
Expand Down Expand Up @@ -617,7 +623,9 @@ u32 PAD_Read(PADStatus *status)
#ifdef _PAD_DEBUG
printf("PAD_Read(%08x %08x)\n",buf[0],buf[1]);
#endif
__pad_makestatus(chan,buf,&status[chan]);
if (type != SI_GC_KEYBOARD) {
__pad_makestatus(chan, buf, &status[chan]);
}
#ifdef _PAD_DEBUG
printf("PAD_Read(%08x)\n",status[chan].button);
#endif
Expand Down Expand Up @@ -833,6 +841,33 @@ void PAD_ControlMotor(s32 chan,u32 cmd)
_CPU_ISR_Restore(level);
}

void PAD_ControlForce(s32 chan, u32 cmd, s32 intensity)
{
u32 level;
u32 mask, type;

if (intensity >= 0x80) {
cmd |= 0x100;
}
else if (intensity > -0x80) {
cmd |= intensity + 0x80;
}
cmd &= 0x7FF;

_CPU_ISR_Disable(level);

mask = PAD_CHAN_BIT(chan);
if (__pad_enabledbits & mask) {
type = SI_GetType(chan);
if (type == SI_GC_STEERING) {
cmd |= 0x300000;
SI_SetCommand(chan, cmd);
SI_TransferCommands();
}
}
_CPU_ISR_Restore(level);
}

void PAD_SetSamplingRate(u32 samplingrate)
{
SI_SetSamplingRate(samplingrate);
Expand Down