mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
GCPad/Wiimote New: Added a set defaults button to the config dialog. (gave new wiimote plugin a few default buttons, not done) Moved MSWindows cursor position code to ControllerInterface/DInput (plan on moving Linux's cursor code to Xlib as well). IR Up,Down,L,R now must have Cursor X/Y/-+ mapped for regular mouse control on Windows. (hopefully this isn't too confusing, the reset to default button automatically sets this up). Renamed One,Two,Minus,Plus to 12-+ (you will have to reconfigure these buttons, sorry). Added text labels for the button and trigger preview bitmaps. -other minor stuff.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5865 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -13,7 +13,7 @@ static const u8 classic_calibration[] =
|
||||
0x00, 0x00, 0x51, 0xa6
|
||||
};
|
||||
|
||||
const u16 classic_button_bitmasks[] =
|
||||
static const u16 classic_button_bitmasks[] =
|
||||
{
|
||||
Classic::BUTTON_A,
|
||||
Classic::BUTTON_B,
|
||||
@ -29,22 +29,22 @@ const u16 classic_button_bitmasks[] =
|
||||
Classic::BUTTON_HOME,
|
||||
};
|
||||
|
||||
const char* classic_button_names[] =
|
||||
static const char* const classic_button_names[] =
|
||||
{
|
||||
"A","B","X","Y","ZL","ZR","Minus","Plus","Home",
|
||||
"A","B","X","Y","ZL","ZR","-","+","Home",
|
||||
};
|
||||
|
||||
const u16 classic_trigger_bitmasks[] =
|
||||
static const u16 classic_trigger_bitmasks[] =
|
||||
{
|
||||
Classic::TRIGGER_L, Classic::TRIGGER_R,
|
||||
};
|
||||
|
||||
const char* const classic_trigger_names[] =
|
||||
static const char* const classic_trigger_names[] =
|
||||
{
|
||||
"L", "R", "L-Analog", "R-Analog"
|
||||
};
|
||||
|
||||
const u16 classic_dpad_bitmasks[] =
|
||||
static const u16 classic_dpad_bitmasks[] =
|
||||
{
|
||||
Classic::PAD_UP, Classic::PAD_DOWN, Classic::PAD_LEFT, Classic::PAD_RIGHT
|
||||
};
|
||||
@ -80,6 +80,7 @@ Classic::Classic() : Attachment( "Classic" )
|
||||
void Classic::GetState( u8* const data, const bool focus )
|
||||
{
|
||||
wm_classic_extension* const ccdata = (wm_classic_extension*)data;
|
||||
ccdata->bt = 0;
|
||||
|
||||
// not using calibration data, o well
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace WiimoteEmu
|
||||
|
||||
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
||||
|
||||
const u16 drum_pad_bitmasks[] =
|
||||
static const u16 drum_pad_bitmasks[] =
|
||||
{
|
||||
Drums::PAD_RED,
|
||||
Drums::PAD_YELLOW,
|
||||
@ -16,12 +16,12 @@ const u16 drum_pad_bitmasks[] =
|
||||
Drums::PAD_BASS,
|
||||
};
|
||||
|
||||
const char* drum_pad_names[] =
|
||||
static const char* const drum_pad_names[] =
|
||||
{
|
||||
"Red","Yellow","Blue","Green","Orange","Bass"
|
||||
};
|
||||
|
||||
const u16 drum_button_bitmasks[] =
|
||||
static const u16 drum_button_bitmasks[] =
|
||||
{
|
||||
Drums::BUTTON_MINUS,
|
||||
Drums::BUTTON_PLUS,
|
||||
@ -39,8 +39,8 @@ Drums::Drums() : Attachment( "Drums" )
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("Minus") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("Plus") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("-") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||
|
||||
// set up register
|
||||
// id
|
||||
@ -50,6 +50,7 @@ Drums::Drums() : Attachment( "Drums" )
|
||||
void Drums::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_drums_extension* const ddata = (wm_drums_extension*)data;
|
||||
ddata->bt = 0;
|
||||
|
||||
// calibration data not figured out yet?
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace WiimoteEmu
|
||||
|
||||
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
||||
|
||||
const u16 guitar_fret_bitmasks[] =
|
||||
static const u16 guitar_fret_bitmasks[] =
|
||||
{
|
||||
Guitar::FRET_GREEN,
|
||||
Guitar::FRET_RED,
|
||||
@ -15,18 +15,18 @@ const u16 guitar_fret_bitmasks[] =
|
||||
Guitar::FRET_ORANGE,
|
||||
};
|
||||
|
||||
const char* guitar_fret_names[] =
|
||||
static const char* const guitar_fret_names[] =
|
||||
{
|
||||
"Green","Red","Yellow","Blue","Orange",
|
||||
};
|
||||
|
||||
const u16 guitar_button_bitmasks[] =
|
||||
static const u16 guitar_button_bitmasks[] =
|
||||
{
|
||||
Guitar::BUTTON_MINUS,
|
||||
Guitar::BUTTON_PLUS,
|
||||
};
|
||||
|
||||
const u16 guitar_strum_bitmasks[] =
|
||||
static const u16 guitar_strum_bitmasks[] =
|
||||
{
|
||||
Guitar::BAR_UP,
|
||||
Guitar::BAR_DOWN,
|
||||
@ -53,8 +53,8 @@ Guitar::Guitar() : Attachment( "Guitar" )
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("Minus") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("Plus") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("-") );
|
||||
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||
|
||||
// set up register
|
||||
// id
|
||||
@ -64,6 +64,7 @@ Guitar::Guitar() : Attachment( "Guitar" )
|
||||
void Guitar::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
|
||||
gdata->bt = 0;
|
||||
|
||||
// calibration data not figured out yet?
|
||||
|
||||
|
@ -21,7 +21,7 @@ static const u8 nunchuck_calibration[] =
|
||||
0xec, 0x41 // checksum on the last two bytes
|
||||
};
|
||||
|
||||
const u8 nunchuk_button_bitmasks[] =
|
||||
static const u8 nunchuk_button_bitmasks[] =
|
||||
{
|
||||
Nunchuk::BUTTON_C,
|
||||
Nunchuk::BUTTON_Z,
|
||||
@ -62,6 +62,7 @@ Nunchuk::Nunchuk() : Attachment( "Nunchuk" )
|
||||
void Nunchuk::GetState( u8* const data, const bool focus )
|
||||
{
|
||||
wm_extension* const ncdata = (wm_extension*)data;
|
||||
ncdata->bt = 0;
|
||||
|
||||
// stick / not using calibration data for stick, o well
|
||||
m_stick->GetState( &ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0 );
|
||||
|
@ -65,7 +65,7 @@ void Wiimote::ReportMode(const u16 _channelID, wm_report_mode* dr)
|
||||
//m_reporting_auto = dr->all_the_time;
|
||||
m_reporting_auto = dr->continuous; // this right?
|
||||
m_reporting_mode = dr->mode;
|
||||
m_reporting_channel = _channelID;
|
||||
//m_reporting_channel = _channelID; // this is set in every Interrupt/Control Channel now
|
||||
|
||||
// reset IR camera
|
||||
//memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack
|
||||
|
@ -51,7 +51,7 @@ static const u8 eeprom_data_16D0[] = {
|
||||
0x77, 0x88, 0x00, 0x00, 0x2B, 0x01, 0xE8, 0x13
|
||||
};
|
||||
|
||||
struct ReportFeatures
|
||||
static struct ReportFeatures
|
||||
{
|
||||
u8 core, accel, ir, ext, size;
|
||||
} const reporting_mode_features[] =
|
||||
@ -193,10 +193,10 @@ const char* const named_buttons[] =
|
||||
{
|
||||
"A",
|
||||
"B",
|
||||
"One",
|
||||
"Two",
|
||||
"Minus",
|
||||
"Plus",
|
||||
"1",
|
||||
"2",
|
||||
"-",
|
||||
"+",
|
||||
"Home",
|
||||
};
|
||||
|
||||
@ -395,6 +395,10 @@ void Wiimote::Update()
|
||||
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
|
||||
}
|
||||
|
||||
// no channel == not connected i guess
|
||||
if (0 == m_reporting_channel)
|
||||
return;
|
||||
|
||||
// check if there is a read data request
|
||||
if (m_read_requests.size())
|
||||
{
|
||||
@ -458,7 +462,7 @@ void Wiimote::Update()
|
||||
if (rpt.accel)
|
||||
{
|
||||
// ----TILT----
|
||||
EmulateTilt((wm_accel*)&data[rpt.accel], m_tilt, (accel_cal*)&m_eeprom[0x16], is_focus, is_sideways, is_upright );
|
||||
EmulateTilt((wm_accel*)&data[rpt.accel], m_tilt, (accel_cal*)&m_eeprom[0x16], /*is_focus*/false, is_sideways, is_upright);
|
||||
|
||||
// ----SWING----
|
||||
//const s8 swing_data[] = { 0x20, 0x40, 0x20, 0x00 };
|
||||
@ -496,36 +500,44 @@ void Wiimote::Update()
|
||||
if (rpt.ir)
|
||||
{
|
||||
float xx = 10000, yy = 0, zz = 0;
|
||||
unsigned int x[4], y[4];
|
||||
|
||||
if (is_focus)
|
||||
{
|
||||
m_ir->GetState(&xx, &yy, &zz, true);
|
||||
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
|
||||
|
||||
float tx, ty;
|
||||
m_tilt->GetState(&tx, &ty, 0, 1, false);
|
||||
|
||||
// TODO: fix tilt math stuff
|
||||
|
||||
const float rtan = tan(0.0f/*tx*/); // disabled cause my math fails
|
||||
const float rsin = sin(rtan);
|
||||
const float rcos = cos(rtan);
|
||||
|
||||
{
|
||||
const float xxx = (xx * -256 * 0.95f);
|
||||
const float yyy = (yy * -256 * 0.90f);
|
||||
|
||||
xx = 512 + xxx * rcos + yyy * rsin;
|
||||
yy = 490 + yyy * rcos + xxx * rsin;
|
||||
}
|
||||
|
||||
const unsigned int distance = (unsigned int)(200 + 100 * zz);
|
||||
|
||||
x[0] = (unsigned int)(xx - distance * rcos);
|
||||
x[1] = (unsigned int)(xx + distance * rcos);
|
||||
x[2] = (unsigned int)(xx - 1.2f * distance * rcos);
|
||||
x[3] = (unsigned int)(xx + 1.2f * distance * rcos);
|
||||
|
||||
y[0] = (unsigned int)(yy - 0.75 * distance * rsin);
|
||||
y[1] = (unsigned int)(yy + 0.75 * distance * rsin);
|
||||
y[2] = (unsigned int)(yy - 0.75 * 1.2f * distance * rsin);
|
||||
y[3] = (unsigned int)(yy + 0.75 * 1.2f * distance * rsin);
|
||||
|
||||
}
|
||||
|
||||
xx *= (-256 * 0.95f);
|
||||
xx += 512;
|
||||
|
||||
yy *= (-256 * 0.90f);
|
||||
yy += 490;
|
||||
|
||||
const unsigned int distance = (unsigned int)(200 + 100 * zz);
|
||||
|
||||
// TODO: make roll affect the dot positions
|
||||
const unsigned int y = (unsigned int)yy;
|
||||
|
||||
unsigned int x[4];
|
||||
x[0] = (unsigned int)(xx - distance);
|
||||
x[1] = (unsigned int)(xx + distance);
|
||||
x[2] = (unsigned int)(xx - 1.2f * distance);
|
||||
x[3] = (unsigned int)(xx + 1.2f * distance);
|
||||
|
||||
// 0xFF report / these memsets are silly
|
||||
if (rpt.ext)
|
||||
memset(data + rpt.ir, 0xFF, (rpt.ext - rpt.ir));
|
||||
else
|
||||
memset(data + rpt.ir, 0xFF, (46 - rpt.ir));
|
||||
|
||||
// Fill report with valid data when full handshake was done
|
||||
if (m_reg_ir->data[0x30] || m_reg_ir->data[0x33])
|
||||
// ir mode
|
||||
@ -534,27 +546,25 @@ void Wiimote::Update()
|
||||
// basic
|
||||
case 1 :
|
||||
{
|
||||
memset(data + rpt.ir, 0xFF, 10);
|
||||
wm_ir_basic* const irdata = (wm_ir_basic*)(data + rpt.ir);
|
||||
if (y < 768)
|
||||
for (unsigned int i=0; i<2; ++i)
|
||||
{
|
||||
for ( unsigned int i=0; i<2; ++i )
|
||||
if (x[i*2] < 1024 && y[i*2] < 768)
|
||||
{
|
||||
if (x[i*2] < 1024)
|
||||
{
|
||||
irdata[i].x1 = u8(x[i*2]);
|
||||
irdata[i].x1hi = x[i*2] >> 8;
|
||||
irdata[i].x1 = u8(x[i*2]);
|
||||
irdata[i].x1hi = x[i*2] >> 8;
|
||||
|
||||
irdata[i].y1 = u8(y);
|
||||
irdata[i].y1hi = y >> 8;
|
||||
}
|
||||
if (x[i*2+1] < 1024)
|
||||
{
|
||||
irdata[i].x2 = u8(x[i*2+1]);
|
||||
irdata[i].x2hi = x[i*2+1] >> 8;
|
||||
irdata[i].y1 = u8(y[i*2]);
|
||||
irdata[i].y1hi = y[i*2] >> 8;
|
||||
}
|
||||
if (x[i*2+1] < 1024 && y[i*2+1] < 768)
|
||||
{
|
||||
irdata[i].x2 = u8(x[i*2+1]);
|
||||
irdata[i].x2hi = x[i*2+1] >> 8;
|
||||
|
||||
irdata[i].y2 = u8(y);
|
||||
irdata[i].y2hi = y >> 8;
|
||||
}
|
||||
irdata[i].y2 = u8(y[i*2+1]);
|
||||
irdata[i].y2hi = y[i*2+1] >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -562,21 +572,19 @@ void Wiimote::Update()
|
||||
// extended
|
||||
case 3 :
|
||||
{
|
||||
memset(data + rpt.ir, 0xFF, 12);
|
||||
wm_ir_extended* const irdata = (wm_ir_extended*)(data + rpt.ir);
|
||||
if (y < 768)
|
||||
{
|
||||
for ( unsigned int i=0; i<4; ++i )
|
||||
if (x[i] < 1024)
|
||||
{
|
||||
irdata[i].x = u8(x[i]);
|
||||
irdata[i].xhi = x[i] >> 8;
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
if (x[i] < 1024 && y[i] < 768)
|
||||
{
|
||||
irdata[i].x = u8(x[i]);
|
||||
irdata[i].xhi = x[i] >> 8;
|
||||
|
||||
irdata[i].y = u8(y);
|
||||
irdata[i].yhi = y >> 8;
|
||||
irdata[i].y = u8(y[i]);
|
||||
irdata[i].yhi = y[i] >> 8;
|
||||
|
||||
irdata[i].size = 10;
|
||||
}
|
||||
}
|
||||
irdata[i].size = 10;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// full
|
||||
@ -628,7 +636,6 @@ void Wiimote::Update()
|
||||
|
||||
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
|
||||
// Check for custom communication
|
||||
if (99 == _channelID)
|
||||
{
|
||||
@ -640,6 +647,9 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
|
||||
return;
|
||||
}
|
||||
|
||||
// this all good?
|
||||
m_reporting_channel = _channelID;
|
||||
|
||||
hid_packet* hidp = (hid_packet*)_pData;
|
||||
|
||||
INFO_LOG(WIIMOTE, "Emu ControlChannel (page: %i, type: 0x%02x, param: 0x%02x)", m_index, hidp->type, hidp->param);
|
||||
@ -681,6 +691,9 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
|
||||
|
||||
void Wiimote::InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
// this all good?
|
||||
m_reporting_channel = _channelID;
|
||||
|
||||
hid_packet* hidp = (hid_packet*)_pData;
|
||||
|
||||
switch (hidp->type)
|
||||
@ -707,6 +720,57 @@ void Wiimote::InterruptChannel(const u16 _channelID, const void* _pData, u32 _Si
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
|
||||
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
|
||||
// TODO: finish this
|
||||
|
||||
// Buttons
|
||||
// these alright for OSX/Linux?
|
||||
|
||||
set_control(m_buttons, 0, "Button 0"); // A
|
||||
set_control(m_buttons, 1, "Button 1"); // B
|
||||
//set_control(m_buttons, 2, ""); // 1
|
||||
//set_control(m_buttons, 3, ""); // 2
|
||||
//set_control(m_buttons, 4, ""); // -
|
||||
//set_control(m_buttons, 5, ""); // +
|
||||
//set_control(m_buttons, 6, ""); // Start
|
||||
|
||||
// Shake
|
||||
for (unsigned int i=0; i<3; ++i)
|
||||
set_control(m_shake, i, "Button 2");
|
||||
|
||||
// IR
|
||||
#ifdef _WIN32
|
||||
set_control(m_ir, 0, "Cursor Y-");
|
||||
set_control(m_ir, 1, "Cursor Y+");
|
||||
set_control(m_ir, 2, "Cursor X-");
|
||||
set_control(m_ir, 3, "Cursor X+");
|
||||
#endif
|
||||
|
||||
// DPad
|
||||
#ifdef _WIN32
|
||||
set_control(m_dpad, 0, "UP"); // Up
|
||||
set_control(m_dpad, 1, "DOWN"); // Down
|
||||
set_control(m_dpad, 2, "LEFT"); // Left
|
||||
set_control(m_dpad, 3, "RIGHT"); // Right
|
||||
#elif __APPLE__
|
||||
set_control(m_dpad, 0, "Up Arrow"); // Up
|
||||
set_control(m_dpad, 1, "Down Arrow"); // Down
|
||||
set_control(m_dpad, 2, "Left Arrow"); // Left
|
||||
set_control(m_dpad, 3, "Right Arrow"); // Right
|
||||
#else
|
||||
set_control(m_dpad, 0, "Up"); // Up
|
||||
set_control(m_dpad, 1, "Down"); // Down
|
||||
set_control(m_dpad, 2, "Left"); // Left
|
||||
set_control(m_dpad, 3, "Right"); // Right
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// TODO: i need to test this
|
||||
void Wiimote::Register::Read( size_t address, void* dst, size_t length )
|
||||
{
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
|
||||
void DoState(PointerWrap& p);
|
||||
|
||||
void LoadDefaults(const ControllerInterface& ciface);
|
||||
|
||||
private:
|
||||
struct ReadRequest
|
||||
{
|
||||
|
@ -120,19 +120,12 @@ void InitPlugin( void* const hwnd )
|
||||
for ( unsigned int i = 0; i<4; ++i )
|
||||
g_plugin.controllers.push_back( new WiimoteEmu::Wiimote(i) );
|
||||
|
||||
// load the saved controller config
|
||||
g_plugin.LoadConfig();
|
||||
|
||||
// needed for Xlib and exclusive dinput
|
||||
g_plugin.controller_interface.SetHwnd(hwnd);
|
||||
g_plugin.controller_interface.Init();
|
||||
|
||||
// update control refs
|
||||
std::vector<ControllerEmu*>::const_iterator
|
||||
i = g_plugin.controllers.begin(),
|
||||
e = g_plugin.controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
(*i)->UpdateReferences( g_plugin.controller_interface );
|
||||
// load the saved controller config
|
||||
g_plugin.LoadConfig();
|
||||
|
||||
// real wiimotes
|
||||
WiimoteReal::LoadSettings();
|
||||
|
Reference in New Issue
Block a user