diff options
author | megazig <megazig@megazig.(none)> | 2013-04-09 16:25:29 -0500 |
---|---|---|
committer | megazig <megazig@megazig.(none)> | 2013-04-09 16:25:29 -0500 |
commit | 3c4ca002c23af8e5c51d7a2e9ab37a0eb9fa7479 (patch) | |
tree | 704c317113a9086d9aebbdf75d140b3789dc64b0 | |
parent | fd0b828d9a4d341830190e56c5153eea6c10f55b (diff) | |
download | kamek-3c4ca002c23af8e5c51d7a2e9ab37a0eb9fa7479.tar.gz kamek-3c4ca002c23af8e5c51d7a2e9ab37a0eb9fa7479.zip |
added defines and device type checking to classic controller support. re-added bubble support
Diffstat (limited to '')
-rw-r--r-- | src/classic_controller.S | 102 |
1 files changed, 74 insertions, 28 deletions
diff --git a/src/classic_controller.S b/src/classic_controller.S index 6fe057e..ccc073c 100644 --- a/src/classic_controller.S +++ b/src/classic_controller.S @@ -10,6 +10,34 @@ .set f30,30; .set f31,31 #endif +#define WPAD_BUTTON_2 0x0001 +#define WPAD_BUTTON_1 0x0002 +#define WPAD_BUTTON_B 0x0004 +#define WPAD_BUTTON_A 0x0008 +#define WPAD_BUTTON_MINUS 0x0010 +#define WPAD_BUTTON_HOME 0x0080 +#define WPAD_BUTTON_LEFT 0x0100 +#define WPAD_BUTTON_RIGHT 0x0200 +#define WPAD_BUTTON_DOWN 0x0400 +#define WPAD_BUTTON_UP 0x0800 +#define WPAD_BUTTON_PLUS 0x1000 + +#define WPAD_CLASSIC_BUTTON_UP 0x0001 +#define WPAD_CLASSIC_BUTTON_LEFT 0x0002 +#define WPAD_CLASSIC_BUTTON_ZR 0x0004 +#define WPAD_CLASSIC_BUTTON_X 0x0008 +#define WPAD_CLASSIC_BUTTON_A 0x0010 +#define WPAD_CLASSIC_BUTTON_Y 0x0020 +#define WPAD_CLASSIC_BUTTON_B 0x0040 +#define WPAD_CLASSIC_BUTTON_ZL 0x0080 +#define WPAD_CLASSIC_BUTTON_FULL_R 0x0200 +#define WPAD_CLASSIC_BUTTON_PLUS 0x0400 +#define WPAD_CLASSIC_BUTTON_HOME 0x0800 +#define WPAD_CLASSIC_BUTTON_MINUS 0x1000 +#define WPAD_CLASSIC_BUTTON_FULL_L 0x2000 +#define WPAD_CLASSIC_BUTTON_DOWN 0x4000 +#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000 + .set stackSize,0x30; .set r4Place,0x10; .set r5Place,0x14; @@ -23,6 +51,9 @@ .text .align 4 +;TODO - check that classic controller is attached +;TODO - add tilt to right analog +;TODO - add R/L to be full tilt .global _switch_buttons _switch_buttons: addi r1,r1,0x50 # replaced instruction @@ -38,22 +69,27 @@ _switch_buttons: stfs f10,f10Place(r1) stfs f11,f11Place(r1) - lwz r5,0x60(r26) # wiimote cc data + lbz r5,0x5C(r26) # wiimote extension type + cmpwi r5, 2 # classic controller + beq cleanup + + lwz r5,0x60(r26) # wiimote cc data ; KPADInsideStatus->KPADEXStatus_bl->hold bl map_buttons - lwz r4,0(r26) + lwz r4,0(r26) # wiimote ; KPADInsideStatus->hold or r5,r5,r4 - stw r5,0(r26) - lwz r5,0x64(r26) + stw r5,0(r26) # wiimote ; KPADInsideStatus->hold + lwz r5,0x64(r26) # wiimote cc data ; KPADInsideStatus->KPADEXStatus_bl->trig bl map_buttons - lwz r4,4(r26) + lwz r4,4(r26) # wiimote ; KPADInsideStatus->trig or r5,r5,r4 - stw r5,4(r26) - lwz r5,0x68(r26) + stw r5,4(r26) # wiimote ; KPADInsideStatus->trig + lwz r5,0x68(r26) # wiimote cc data ; KPADInsideStatus->KPADEXStatus_bl->release bl map_buttons - lwz r4,8(r26) + lwz r4,8(r26) # wiimote ; KPADInsideStatus->release or r5,r5,r4 - stw r5,8(r26) + stw r5,8(r26) # wiimote ; KPADInsideStatus->release +cleanup: lwz r4,r4Place(r1) lwz r5,r5Place(r1) lwz r6,r6Place(r1) @@ -66,12 +102,14 @@ _switch_buttons: addi r1,r1,stackSize blr +; r5 == CC data +; r5 returns the wpad data map_buttons: andi. r4,r5,0x10 // WPAD_CLASSIC_BUTTON_A cmpwi r4,0 beq- skip_waggle lis r6,0x7fc0 // float - stw r6,0x10(r26) // set waggle + stw r6,0x10(r26) // set waggle ; KPADInsideStatus->acc->y skip_waggle: li r6,0 andi. r4,r5,0x800 // WPAD_CLASSIC_BUTTON_HOME @@ -90,6 +128,14 @@ skip_run_two: beq- skip_jump ori r6,r6,0x100 // WPAD_BUTTON_2 skip_jump: + andi. r4,r5,0x80 // WPAD_CLASSIC_BUTTON_ZL + beq- skip_bubble1 + ori r6,r6,0x8 // WPAD_BUTTON_A +skip_bubble1: + andi. r4,r5,0x4 // WPAD_CLASSIC_BUTTON_ZR + beq- skip_bubble2 + ori r6,r6,0x8 // WPAD_BUTTON_A +skip_bubble2: andi. r4,r5,1 // WPAD_CLASSIC_BUTTON_UP beq- skip_right ori r6,r6,2 // WPAD_BUTTON_RIGHT @@ -114,27 +160,27 @@ skip_plus: beq- skip_minus ori r6,r6,0x1000 // WPAD_BUTTON_MINUS skip_minus: - lfs f8,0x6c(r26) // left analog x - lfs f9,0x70(r26) // left analog y + lfs f8,0x6c(r26) // left analog x ; KPADInsideStatus->KPADEXStatus_cl->lstick + lfs f9,0x70(r26) // left analog y ; KPADInsideStatus->KPADEXStatus_cl->rstick lis r5,float_one@h lfs f10,float_one@l(r5) lfs f11,float_neg_one@l(r5) -# fcmpu cr0,f8,f10 -# bne skip_right_analog -# ori r6,r6,4 // WPAD_BUTTON_DOWN -#skip_right_analog: -# fcmpu cr0,f9,f10 -# bne skip_right_analog -# ori r6,r6,2 // WPAD_BUTTON_RIGHT -#skip_up_analog: -# fcmpu cr0,f9,f11 -# bne skip_right_analog -# ori r6,r6,1 // WPAD_BUTTON_LEFT -#skip_down_analog: -# fcmpu cr0,f8,f11 -# bne skip_right_analog -# ori r6,r6,8 // WPAD_BUTTON_UP -#skip_left_analog: +; fcmpu cr0,f8,f10 +; bne skip_right_analog +; ori r6,r6,4 // WPAD_BUTTON_DOWN +;skip_right_analog: +; fcmpu cr0,f9,f10 +; bne skip_right_analog +; ori r6,r6,2 // WPAD_BUTTON_RIGHT +;skip_up_analog: +; fcmpu cr0,f9,f11 +; bne skip_right_analog +; ori r6,r6,1 // WPAD_BUTTON_LEFT +;skip_down_analog: +; fcmpu cr0,f8,f11 +; bne skip_right_analog +; ori r6,r6,8 // WPAD_BUTTON_UP +;skip_left_analog: mr r5,r6 blr |