mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 08:25:12 +01:00
replace keyboard/mouse code w/ code from libogc
This commit is contained in:
parent
4dd183302e
commit
a155c8105e
@ -41,7 +41,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -ldb -ldi -lpngu -lpng -lmxml -lmetaphrasis \
|
||||
LIBS := -ldb -ldi -lpngu -lpng -lmxml -lmetaphrasis -lwiikeyboard \
|
||||
-lfat -lwiiuse -lz -lbte -logc -lasnd -ltremor -lfreetype -ltinysmb
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "button_mapping.h"
|
||||
#include "wiiusbsupport.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Controller Button Descriptions:
|
||||
@ -113,144 +114,77 @@ CtrlrMap ctrlr_def[5] = {
|
||||
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
|
||||
}
|
||||
},
|
||||
// Keyboard btn def, see http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
||||
// Keyboard btn def
|
||||
{
|
||||
CTRLR_KEYBOARD,
|
||||
150,
|
||||
66,
|
||||
{
|
||||
{4, "A"},
|
||||
{5, "B"},
|
||||
{6, "C"},
|
||||
{7, "D"},
|
||||
{8, "E"},
|
||||
{9, "F"},
|
||||
{10, "G"},
|
||||
{11, "H"},
|
||||
{12, "I"},
|
||||
{13, "J"},
|
||||
{14, "K"},
|
||||
{15, "L"},
|
||||
{16, "M"},
|
||||
{17, "N"},
|
||||
{18, "O"},
|
||||
{19, "P"},
|
||||
{20, "Q"},
|
||||
{21, "R"},
|
||||
{22, "S"},
|
||||
{23, "T"},
|
||||
{24, "U"},
|
||||
{25, "V"},
|
||||
{26, "W"},
|
||||
{27, "X"},
|
||||
{28, "Y"},
|
||||
{29, "Z"},
|
||||
{30, "1"},
|
||||
{31, "2"},
|
||||
{32, "3"},
|
||||
{33, "4"},
|
||||
{34, "5"},
|
||||
{35, "6"},
|
||||
{36, "7"},
|
||||
{37, "8"},
|
||||
{38, "9"},
|
||||
{39, "0"},
|
||||
{40, "ENTER"},
|
||||
{41, "ESC"},
|
||||
{42, "BKSP"},
|
||||
{43, "TAB"},
|
||||
{44, "SPACE"},
|
||||
{45, "-"},
|
||||
{46, "="},
|
||||
{47, "["},
|
||||
{48, "]"},
|
||||
{49, "\\"},
|
||||
{50, "#"},
|
||||
{51, ";"},
|
||||
{52, "'"},
|
||||
{53, "`"},
|
||||
{54, ","},
|
||||
{55, "."},
|
||||
{56, "/"},
|
||||
{57, "CAPLK"},
|
||||
{58, "F1"},
|
||||
{59, "F2"},
|
||||
{60, "F3"},
|
||||
{61, "F4"},
|
||||
{62, "F5"},
|
||||
{63, "F6"},
|
||||
{64, "F7"},
|
||||
{65, "F8"},
|
||||
{66, "F9"},
|
||||
{67, "F10"},
|
||||
{68, "F11"},
|
||||
{69, "F12"},
|
||||
{70, "PRTSC"},
|
||||
{71, "SCRLK"},
|
||||
{72, "PAUSE"},
|
||||
{73, "INS"},
|
||||
{74, "HOME"},
|
||||
{75, "PGUP"},
|
||||
{76, "DEL"},
|
||||
{77, "END"},
|
||||
{78, "PGDN"},
|
||||
{79, "RIGHT"},
|
||||
{80, "LEFT"},
|
||||
{81, "DOWN"},
|
||||
{82, "UP"},
|
||||
{83, "NUMLK"},
|
||||
{84, "NP/"},
|
||||
{85, "NP*"},
|
||||
{86, "NP-"},
|
||||
{87, "NP+"},
|
||||
{88, "NPENT"},
|
||||
{89, "NP1"},
|
||||
{90, "NP2"},
|
||||
{91, "NP3"},
|
||||
{92, "NP4"},
|
||||
{93, "NP5"},
|
||||
{94, "NP6"},
|
||||
{95, "NP7"},
|
||||
{96, "NP8"},
|
||||
{97, "NP9"},
|
||||
{98, "NP0"},
|
||||
{99, "NP."},
|
||||
{100, "\\|"},
|
||||
{101, "APP"},
|
||||
{102, "POWER"},
|
||||
{103, "NP="},
|
||||
{104, "F13"},
|
||||
{105, "F14"},
|
||||
{106, "F15"},
|
||||
{107, "F16"},
|
||||
{108, "F17"},
|
||||
{109, "F18"},
|
||||
{110, "F19"},
|
||||
{111, "F20"},
|
||||
{112, "F21"},
|
||||
{113, "F22"},
|
||||
{114, "F23"},
|
||||
{115, "F24"},
|
||||
|
||||
{127, "MUTE"},
|
||||
{128, "VOL+"},
|
||||
{129, "VOL-"},
|
||||
|
||||
{144, "HANGL"},
|
||||
{145, "HANJA"},
|
||||
{146, "KATA"},
|
||||
{147, "HIRA"},
|
||||
|
||||
{224, "LCTRL"},
|
||||
{225, "LSHFT"},
|
||||
{226, "LALT"},
|
||||
{227, "LWIN"},
|
||||
{228, "RCTRL"},
|
||||
{229, "RSHFT"},
|
||||
{230, "RALT"},
|
||||
{231, "RWIN"},
|
||||
{232, "MOUSEL"},
|
||||
{233, "MOUSER"},
|
||||
{234, "MOUSEM"}
|
||||
{KS_A, "A"},
|
||||
{KS_B, "B"},
|
||||
{KS_C, "C"},
|
||||
{KS_D, "D"},
|
||||
{KS_E, "E"},
|
||||
{KS_F, "F"},
|
||||
{KS_G, "G"},
|
||||
{KS_H, "H"},
|
||||
{KS_I, "I"},
|
||||
{KS_J, "J"},
|
||||
{KS_K, "K"},
|
||||
{KS_L, "L"},
|
||||
{KS_M, "M"},
|
||||
{KS_N, "N"},
|
||||
{KS_O, "O"},
|
||||
{KS_P, "P"},
|
||||
{KS_Q, "Q"},
|
||||
{KS_R, "R"},
|
||||
{KS_S, "S"},
|
||||
{KS_T, "T"},
|
||||
{KS_U, "U"},
|
||||
{KS_V, "V"},
|
||||
{KS_W, "W"},
|
||||
{KS_X, "X"},
|
||||
{KS_Y, "Y"},
|
||||
{KS_Z, "Z"},
|
||||
{KS_1, "1"},
|
||||
{KS_2, "2"},
|
||||
{KS_3, "3"},
|
||||
{KS_4, "4"},
|
||||
{KS_5, "5"},
|
||||
{KS_6, "6"},
|
||||
{KS_7, "7"},
|
||||
{KS_8, "8"},
|
||||
{KS_9, "9"},
|
||||
{KS_0, "0"},
|
||||
{KS_Return, "ENTER"},
|
||||
{KS_Escape, "ESC"},
|
||||
{KS_BackSpace, "BKSP"},
|
||||
{KS_Tab, "TAB"},
|
||||
{KS_space, "SPACE"},
|
||||
{KS_F1, "F1"},
|
||||
{KS_F2, "F2"},
|
||||
{KS_F3, "F3"},
|
||||
{KS_F4, "F4"},
|
||||
{KS_F5, "F5"},
|
||||
{KS_F6, "F6"},
|
||||
{KS_F7, "F7"},
|
||||
{KS_F8, "F8"},
|
||||
{KS_F9, "F9"},
|
||||
{KS_F10, "F10"},
|
||||
{KS_F11, "F11"},
|
||||
{KS_F12, "F12"},
|
||||
{KS_Right, "RIGHT"},
|
||||
{KS_Left, "LEFT"},
|
||||
{KS_Down, "DOWN"},
|
||||
{KS_Up, "UP"},
|
||||
{KS_Control_L, "LCTRL"},
|
||||
{KS_Shift_L, "LSHFT"},
|
||||
{KS_Alt_L, "LALT"},
|
||||
{KS_Control_R, "RCTRL"},
|
||||
{KS_Shift_R, "RSHFT"},
|
||||
{KS_Alt_R, "RALT"},
|
||||
{MOUSEL, "MOUSEL"},
|
||||
{MOUSER, "MOUSER"},
|
||||
{MOUSEM, "MOUSEM"}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -20,8 +20,8 @@ enum {
|
||||
CTRLR_KEYBOARD
|
||||
};
|
||||
|
||||
const char ctrlrName[4][20] =
|
||||
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller" };
|
||||
const char ctrlrName[5][20] =
|
||||
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Keyboard & Mouse" };
|
||||
|
||||
typedef struct _btn_map {
|
||||
u32 btn; // button 'id'
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <ogcsys.h>
|
||||
#include <unistd.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <wiikeyboard/wsksymdef.h>
|
||||
|
||||
#include "vba.h"
|
||||
#include "button_mapping.h"
|
||||
@ -803,13 +804,13 @@ u32 HarryPotter4Input(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DPadArrowKeys(pad)
|
||||
| DecodeGamecube(pad);
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_A]) J |= VBA_BUTTON_L;
|
||||
if (DownUsbKeys[KB_D]) J |= VBA_BUTTON_R;
|
||||
if (DownUsbKeys[KB_ENTER] || DownUsbKeys[KB_X]) J |= VBA_BUTTON_A;
|
||||
if (DownUsbKeys[KB_C]) J |= VBA_BUTTON_B;
|
||||
if (DownUsbKeys[KB_TAB]) J |= VBA_BUTTON_SELECT;
|
||||
if (DownUsbKeys[KB_SPACE]) J |= VBA_BUTTON_START;
|
||||
if (DownUsbKeys[KB_LSHIFT] || DownUsbKeys[KB_RSHIFT]) J |= VBA_SPEED;
|
||||
if (DownUsbKeys[KS_A]) J |= VBA_BUTTON_L;
|
||||
if (DownUsbKeys[KS_D]) J |= VBA_BUTTON_R;
|
||||
if (DownUsbKeys[KS_Return] || DownUsbKeys[KS_X]) J |= VBA_BUTTON_A;
|
||||
if (DownUsbKeys[KS_C]) J |= VBA_BUTTON_B;
|
||||
if (DownUsbKeys[KS_Tab]) J |= VBA_BUTTON_SELECT;
|
||||
if (DownUsbKeys[KS_space]) J |= VBA_BUTTON_START;
|
||||
if (DownUsbKeys[KS_Shift_L] || DownUsbKeys[KS_Shift_R]) J |= VBA_SPEED;
|
||||
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
|
||||
@ -861,13 +862,13 @@ u32 HarryPotter5Input(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DPadWASD(pad);
|
||||
#ifdef HW_RVL
|
||||
// Keyboard controls based on Harry Potter 5 for PC
|
||||
if (DownUsbKeys[KB_LEFT]) J |= VBA_BUTTON_L;
|
||||
if (DownUsbKeys[KB_RIGHT]) J |= VBA_BUTTON_R;
|
||||
if (DownUsbKeys[KB_UP] || DownUsbKeys[KB_DOWN]) J |= VBA_BUTTON_B;
|
||||
if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_A;
|
||||
if (DownUsbKeys[KB_TAB]) J |= VBA_BUTTON_SELECT;
|
||||
if (DownUsbKeys[KB_SPACE]) J |= VBA_BUTTON_START;
|
||||
if (DownUsbKeys[KB_LSHIFT] || DownUsbKeys[KB_RSHIFT]) J |= VBA_SPEED;
|
||||
if (DownUsbKeys[KS_Left]) J |= VBA_BUTTON_L;
|
||||
if (DownUsbKeys[KS_Right]) J |= VBA_BUTTON_R;
|
||||
if (DownUsbKeys[KS_Up] || DownUsbKeys[KS_Down]) J |= VBA_BUTTON_B;
|
||||
if (DownUsbKeys[KS_Return]) J |= VBA_BUTTON_A;
|
||||
if (DownUsbKeys[KS_Tab]) J |= VBA_BUTTON_SELECT;
|
||||
if (DownUsbKeys[KS_space]) J |= VBA_BUTTON_START;
|
||||
if (DownUsbKeys[KS_Shift_L] || DownUsbKeys[KS_Shift_R]) J |= VBA_SPEED;
|
||||
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
|
||||
@ -1291,20 +1292,20 @@ u32 HobbitInput(unsigned short pad) {
|
||||
AttackButton = (fabs(wp->gforce.x)> 1.5);
|
||||
}
|
||||
#endif
|
||||
if (DownUsbKeys[KB_E]) UseButton = true;
|
||||
if (DownUsbKeys[KB_LSHIFT]) {
|
||||
if (DownUsbKeys[KB_MOUSEL] || DownUsbKeys[KB_MOUSER]) AbilityButton = true;
|
||||
if (DownUsbKeys[KS_E]) UseButton = true;
|
||||
if (DownUsbKeys[KS_Shift_L]) {
|
||||
if (DownUsbKeys[MOUSEL] || DownUsbKeys[MOUSER]) AbilityButton = true;
|
||||
} else {
|
||||
if (DownUsbKeys[KB_MOUSEL] || DownUsbKeys[KB_MOUSER]) AttackButton = true;
|
||||
if (DownUsbKeys[MOUSEL] || DownUsbKeys[MOUSER]) AttackButton = true;
|
||||
}
|
||||
if (DownUsbKeys[KB_F5]) AbilityButton = true;
|
||||
if (DownUsbKeys[KB_LCTRL]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_SPACE]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_Q]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_C]) ChangeSkillButton = true;
|
||||
if (DownUsbKeys[KB_ENTER]) ItemsButton = true;
|
||||
if (DownUsbKeys[KB_BKSP]) PauseButton = true;
|
||||
if (DownUsbKeys[KB_F]) SpeedButton = true;
|
||||
if (DownUsbKeys[KS_F5]) AbilityButton = true;
|
||||
if (DownUsbKeys[KS_Control_L]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_space]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_Q]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_C]) ChangeSkillButton = true;
|
||||
if (DownUsbKeys[KS_Return]) ItemsButton = true;
|
||||
if (DownUsbKeys[KS_BackSpace]) PauseButton = true;
|
||||
if (DownUsbKeys[KS_F]) SpeedButton = true;
|
||||
|
||||
if (AbilityButton) J |= VBA_BUTTON_B;
|
||||
if (AttackButton) J |= VBA_BUTTON_L;
|
||||
@ -1339,18 +1340,18 @@ u32 FellowshipOfTheRingInput(unsigned short pad) {
|
||||
SelectButton = wp->btns_h & WPAD_BUTTON_1;
|
||||
}
|
||||
#endif
|
||||
if (DownUsbKeys[KB_E]) UseButton = true;
|
||||
if (DownUsbKeys[KB_Q]) CancelButton = true;
|
||||
if (DownUsbKeys[KB_MOUSEL]) UseButton = true;
|
||||
if (DownUsbKeys[KB_MOUSER]) CancelButton = true;
|
||||
if (DownUsbKeys[KB_C]) ChangeCharButton = true;
|
||||
if (DownUsbKeys[KB_ENTER]) PauseButton = true;
|
||||
if (DownUsbKeys[KB_BKSP]) ItemsButton = true;
|
||||
if (DownUsbKeys[KB_TAB]) SelectButton = true;
|
||||
if (DownUsbKeys[KB_F]) SpeedButton = true;
|
||||
if (DownUsbKeys[KB_SPACE]) SpeedButton = true;
|
||||
if (DownUsbKeys[KB_F5]) UseButton = true;
|
||||
if (DownUsbKeys[KB_LCTRL]) UseButton = true;
|
||||
if (DownUsbKeys[KS_E]) UseButton = true;
|
||||
if (DownUsbKeys[KS_Q]) CancelButton = true;
|
||||
if (DownUsbKeys[MOUSEL]) UseButton = true;
|
||||
if (DownUsbKeys[MOUSER]) CancelButton = true;
|
||||
if (DownUsbKeys[KS_C]) ChangeCharButton = true;
|
||||
if (DownUsbKeys[KS_Return]) PauseButton = true;
|
||||
if (DownUsbKeys[KS_BackSpace]) ItemsButton = true;
|
||||
if (DownUsbKeys[KS_Tab]) SelectButton = true;
|
||||
if (DownUsbKeys[KS_F]) SpeedButton = true;
|
||||
if (DownUsbKeys[KS_space]) SpeedButton = true;
|
||||
if (DownUsbKeys[KS_F5]) UseButton = true;
|
||||
if (DownUsbKeys[KS_Control_L]) UseButton = true;
|
||||
|
||||
if (UseButton) J |= VBA_BUTTON_A;
|
||||
if (CancelButton) J |= VBA_BUTTON_B;
|
||||
@ -1384,20 +1385,20 @@ u32 ReturnOfTheKingInput(unsigned short pad) {
|
||||
AttackButton = (fabs(wp->gforce.x)> 1.5);
|
||||
}
|
||||
#endif
|
||||
if (DownUsbKeys[KB_E]) UseButton = true;
|
||||
if (DownUsbKeys[KB_LSHIFT]) {
|
||||
if (DownUsbKeys[KB_MOUSEL] || DownUsbKeys[KB_MOUSER]) AbilityButton = true;
|
||||
if (DownUsbKeys[KS_E]) UseButton = true;
|
||||
if (DownUsbKeys[KS_Shift_L]) {
|
||||
if (DownUsbKeys[MOUSEL] || DownUsbKeys[MOUSER]) AbilityButton = true;
|
||||
} else {
|
||||
if (DownUsbKeys[KB_MOUSEL] || DownUsbKeys[KB_MOUSER]) AttackButton = true;
|
||||
if (DownUsbKeys[MOUSEL] || DownUsbKeys[MOUSER]) AttackButton = true;
|
||||
}
|
||||
if (DownUsbKeys[KB_F5]) AbilityButton = true;
|
||||
if (DownUsbKeys[KB_LCTRL]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_SPACE]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_Q]) AttackButton = true;
|
||||
if (DownUsbKeys[KB_C]) ChangeSkillButton = true;
|
||||
if (DownUsbKeys[KB_ENTER]) ItemsButton = true;
|
||||
if (DownUsbKeys[KB_BKSP]) PauseButton = true;
|
||||
if (DownUsbKeys[KB_F]) SpeedButton = true;
|
||||
if (DownUsbKeys[KS_F5]) AbilityButton = true;
|
||||
if (DownUsbKeys[KS_Control_L]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_space]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_Q]) AttackButton = true;
|
||||
if (DownUsbKeys[KS_C]) ChangeSkillButton = true;
|
||||
if (DownUsbKeys[KS_Return]) ItemsButton = true;
|
||||
if (DownUsbKeys[KS_BackSpace]) PauseButton = true;
|
||||
if (DownUsbKeys[KS_F]) SpeedButton = true;
|
||||
|
||||
if (AbilityButton) J |= VBA_BUTTON_A;
|
||||
if (AttackButton) J |= VBA_BUTTON_B;
|
||||
|
@ -129,16 +129,16 @@ void ResetControls(int wiiCtrl)
|
||||
if(wiiCtrl == CTRLR_KEYBOARD || wiiCtrl == -1)
|
||||
{
|
||||
i=0;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_X; // VBA stupidly has B on the right instead of left
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_Z;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_BKSP;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_ENTER;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_UP;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_DOWN;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_LEFT;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_RIGHT;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_A;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_S;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_X; // VBA stupidly has B on the right instead of left
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Z;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_BackSpace;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Return;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Up;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Down;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Left;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_Right;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_A;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KS_S;
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,10 +418,10 @@ u32 StandardMovement(unsigned short pad)
|
||||
}
|
||||
|
||||
// Turbo feature, keyboard or gamecube only
|
||||
if(DownUsbKeys[KB_SPACE])
|
||||
if(DownUsbKeys[KS_space])
|
||||
J |= VBA_SPEED;
|
||||
// Capture feature
|
||||
if(DownUsbKeys[KB_PRTSC] | DownUsbKeys[KB_F12])
|
||||
if(DownUsbKeys[KS_Print_Screen] | DownUsbKeys[KS_F12])
|
||||
J |= VBA_CAPTURE;
|
||||
#endif
|
||||
return J;
|
||||
@ -575,29 +575,29 @@ u32 StandardKeyboard(unsigned short pad)
|
||||
{
|
||||
u32 J = 0;
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_UP])
|
||||
if (DownUsbKeys[KS_Up])
|
||||
J |= VBA_UP;
|
||||
if (DownUsbKeys[KB_DOWN])
|
||||
if (DownUsbKeys[KS_Down])
|
||||
J |= VBA_DOWN;
|
||||
if (DownUsbKeys[KB_LEFT])
|
||||
if (DownUsbKeys[KS_Left])
|
||||
J |= VBA_LEFT;
|
||||
if (DownUsbKeys[KB_RIGHT])
|
||||
if (DownUsbKeys[KS_Right])
|
||||
J |= VBA_RIGHT;
|
||||
if (DownUsbKeys[KB_SPACE])
|
||||
if (DownUsbKeys[KS_space])
|
||||
J |= VBA_SPEED;
|
||||
if (DownUsbKeys[KB_F12] || DownUsbKeys[KB_PRTSC])
|
||||
if (DownUsbKeys[KS_F12] || DownUsbKeys[KS_Print_Screen])
|
||||
J |= VBA_CAPTURE;
|
||||
if (DownUsbKeys[KB_X])
|
||||
if (DownUsbKeys[KS_X])
|
||||
J |= VBA_BUTTON_A;
|
||||
if (DownUsbKeys[KB_Z])
|
||||
if (DownUsbKeys[KS_Z])
|
||||
J |= VBA_BUTTON_B;
|
||||
if (DownUsbKeys[KB_A])
|
||||
if (DownUsbKeys[KS_A])
|
||||
J |= VBA_BUTTON_L;
|
||||
if (DownUsbKeys[KB_S])
|
||||
if (DownUsbKeys[KS_S])
|
||||
J |= VBA_BUTTON_R;
|
||||
if (DownUsbKeys[KB_ENTER])
|
||||
if (DownUsbKeys[KS_Return])
|
||||
J |= VBA_BUTTON_START;
|
||||
if (DownUsbKeys[KB_BKSP])
|
||||
if (DownUsbKeys[KS_BackSpace])
|
||||
J |= VBA_BUTTON_SELECT;
|
||||
#endif
|
||||
return J;
|
||||
@ -607,13 +607,13 @@ u32 DPadWASD(unsigned short pad)
|
||||
{
|
||||
u32 J = 0;
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_W])
|
||||
if (DownUsbKeys[KS_W])
|
||||
J |= VBA_UP;
|
||||
if (DownUsbKeys[KB_S])
|
||||
if (DownUsbKeys[KS_S])
|
||||
J |= VBA_DOWN;
|
||||
if (DownUsbKeys[KB_A])
|
||||
if (DownUsbKeys[KS_A])
|
||||
J |= VBA_LEFT;
|
||||
if (DownUsbKeys[KB_D])
|
||||
if (DownUsbKeys[KS_D])
|
||||
J |= VBA_RIGHT;
|
||||
#endif
|
||||
return J;
|
||||
@ -623,13 +623,13 @@ u32 DPadArrowKeys(unsigned short pad)
|
||||
{
|
||||
u32 J = 0;
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_UP])
|
||||
if (DownUsbKeys[KS_Up])
|
||||
J |= VBA_UP;
|
||||
if (DownUsbKeys[KB_DOWN])
|
||||
if (DownUsbKeys[KS_Down])
|
||||
J |= VBA_DOWN;
|
||||
if (DownUsbKeys[KB_LEFT])
|
||||
if (DownUsbKeys[KS_Left])
|
||||
J |= VBA_LEFT;
|
||||
if (DownUsbKeys[KB_RIGHT])
|
||||
if (DownUsbKeys[KS_Right])
|
||||
J |= VBA_RIGHT;
|
||||
#endif
|
||||
return J;
|
||||
@ -993,7 +993,7 @@ bool MenuRequested()
|
||||
(userInput[i].pad.substickX < -70) ||
|
||||
(userInput[i].wpad.btns_h & WPAD_BUTTON_HOME) ||
|
||||
(userInput[i].wpad.btns_h & WPAD_CLASSIC_BUTTON_HOME) ||
|
||||
(DownUsbKeys[KB_ESC])
|
||||
(DownUsbKeys[KS_Escape])
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
@ -40,13 +40,13 @@ u32 LegoStarWars1Input(unsigned short pad) {
|
||||
OldHealth = Health;
|
||||
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start
|
||||
if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars
|
||||
if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump
|
||||
if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack
|
||||
if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_R; // force power, special ability
|
||||
if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_L; // build, use force (supposed to be J too)
|
||||
if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward
|
||||
if (DownUsbKeys[KS_Return]) J |= VBA_BUTTON_START; // start
|
||||
if (DownUsbKeys[KS_K] || DownUsbKeys[KS_Control_L]) J |= VBA_BUTTON_SELECT; // change chars
|
||||
if (DownUsbKeys[KS_U]) J |= VBA_BUTTON_A; // jump
|
||||
if (DownUsbKeys[KS_H]) J |= VBA_BUTTON_B; // attack
|
||||
if (DownUsbKeys[KS_J]) J |= VBA_BUTTON_R; // force power, special ability
|
||||
if (DownUsbKeys[KS_I]) J |= VBA_BUTTON_L; // build, use force (supposed to be J too)
|
||||
if (DownUsbKeys[KS_space]) J |= VBA_SPEED; // fast forward
|
||||
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
|
||||
@ -94,13 +94,13 @@ u32 LegoStarWars2Input(unsigned short pad) {
|
||||
OldHealth = Health;
|
||||
|
||||
#ifdef HW_RVL
|
||||
if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start
|
||||
if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars
|
||||
if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump
|
||||
if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack
|
||||
if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_L; // force power, special ability
|
||||
if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_R; // build, use force (supposed to be J too)
|
||||
if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward
|
||||
if (DownUsbKeys[KS_Return]) J |= VBA_BUTTON_START; // start
|
||||
if (DownUsbKeys[KS_K] || DownUsbKeys[KS_Control_L]) J |= VBA_BUTTON_SELECT; // change chars
|
||||
if (DownUsbKeys[KS_U]) J |= VBA_BUTTON_A; // jump
|
||||
if (DownUsbKeys[KS_H]) J |= VBA_BUTTON_B; // attack
|
||||
if (DownUsbKeys[KS_J]) J |= VBA_BUTTON_L; // force power, special ability
|
||||
if (DownUsbKeys[KS_I]) J |= VBA_BUTTON_R; // build, use force (supposed to be J too)
|
||||
if (DownUsbKeys[KS_space]) J |= VBA_SPEED; // fast forward
|
||||
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
|
||||
@ -193,7 +193,7 @@ u32 SWObiWanInput(unsigned short pad) {
|
||||
u32 SWEpisode2Input(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad);
|
||||
// Rumble when they lose health!
|
||||
u8 Health = CPUReadByte(0x3002fb3);
|
||||
u8 Health = CPUReadByte(0x3002fb3);
|
||||
static u8 OldHealth = 0;
|
||||
if (Health < OldHealth)
|
||||
systemGameRumble(6);
|
||||
@ -241,7 +241,7 @@ u32 SWEpisode2Input(unsigned short pad) {
|
||||
u32 SWEpisode3Input(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad);
|
||||
// Rumble when they lose health!
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
static u8 OldHealth = 0;
|
||||
if (Health < OldHealth)
|
||||
systemGameRumble(6);
|
||||
@ -294,7 +294,7 @@ u32 SWEpisode3Input(unsigned short pad) {
|
||||
u32 SWJediPowerBattlesInput(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad);
|
||||
// Rumble when they lose health!
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
static u8 OldHealth = 0;
|
||||
if (Health < OldHealth)
|
||||
systemGameRumble(6);
|
||||
@ -347,7 +347,7 @@ u32 SWJediPowerBattlesInput(unsigned short pad) {
|
||||
u32 SWTrilogyInput(unsigned short pad) {
|
||||
u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad);
|
||||
// Rumble when they lose health!
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
u8 Health = 0;//CPUReadByte(0x3002fb3);
|
||||
static u8 OldHealth = 0;
|
||||
if (Health < OldHealth)
|
||||
systemGameRumble(6);
|
||||
@ -431,7 +431,7 @@ u32 SWEpisode4Input(unsigned short pad) {
|
||||
}
|
||||
// Force
|
||||
if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) {
|
||||
|
||||
|
||||
}
|
||||
// Start/Select
|
||||
if (wp->btns_h & WPAD_BUTTON_PLUS)
|
||||
@ -484,7 +484,7 @@ u32 SWEpisode5Input(unsigned short pad) {
|
||||
}
|
||||
// Force
|
||||
if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) {
|
||||
|
||||
|
||||
}
|
||||
// Start/Select
|
||||
if (wp->btns_h & WPAD_BUTTON_PLUS)
|
||||
@ -537,7 +537,7 @@ u32 SWEpisode6Input(unsigned short pad) {
|
||||
}
|
||||
// Force
|
||||
if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) {
|
||||
|
||||
|
||||
}
|
||||
// Start/Select
|
||||
if (wp->btns_h & WPAD_BUTTON_PLUS)
|
||||
@ -574,7 +574,7 @@ u32 SWYodaStoriesInput(unsigned short pad) {
|
||||
// Drag object, get out of dialog
|
||||
if (wp->btns_h & WPAD_BUTTON_A)
|
||||
J |= VBA_BUTTON_B;
|
||||
|
||||
|
||||
// Light saber
|
||||
if (fabs(wp->gforce.x)> 1.5 ) {
|
||||
// should change weapon here
|
||||
|
@ -153,7 +153,7 @@ void ZeldaAgesCheat()
|
||||
case 2: case 0xb: case 0x10: case 0x18:
|
||||
j++;
|
||||
break;
|
||||
case 7: case 0x12:
|
||||
case 7: case 0x12:
|
||||
j+=3;
|
||||
}
|
||||
gbWriteMemory(0xC688 + i, j);
|
||||
@ -232,14 +232,14 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
// Rumble when they lose health!
|
||||
u8 Health = gbReadMemory(0xDB5A);
|
||||
static u8 OldHealth = 0;
|
||||
if (Health < OldHealth)
|
||||
if (Health < OldHealth)
|
||||
systemGameRumble(20);
|
||||
OldHealth = Health;
|
||||
|
||||
bool ActionButton=0, SwordButton=0, ShieldButton=0, PullButton=0,
|
||||
ItemsButton=0, QuestButton=0, MapButton=0, SpeedButton=0, CheatButton=0, MidnaButton=0,
|
||||
#ifdef HW_RVL
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0,
|
||||
#ifdef HW_RVL
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0,
|
||||
#endif
|
||||
BItemButton=0, UseLeftItemButton=0, UseRightItemButton=0;
|
||||
|
||||
@ -308,7 +308,7 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
// Must use Wiimote for these buttons
|
||||
CheatButton = wp->btns_d & WPAD_BUTTON_2;
|
||||
}
|
||||
CheatButton = CheatButton || DownUsbKeys[KB_C];
|
||||
CheatButton = CheatButton || DownUsbKeys[KS_C];
|
||||
#endif
|
||||
// Gamecube controls are based on Twilight Princess for the Gamecube
|
||||
{
|
||||
@ -498,7 +498,7 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
if (ItemsButton) {
|
||||
if (QuestScreen) QuestScreen = false;
|
||||
else J |= VBA_BUTTON_START;
|
||||
}
|
||||
}
|
||||
// Quest Status
|
||||
if (QuestButton) {
|
||||
StartCount = 80;
|
||||
@ -530,7 +530,7 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
J |= VBA_SPEED;
|
||||
QuestScreen = false;
|
||||
}
|
||||
|
||||
|
||||
return J;
|
||||
}
|
||||
|
||||
@ -543,7 +543,7 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
// There is Zelda 1 & 2 for Wii VC wiimote but it doesn't make sense to use their controls,
|
||||
// so let user choose sideways wiimote controls.
|
||||
u32 J = StandardMovement(pad) | DecodeKeyboard(pad) | DecodeWiimote(pad);
|
||||
|
||||
|
||||
// Rumble when they lose health!
|
||||
u8 Health;
|
||||
if (Seasons) Health = gbReadMemory(0xC6A2); // health in quarters... note C6A3 is max health
|
||||
@ -556,29 +556,29 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
static int DesiredSubscreen = -1;
|
||||
int Subscreen = 0;
|
||||
switch (gbReadMemory(0xCBCB)) {
|
||||
case 0:
|
||||
case 0:
|
||||
Subscreen = 0;
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
Subscreen = 1+gbReadMemory(0xCBCF);
|
||||
break;
|
||||
case 2:
|
||||
case 2:
|
||||
Subscreen = 4;
|
||||
break;
|
||||
case 3:
|
||||
case 3:
|
||||
Subscreen = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bool ActionButton=0, SwordButton=0, ShieldButton=0, PullButton=0,
|
||||
ItemsButton=0, QuestButton=0, MapButton=0, SpeedButton=0, CheatButton=0, MidnaButton=0,
|
||||
#ifdef HW_RVL
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0, BItemButton=0,
|
||||
#ifdef HW_RVL
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0, BItemButton=0,
|
||||
#endif
|
||||
UseLeftItemButton=0, UseRightItemButton=0;
|
||||
|
||||
bool OnItemScreen = (Subscreen == 1);
|
||||
|
||||
|
||||
#ifdef HW_RVL
|
||||
static int SwordCount = 0;
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
@ -639,7 +639,7 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
// Must use Wiimote for these buttons
|
||||
CheatButton = wp->btns_d & WPAD_BUTTON_2;
|
||||
}
|
||||
CheatButton = CheatButton || DownUsbKeys[KB_C];
|
||||
CheatButton = CheatButton || DownUsbKeys[KS_C];
|
||||
#endif
|
||||
// Gamecube controls are based on Twilight Princess for the Gamecube
|
||||
{
|
||||
@ -814,16 +814,16 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
if (Seasons) ZeldaSeasonsCheat();
|
||||
else ZeldaAgesCheat();
|
||||
}
|
||||
|
||||
|
||||
if (DesiredSubscreen == Subscreen)
|
||||
DesiredSubscreen = -1;
|
||||
static int OldSubscreen = 0;
|
||||
if (Subscreen != OldSubscreen) {
|
||||
if (Subscreen != OldSubscreen) {
|
||||
if (Subscreen==1) DelayCount = 80; // wait for items screen to fade in
|
||||
else DelayCount = 20; // wait to swap subscreens
|
||||
}
|
||||
OldSubscreen = Subscreen;
|
||||
|
||||
|
||||
if (DelayCount > 0) {
|
||||
// do nothing
|
||||
DelayCount--;
|
||||
@ -951,7 +951,7 @@ u32 MinishCapInput(unsigned short pad)
|
||||
|
||||
bool ActionButton=0, SwordButton=0, ShieldButton=0, PullButton=0,
|
||||
ItemsButton=0, QuestButton=0, MapButton=0, SpeedButton=0, CheatButton=0, MidnaButton=0,
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0,
|
||||
LeftItemButton=0, DownItemButton=0, RightItemButton=0,
|
||||
BItemButton=0, UseLeftItemButton=0, UseRightItemButton=0;
|
||||
|
||||
|
||||
@ -1172,7 +1172,7 @@ u32 MinishCapInput(unsigned short pad)
|
||||
}
|
||||
OldCursorRow = CursorRow;
|
||||
OldCursorCol = CursorCol;
|
||||
|
||||
|
||||
static int SwordCount = 0;
|
||||
// Nunchuk controls are based on Twilight Princess for the Wii
|
||||
if (wp->exp.type == WPAD_EXP_NUNCHUK) {
|
||||
@ -1235,7 +1235,7 @@ u32 MinishCapInput(unsigned short pad)
|
||||
// Must use Wiimote for these buttons
|
||||
CheatButton = wp->btns_h & WPAD_BUTTON_2;
|
||||
}
|
||||
CheatButton = CheatButton || DownUsbKeys[KB_C];
|
||||
CheatButton = CheatButton || DownUsbKeys[KS_C];
|
||||
#endif
|
||||
// Gamecube controls are based on Twilight Princess for the Gamecube
|
||||
{
|
||||
@ -1446,7 +1446,7 @@ u32 MinishCapInput(unsigned short pad)
|
||||
// Camera (use as extra way of pressing A without using DPad)
|
||||
if (SpeedButton)
|
||||
J |= VBA_BUTTON_A;
|
||||
// Pull (I was going to check RButtonAction, but the in-game text always tells you to
|
||||
// Pull (I was going to check RButtonAction, but the in-game text always tells you to
|
||||
// use R as the action button, so let's just make Gamecube R = Gameboy R)
|
||||
if (PullButton)
|
||||
J |= VBA_BUTTON_R;
|
||||
|
@ -2250,7 +2250,7 @@ ButtonMappingWindow()
|
||||
}
|
||||
}
|
||||
if(userInput[0].wpad.btns_d == WPAD_BUTTON_HOME)
|
||||
pressed = KB_ESC;
|
||||
pressed = KS_Escape;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2283,7 +2283,7 @@ ButtonMappingWindow()
|
||||
}
|
||||
|
||||
if(mapMenuCtrl == CTRLR_KEYBOARD) {
|
||||
if (pressed == KB_ESC)
|
||||
if (pressed == KS_Escape)
|
||||
pressed = 0;
|
||||
} else if(pressed == WPAD_BUTTON_HOME || pressed == WPAD_CLASSIC_BUTTON_HOME)
|
||||
pressed = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Carl Kenner February 2009
|
||||
* Tantric August 2009
|
||||
*
|
||||
* wiiusbsupport.cpp
|
||||
*
|
||||
@ -17,348 +17,96 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
#include <ogc/usbmouse.h>
|
||||
#include <wiikeyboard/keyboard.h>
|
||||
|
||||
#include "wiiusbsupport.h"
|
||||
|
||||
u16 DownUsbKeys[65536];
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#define USB_CLASS_HID 0x03
|
||||
#define USB_SUBCLASS_BOOT 0x01
|
||||
#define USB_PROTOCOL_KEYBOARD 0x01
|
||||
#define USB_PROTOCOL_MOUSE 0x02
|
||||
static lwp_t eventthread = LWP_THREAD_NULL;
|
||||
|
||||
static int mouse_vid = 0;
|
||||
static int mouse_pid = 0;
|
||||
#define DEVLIST_MAXSIZE 0x08
|
||||
|
||||
#define USB_REQ_GETPROTOCOL 0x03
|
||||
#define USB_REQ_SETPROTOCOL 0x0B
|
||||
#define USB_REQ_GETREPORT 0x01
|
||||
#define USB_REQ_SETREPORT 0x09
|
||||
#define USB_REPTYPE_INPUT 0x01
|
||||
#define USB_REPTYPE_OUTPUT 0x02
|
||||
#define USB_REPTYPE_FEATURE 0x03
|
||||
|
||||
#define USB_REQTYPE_GET 0xA1
|
||||
#define USB_REQTYPE_SET 0x21
|
||||
|
||||
static u8 mouseconfiguration = 0;
|
||||
static u32 mouseinterface = 0;
|
||||
static u32 mousealtInterface = 0;
|
||||
|
||||
u8 DownUsbKeys[256];
|
||||
u8 DownUsbShiftKeys = 0;
|
||||
u16 DownUsbShiftKeys = 0;
|
||||
|
||||
s32 MouseDirectInputX = 0;
|
||||
s32 MouseDirectInputY = 0;
|
||||
|
||||
static bool KeyboardStarted=false, MouseStarted=false;
|
||||
static s32 KeyboardHandle=0, MouseHandle=0;
|
||||
|
||||
typedef struct
|
||||
static void KeyPress(u16 key)
|
||||
{
|
||||
u32 message;
|
||||
u32 id; // direction
|
||||
u8 modifiers;
|
||||
u8 unknown;
|
||||
u8 keys[6];
|
||||
u8 pad[16];
|
||||
}TKeyData;
|
||||
if(key >= 0x61 && key <= 0x7a) // lowercase letter
|
||||
DownUsbKeys[key-32] = 1; // press the uppercase letter too
|
||||
else if(key >= 0x41 && key <= 0x5a) // uppercase letter
|
||||
DownUsbKeys[key+32] = 1; // press the lowercase letter too
|
||||
|
||||
static TKeyData KeyData ATTRIBUTE_ALIGN(32);
|
||||
static signed char *MouseData = NULL;
|
||||
|
||||
static u8 OldKeys[6];
|
||||
static u8 OldShiftKeys;
|
||||
|
||||
static bool StopKeyboard = true;
|
||||
|
||||
void KeyPress(u8 key)
|
||||
{
|
||||
DownUsbKeys[key] = 1;
|
||||
}
|
||||
void KeyRelease(u8 key)
|
||||
|
||||
static void KeyRelease(u16 key)
|
||||
{
|
||||
if(key >= 0x61 && key <= 0x7a) // lowercase letter
|
||||
DownUsbKeys[key-32] = 0; // unpress the uppercase letter too
|
||||
else if(key >= 0x41 && key <= 0x5a) // uppercase letter
|
||||
DownUsbKeys[key+32] = 0; // unpress the lowercase letter too
|
||||
|
||||
DownUsbKeys[key] = 0;
|
||||
}
|
||||
|
||||
static void * eventcallback(void *arg)
|
||||
{
|
||||
s32 stat;
|
||||
s32 mstat;
|
||||
keyboard_event ke;
|
||||
mouse_event me;
|
||||
|
||||
while(1)
|
||||
{
|
||||
stat = KEYBOARD_GetEvent(&ke);
|
||||
mstat = MOUSE_GetEvent(&me);
|
||||
|
||||
if (stat)
|
||||
{
|
||||
if(ke.type == KEYBOARD_PRESSED)
|
||||
KeyPress(ke.symbol);
|
||||
else if(ke.type == KEYBOARD_RELEASED)
|
||||
KeyRelease(ke.symbol);
|
||||
}
|
||||
if (mstat)
|
||||
{
|
||||
MouseDirectInputX += me.rx;
|
||||
MouseDirectInputY += me.ry;
|
||||
DownUsbKeys[MOUSEL] = (me.button & 1);
|
||||
DownUsbKeys[MOUSER] = (me.button & 2);
|
||||
DownUsbKeys[MOUSEM] = (me.button & 4);
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AnyKeyDown()
|
||||
{
|
||||
int i;
|
||||
for (i=4; i<=231;i++)
|
||||
for (int i=0; i<65536; i++)
|
||||
{
|
||||
if (DownUsbKeys[i]) return true;
|
||||
if (DownUsbKeys[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 KeyboardCallback(int ret,void * none)
|
||||
{
|
||||
if (KeyboardHandle<0 || KeyData.message==0x7fffffff)
|
||||
return 0;
|
||||
if(KeyData.message==0)
|
||||
{
|
||||
// keyboard connected!
|
||||
}
|
||||
else if(KeyData.message==1)
|
||||
{
|
||||
// keyboard disconnected!
|
||||
}
|
||||
else if(KeyData.message==2)
|
||||
{
|
||||
// key event
|
||||
DownUsbShiftKeys = KeyData.modifiers;
|
||||
u8 p = DownUsbShiftKeys & (~OldShiftKeys);
|
||||
if (p & 0x01) KeyPress(KB_LCTRL);
|
||||
if (p & 0x02) KeyPress(KB_LSHIFT);
|
||||
if (p & 0x04) KeyPress(KB_LALT);
|
||||
if (p & 0x08) KeyPress(KB_LWIN);
|
||||
if (p & 0x10) KeyPress(KB_RCTRL);
|
||||
if (p & 0x20) KeyPress(KB_RSHIFT);
|
||||
if (p & 0x40) KeyPress(KB_RALT);
|
||||
if (p & 0x80) KeyPress(KB_RWIN);
|
||||
p = OldShiftKeys & (~DownUsbShiftKeys);
|
||||
if (p & 0x01) KeyRelease(KB_LCTRL);
|
||||
if (p & 0x02) KeyRelease(KB_LSHIFT);
|
||||
if (p & 0x04) KeyRelease(KB_LALT);
|
||||
if (p & 0x08) KeyRelease(KB_LWIN);
|
||||
if (p & 0x10) KeyRelease(KB_RCTRL);
|
||||
if (p & 0x20) KeyRelease(KB_RSHIFT);
|
||||
if (p & 0x40) KeyRelease(KB_RALT);
|
||||
if (p & 0x80) KeyRelease(KB_RWIN);
|
||||
// check each key to see if is in the list of old keys, if not it was pressed
|
||||
for (int i=0; i<6; i++)
|
||||
{
|
||||
if (KeyData.keys[i]==1)
|
||||
{
|
||||
break; // too many keys held down at once, so no key data except modifiers
|
||||
}
|
||||
else if (KeyData.keys[i])
|
||||
{
|
||||
bool found = false;
|
||||
for (int old=0; old<6; old++)
|
||||
{
|
||||
if (OldKeys[old]==KeyData.keys[i])
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) KeyPress(KeyData.keys[i]);
|
||||
}
|
||||
}
|
||||
// check each old key to see if is in the list of keys, if not it was released
|
||||
for (int old=0; old<6; old++)
|
||||
{
|
||||
if (OldKeys[old])
|
||||
{
|
||||
bool found = false;
|
||||
for (int i=0; i<6; i++)
|
||||
{
|
||||
if (OldKeys[old]==KeyData.keys[i])
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) KeyRelease(OldKeys[old]);
|
||||
}
|
||||
}
|
||||
// Update old keys, unless too many keys were held down
|
||||
if (KeyData.keys[0]!=1)
|
||||
memcpy(OldKeys, KeyData.keys, 6);
|
||||
OldShiftKeys = DownUsbShiftKeys;
|
||||
}
|
||||
|
||||
// no keyboard message
|
||||
KeyData.message=0x7fffffff;
|
||||
// Request another keyboard message when one is ready
|
||||
if (!StopKeyboard)
|
||||
IOS_IoctlAsync(KeyboardHandle,1,(void *) &KeyData, 16,(void *) &KeyData, 16, KeyboardCallback, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StartWiiKeyboardMouse()
|
||||
{
|
||||
memset(DownUsbKeys, 0, sizeof(DownUsbKeys));
|
||||
|
||||
if (!KeyboardStarted)
|
||||
{
|
||||
USB_Initialize();
|
||||
StartWiiMouse();
|
||||
KeyboardHandle=IOS_Open("/dev/usb/kbd", 1);
|
||||
if (KeyboardHandle<0)
|
||||
{
|
||||
// Error!
|
||||
}
|
||||
//sleep(2);
|
||||
KeyData.message=0x7fffffff;
|
||||
StopKeyboard = false;
|
||||
if(KeyboardHandle>=0)
|
||||
IOS_IoctlAsync(KeyboardHandle,1,(void *) &KeyData, 16,(void *) &KeyData, 16, KeyboardCallback, NULL);
|
||||
KeyboardStarted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(KeyboardHandle>=0)
|
||||
IOS_IoctlAsync(KeyboardHandle,1,(void *) &KeyData, 16,(void *) &KeyData, 16, KeyboardCallback, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void StopWiiKeyboard()
|
||||
{
|
||||
StopKeyboard = true;
|
||||
IOS_Close(KeyboardHandle);
|
||||
}
|
||||
|
||||
s32 MouseCallback(s32 result, void *usrdata)
|
||||
{
|
||||
|
||||
if (result>0)
|
||||
{
|
||||
u8 button = MouseData[0];
|
||||
int deltax = (s8)MouseData[1];
|
||||
int deltay = (s8)MouseData[2];
|
||||
MouseDirectInputX += deltax;
|
||||
MouseDirectInputY += deltay;
|
||||
DownUsbKeys[KB_MOUSEL] = (button & 1);
|
||||
DownUsbKeys[KB_MOUSER] = (button & 2);
|
||||
DownUsbKeys[KB_MOUSEM] = (button & 4);
|
||||
|
||||
USB_ReadIntrMsgAsync(MouseHandle, 0x81, 4, MouseData, MouseCallback, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
MouseStarted=0;
|
||||
MouseHandle=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wii_find_mouse()
|
||||
{
|
||||
s32 fd=0;
|
||||
static u8 *buffer = 0;
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
buffer = (u8*)memalign(32, DEVLIST_MAXSIZE << 3);
|
||||
}
|
||||
if(buffer == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
memset(buffer, 0, DEVLIST_MAXSIZE << 3);
|
||||
|
||||
u8 dummy;
|
||||
u16 vid,pid;
|
||||
|
||||
if (USB_GetDeviceList("/dev/usb/oh0", buffer, DEVLIST_MAXSIZE, 0, &dummy) < 0)
|
||||
{
|
||||
|
||||
free(buffer);
|
||||
buffer =0;
|
||||
return -2;
|
||||
}
|
||||
|
||||
u8 mouseep;
|
||||
u32 mouseep_size;
|
||||
|
||||
int i;
|
||||
|
||||
for(i = 0; i < DEVLIST_MAXSIZE; i++)
|
||||
{
|
||||
memcpy(&vid, (buffer + (i << 3) + 4), 2);
|
||||
memcpy(&pid, (buffer + (i << 3) + 6), 2);
|
||||
|
||||
if ((vid==0)&&(pid==0))
|
||||
continue;
|
||||
fd =0;
|
||||
|
||||
int err = USB_OpenDevice("oh0",vid,pid,&fd);
|
||||
if (err<0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// error!
|
||||
}
|
||||
|
||||
u32 iConf, iInterface;
|
||||
usb_devdesc udd;
|
||||
usb_configurationdesc *ucd;
|
||||
usb_interfacedesc *uid;
|
||||
usb_endpointdesc *ued;
|
||||
|
||||
USB_GetDescriptors(fd, &udd);
|
||||
|
||||
for(iConf = 0; iConf < udd.bNumConfigurations; iConf++)
|
||||
{
|
||||
ucd = &udd.configurations[iConf];
|
||||
for(iInterface = 0; iInterface < ucd->bNumInterfaces; iInterface++)
|
||||
{
|
||||
uid = &ucd->interfaces[iInterface];
|
||||
|
||||
if ( (uid->bInterfaceClass == USB_CLASS_HID) && (uid->bInterfaceSubClass == USB_SUBCLASS_BOOT) &&
|
||||
(uid->bInterfaceProtocol== USB_PROTOCOL_MOUSE))
|
||||
{
|
||||
int iEp;
|
||||
for(iEp = 0; iEp < uid->bNumEndpoints; iEp++)
|
||||
{
|
||||
ued = &uid->endpoints[iEp];
|
||||
mouse_vid = vid;
|
||||
mouse_pid = pid;
|
||||
|
||||
mouseep = ued->bEndpointAddress;
|
||||
mouseep_size = ued->wMaxPacketSize;
|
||||
mouseconfiguration = ucd->bConfigurationValue;
|
||||
mouseinterface = uid->bInterfaceNumber;
|
||||
mousealtInterface = uid->bAlternateSetting;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
USB_FreeDescriptors(&udd);
|
||||
USB_CloseDevice(&fd);
|
||||
|
||||
}
|
||||
if (mouse_pid!=0 || mouse_vid!=0) return 0;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void StartWiiMouse()
|
||||
{
|
||||
if (!MouseStarted)
|
||||
{
|
||||
|
||||
if (wii_find_mouse()!=0) return;
|
||||
|
||||
if (USB_OpenDevice("oh0", mouse_vid, mouse_pid, &MouseHandle)<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!MouseData)
|
||||
{
|
||||
MouseData = (signed char*)memalign(32, 20);
|
||||
}
|
||||
|
||||
//set boot protocol
|
||||
USB_WriteCtrlMsg(MouseHandle,USB_REQTYPE_SET,USB_REQ_SETPROTOCOL,0,0,0,0);
|
||||
USB_ReadIntrMsgAsync(MouseHandle, 0x81, 4, MouseData, MouseCallback, 0);
|
||||
|
||||
MouseStarted=true;
|
||||
}
|
||||
MOUSE_Init();
|
||||
KEYBOARD_Init(NULL);
|
||||
if(eventthread == LWP_THREAD_NULL)
|
||||
LWP_CreateThread(&eventthread, eventcallback, NULL, NULL, 0, 80);
|
||||
}
|
||||
|
||||
#else // GameCube stub
|
||||
|
||||
u8 DownUsbKeys[256];
|
||||
|
||||
bool AnyKeyDown()
|
||||
{
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Carl Kenner Febuary 2009
|
||||
* Tantric August 2009
|
||||
*
|
||||
* wiiusbsupport.h
|
||||
*
|
||||
@ -11,74 +11,16 @@
|
||||
#ifndef _WIIUSBSUPPORT_H_
|
||||
#define _WIIUSBSUPPORT_H_
|
||||
|
||||
#define KB_A 4
|
||||
#define KB_B 5
|
||||
#define KB_C 6
|
||||
#define KB_D 7
|
||||
#define KB_E 8
|
||||
#define KB_F 9
|
||||
#define KB_G 10
|
||||
#define KB_H 11
|
||||
#define KB_I 12
|
||||
#define KB_J 13
|
||||
#define KB_K 14
|
||||
#define KB_L 15
|
||||
#define KB_M 16
|
||||
#define KB_N 17
|
||||
#define KB_O 18
|
||||
#define KB_P 19
|
||||
#define KB_Q 20
|
||||
#define KB_R 21
|
||||
#define KB_S 22
|
||||
#define KB_T 23
|
||||
#define KB_U 24
|
||||
#define KB_V 25
|
||||
#define KB_W 26
|
||||
#define KB_X 27
|
||||
#define KB_Y 28
|
||||
#define KB_Z 29
|
||||
#define KB_ENTER 40
|
||||
#define KB_ESC 41
|
||||
#define KB_BKSP 42
|
||||
#define KB_TAB 43
|
||||
#define KB_SPACE 44
|
||||
#define KB_F1 58
|
||||
#define KB_F2 59
|
||||
#define KB_F3 60
|
||||
#define KB_F4 61
|
||||
#define KB_F5 62
|
||||
#define KB_F6 63
|
||||
#define KB_F7 64
|
||||
#define KB_F8 65
|
||||
#define KB_F9 66
|
||||
#define KB_F10 67
|
||||
#define KB_F11 68
|
||||
#define KB_F12 69
|
||||
#define KB_PRTSC 70
|
||||
#define KB_SCRLK 71
|
||||
#define KB_PAUSE 72
|
||||
#define KB_RIGHT 79
|
||||
#define KB_LEFT 80
|
||||
#define KB_DOWN 81
|
||||
#define KB_UP 82
|
||||
#define KB_LCTRL 224
|
||||
#define KB_LSHIFT 225
|
||||
#define KB_LALT 226
|
||||
#define KB_LWIN 227
|
||||
#define KB_RCTRL 228
|
||||
#define KB_RSHIFT 229
|
||||
#define KB_RALT 230
|
||||
#define KB_RWIN 231
|
||||
#define KB_MOUSEL 232
|
||||
#define KB_MOUSER 233
|
||||
#define KB_MOUSEM 234
|
||||
#include <wiikeyboard/wsksymdef.h>
|
||||
|
||||
#define MOUSEL 65533
|
||||
#define MOUSER 65534
|
||||
#define MOUSEM 65535
|
||||
|
||||
void StartWiiKeyboardMouse();
|
||||
void StopWiiKeyboard();
|
||||
bool AnyKeyDown();
|
||||
void StartWiiMouse();
|
||||
|
||||
extern u8 DownUsbKeys[256];
|
||||
extern u8 DownUsbShiftKeys;
|
||||
extern u16 DownUsbKeys[65536];
|
||||
extern u16 DownUsbShiftKeys;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user