Skip to content

Commit

Permalink
Add Rumbling support, thanks Steward-fu !
Browse files Browse the repository at this point in the history
  • Loading branch information
gameblabla committed Jun 27, 2019
1 parent 8403ca3 commit a9364d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.c
Expand Up @@ -226,10 +226,18 @@ void init_main()

extern void load_controllers();

#ifdef BITTBOY
int motordev=-1;
#endif

int main(int argc, char *argv[])
{
char bios_filename[512];
int ret;

#ifdef BITTBOY
motordev = open("/dev/miyoo_vir", O_RDWR);
#endif

#ifdef PSP_BUILD
sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0,
Expand Down Expand Up @@ -376,6 +384,14 @@ int main(int argc, char *argv[])
execute_arm_translate(execute_cycles);
execute_arm(execute_cycles);
#endif


#ifdef BITTBOY
if(motordev > 0){
ioctl(motordev, MIYOO_VIR_SET_MODE, 1);
close(motordev);
}
#endif
return 0;
}

Expand Down
17 changes: 17 additions & 0 deletions memory.c
Expand Up @@ -1477,8 +1477,14 @@ u32 encode_bcd(u8 value)
\
address16(map, update_address & 0x7FFF) = _value \


#ifdef BITTBOY
extern int motordev;
#endif

void function_cc write_rtc(u32 address, u32 value)
{
static u32 rumble = 0;
u32 rtc_page_index;
u32 update_address;
u8 *map;
Expand All @@ -1492,6 +1498,17 @@ void function_cc write_rtc(u32 address, u32 value)
// Bit 1: IO, input/output command data
// Bit 2: CS, select input/output? If high make I/O write only
case 0xC4:
if(rtc_registers[1] & 8){
if((value & 8) != rumble){
rumble = value & 8;
#ifdef BITTBOY
if(motordev > 0){
ioctl(motordev, MIYOO_VIR_SET_MODE, rumble > 0 ? 0 : 1);
}
#endif
}
}

if(rtc_state == RTC_DISABLED)
rtc_state = RTC_IDLE;
if(!(rtc_registers[0] & 0x04))
Expand Down

0 comments on commit a9364d1

Please sign in to comment.