mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 12:35:27 +00: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:
parent
2bcdf4f5a4
commit
a0aa506453
@ -51,35 +51,15 @@ void GCPad_Init( void* const hwnd )
|
|||||||
if ( false == g_plugin.controller_interface.IsInit() )
|
if ( false == g_plugin.controller_interface.IsInit() )
|
||||||
{
|
{
|
||||||
// add 4 gcpads
|
// add 4 gcpads
|
||||||
for ( unsigned int i = 0; i<4; ++i )
|
for (unsigned int i=0; i<4; ++i)
|
||||||
g_plugin.controllers.push_back( new GCPad( i ) );
|
g_plugin.controllers.push_back(new GCPad(i));
|
||||||
|
|
||||||
// needed for Xlib
|
// needed for Xlib
|
||||||
g_plugin.controller_interface.SetHwnd(hwnd);
|
g_plugin.controller_interface.SetHwnd(hwnd);
|
||||||
g_plugin.controller_interface.Init();
|
g_plugin.controller_interface.Init();
|
||||||
|
|
||||||
// load the saved controller config
|
// load the saved controller config
|
||||||
if (false == g_plugin.LoadConfig())
|
g_plugin.LoadConfig();
|
||||||
{
|
|
||||||
// load default config for pad 1
|
|
||||||
g_plugin.controllers[0]->LoadDefaults();
|
|
||||||
|
|
||||||
// kinda silly, set default device(all controls) to first one found in ControllerInterface
|
|
||||||
// should be the keyboard device
|
|
||||||
if (g_plugin.controller_interface.Devices().size())
|
|
||||||
{
|
|
||||||
g_plugin.controllers[0]->default_device.FromDevice(g_plugin.controller_interface.Devices()[0]);
|
|
||||||
g_plugin.controllers[0]->UpdateDefaultDevice();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,18 +124,11 @@ void GCPad::SetOutput( const bool on )
|
|||||||
m_rumble->controls[0]->control_ref->State( on && (Host_RendererHasFocus() || m_options[0].settings[0]->value) );
|
m_rumble->controls[0]->control_ref->State( on && (Host_RendererHasFocus() || m_options[0].settings[0]->value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCPad::LoadDefaults()
|
void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
||||||
{
|
{
|
||||||
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
|
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
|
||||||
|
|
||||||
// nvm, do the device part elsewhere
|
ControllerEmu::LoadDefaults(ciface);
|
||||||
//#ifdef _WIN32
|
|
||||||
// default_device.FromString("DirectInput/0/Keyboard Mouse");
|
|
||||||
//#elif __APPLE__
|
|
||||||
// // keyboard mouse devices are named by their product name thing on OSX currently
|
|
||||||
//#else
|
|
||||||
// default_device.FromString("Xlib/0/Keyboard");
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
set_control(m_buttons, 0, "X"); // A
|
set_control(m_buttons, 0, "X"); // A
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
|
|
||||||
void LoadDefaults();
|
void LoadDefaults(const ControllerInterface& ciface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\ControllerInterface\DirectInput\NamedKeys.h"
|
RelativePath=".\Src\ControllerInterface\DInput\NamedKeys.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -307,27 +307,25 @@ ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerEmu::LoadDefaults(const ControllerInterface &ciface)
|
||||||
|
{
|
||||||
|
// load an empty inifile section, clears everything
|
||||||
|
IniFile::Section sec;
|
||||||
|
LoadConfig(&sec);
|
||||||
|
|
||||||
|
if (ciface.Devices().size())
|
||||||
|
{
|
||||||
|
default_device.FromDevice(ciface.Devices()[0]);
|
||||||
|
UpdateDefaultDevice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove this hackery
|
||||||
void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize)
|
void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize)
|
||||||
{
|
{
|
||||||
#if ( defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11))
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
|
|
||||||
unsigned int win_width = 2, win_height = 2;
|
unsigned int win_width = 2, win_height = 2;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// Get the cursor position for the entire screen
|
|
||||||
POINT point = { 1, 1 };
|
|
||||||
GetCursorPos(&point);
|
|
||||||
// Get the cursor position relative to the upper left corner of the rendering window
|
|
||||||
ScreenToClient(wiimote_initialize->hWnd, &point);
|
|
||||||
|
|
||||||
// Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.)
|
|
||||||
RECT Rect;
|
|
||||||
GetClientRect(wiimote_initialize->hWnd, &Rect);
|
|
||||||
// Width and height is the size of the rendering window
|
|
||||||
win_width = Rect.right - Rect.left;
|
|
||||||
win_height = Rect.bottom - Rect.top;
|
|
||||||
|
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
|
||||||
int root_x, root_y;
|
int root_x, root_y;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -344,15 +342,13 @@ void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_ini
|
|||||||
Window root_dummy, child_win;
|
Window root_dummy, child_win;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
XQueryPointer(wm_display, glwin, &root_dummy, &child_win, &root_x, &root_y, &point.x, &point.y, &mask);
|
XQueryPointer(wm_display, glwin, &root_dummy, &child_win, &root_x, &root_y, &point.x, &point.y, &mask);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ( defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11))
|
|
||||||
// Return the mouse position as a range from -1 to 1
|
// Return the mouse position as a range from -1 to 1
|
||||||
x = (float)point.x / (float)win_width * 2 - 1;
|
x = (float)point.x / (float)win_width * 2 - 1;
|
||||||
y = (float)point.y / (float)win_height * 2 - 1;
|
y = (float)point.y / (float)win_height * 2 - 1;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public:
|
|||||||
Tilt( const char* const _name );
|
Tilt( const char* const _name );
|
||||||
|
|
||||||
template <typename C, typename R>
|
template <typename C, typename R>
|
||||||
void GetState( C* const x, C* const y, const unsigned int base, const R range )
|
void GetState(C* const x, C* const y, const unsigned int base, const R range, const bool step = true)
|
||||||
{
|
{
|
||||||
// this is all a mess
|
// this is all a mess
|
||||||
|
|
||||||
@ -326,15 +326,20 @@ public:
|
|||||||
|
|
||||||
// this is kinda silly here
|
// this is kinda silly here
|
||||||
// gui being open will make this happen 2x as fast, o well
|
// gui being open will make this happen 2x as fast, o well
|
||||||
if (xx > m_tilt[0])
|
|
||||||
m_tilt[0] = std::min(m_tilt[0] + 0.1f, xx);
|
// silly
|
||||||
else if (xx < m_tilt[0])
|
if (step)
|
||||||
m_tilt[0] = std::max(m_tilt[0] - 0.1f, xx);
|
{
|
||||||
|
if (xx > m_tilt[0])
|
||||||
|
m_tilt[0] = std::min(m_tilt[0] + 0.1f, xx);
|
||||||
|
else if (xx < m_tilt[0])
|
||||||
|
m_tilt[0] = std::max(m_tilt[0] - 0.1f, xx);
|
||||||
|
|
||||||
if (yy > m_tilt[1])
|
if (yy > m_tilt[1])
|
||||||
m_tilt[1] = std::min(m_tilt[1] + 0.1f, yy);
|
m_tilt[1] = std::min(m_tilt[1] + 0.1f, yy);
|
||||||
else if (yy < m_tilt[1])
|
else if (yy < m_tilt[1])
|
||||||
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
|
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
|
||||||
|
}
|
||||||
|
|
||||||
*y = C( m_tilt[1] * range + base );
|
*y = C( m_tilt[1] * range + base );
|
||||||
*x = C( m_tilt[0] * range + base );
|
*x = C( m_tilt[0] * range + base );
|
||||||
@ -421,7 +426,7 @@ public:
|
|||||||
|
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
|
|
||||||
virtual void LoadDefaults() {}
|
virtual void LoadDefaults(const ControllerInterface& ciface);
|
||||||
|
|
||||||
virtual void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
virtual void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
virtual void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
virtual void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
|
@ -31,7 +31,7 @@ void ControllerInterface::Init()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CIFACE_USE_DINPUT
|
#ifdef CIFACE_USE_DINPUT
|
||||||
ciface::DInput::Init(m_devices);
|
ciface::DInput::Init(m_devices, (HWND)m_hwnd);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_XINPUT
|
#ifdef CIFACE_USE_XINPUT
|
||||||
ciface::XInput::Init(m_devices);
|
ciface::XInput::Init(m_devices);
|
||||||
|
@ -204,7 +204,7 @@ public:
|
|||||||
Device::Control* Detect(const unsigned int ms, Device* const device);
|
Device::Control* Detect(const unsigned int ms, Device* const device);
|
||||||
};
|
};
|
||||||
|
|
||||||
ControllerInterface() : m_is_init(false) {}
|
ControllerInterface() : m_is_init(false), m_hwnd(NULL) {}
|
||||||
|
|
||||||
void SetHwnd(void* const hwnd);
|
void SetHwnd(void* const hwnd);
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -61,14 +61,14 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
|||||||
return StripSpaces(out);
|
return StripSpaces(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ )
|
void Init(std::vector<ControllerInterface::Device*>& devices, HWND hwnd)
|
||||||
{
|
{
|
||||||
IDirectInput8* idi8;
|
IDirectInput8* idi8;
|
||||||
if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL)))
|
if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CIFACE_USE_DINPUT_KBM
|
#ifdef CIFACE_USE_DINPUT_KBM
|
||||||
InitKeyboardMouse(idi8, devices);
|
InitKeyboardMouse(idi8, devices, hwnd);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_DINPUT_JOYSTICK
|
#ifdef CIFACE_USE_DINPUT_JOYSTICK
|
||||||
InitJoystick(idi8, devices/*, hwnd*/);
|
InitJoystick(idi8, devices/*, hwnd*/);
|
||||||
|
@ -23,7 +23,7 @@ BOOL CALLBACK DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVO
|
|||||||
BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
|
BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
|
||||||
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device);
|
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device);
|
||||||
|
|
||||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ );
|
void Init(std::vector<ControllerInterface::Device*>& devices, HWND hwnd);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace ciface
|
|||||||
namespace DInput
|
namespace DInput
|
||||||
{
|
{
|
||||||
|
|
||||||
struct
|
static struct
|
||||||
{
|
{
|
||||||
const BYTE code;
|
const BYTE code;
|
||||||
const char* const name;
|
const char* const name;
|
||||||
@ -28,7 +28,7 @@ struct
|
|||||||
#include "NamedKeys.h"
|
#include "NamedKeys.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
struct
|
static struct
|
||||||
{
|
{
|
||||||
const BYTE code;
|
const BYTE code;
|
||||||
const char* const name;
|
const char* const name;
|
||||||
@ -39,8 +39,13 @@ struct
|
|||||||
{ VK_SCROLL, "SCROLL LOCK" }
|
{ VK_SCROLL, "SCROLL LOCK" }
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitKeyboardMouse( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices )
|
// lil silly
|
||||||
|
static HWND hwnd;
|
||||||
|
|
||||||
|
void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices, HWND _hwnd)
|
||||||
{
|
{
|
||||||
|
hwnd = _hwnd;
|
||||||
|
|
||||||
// mouse and keyboard are a combined device, to allow shift+click and stuff
|
// mouse and keyboard are a combined device, to allow shift+click and stuff
|
||||||
// if thats dumb, i will make a VirtualDevice class that just uses ranges of inputs/outputs from other devices
|
// if thats dumb, i will make a VirtualDevice class that just uses ranges of inputs/outputs from other devices
|
||||||
// so there can be a separated Keyboard and mouse, as well as combined KeyboardMouse
|
// so there can be a separated Keyboard and mouse, as well as combined KeyboardMouse
|
||||||
@ -81,7 +86,7 @@ KeyboardMouse::~KeyboardMouse()
|
|||||||
m_mo_device->Release();
|
m_mo_device->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardMouse::KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device )
|
KeyboardMouse::KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device)
|
||||||
: m_kb_device(kb_device)
|
: m_kb_device(kb_device)
|
||||||
, m_mo_device(mo_device)
|
, m_mo_device(mo_device)
|
||||||
{
|
{
|
||||||
@ -90,16 +95,16 @@ KeyboardMouse::KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRE
|
|||||||
|
|
||||||
m_last_update = GetTickCount();
|
m_last_update = GetTickCount();
|
||||||
|
|
||||||
ZeroMemory( &m_state_in, sizeof(m_state_in) );
|
ZeroMemory(&m_state_in, sizeof(m_state_in));
|
||||||
ZeroMemory( m_state_out, sizeof(m_state_out) );
|
ZeroMemory(m_state_out, sizeof(m_state_out));
|
||||||
ZeroMemory( &m_current_state_out, sizeof(m_current_state_out) );
|
ZeroMemory(&m_current_state_out, sizeof(m_current_state_out));
|
||||||
|
|
||||||
// KEYBOARD
|
// KEYBOARD
|
||||||
// add keys
|
// add keys
|
||||||
for ( unsigned int i = 0; i < sizeof(named_keys)/sizeof(*named_keys); ++i )
|
for (unsigned int i = 0; i < sizeof(named_keys)/sizeof(*named_keys); ++i)
|
||||||
AddInput(new Key(i));
|
AddInput(new Key(i));
|
||||||
// add lights
|
// add lights
|
||||||
for ( unsigned int i = 0; i < sizeof(named_lights)/sizeof(*named_lights); ++i )
|
for (unsigned int i = 0; i < sizeof(named_lights)/sizeof(*named_lights); ++i)
|
||||||
AddOutput(new Light(i));
|
AddOutput(new Light(i));
|
||||||
|
|
||||||
// MOUSE
|
// MOUSE
|
||||||
@ -109,15 +114,38 @@ KeyboardMouse::KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRE
|
|||||||
mouse_caps.dwSize = sizeof(mouse_caps);
|
mouse_caps.dwSize = sizeof(mouse_caps);
|
||||||
m_mo_device->GetCapabilities(&mouse_caps);
|
m_mo_device->GetCapabilities(&mouse_caps);
|
||||||
// mouse buttons
|
// mouse buttons
|
||||||
for ( unsigned int i = 0; i < mouse_caps.dwButtons; ++i )
|
for (unsigned int i = 0; i < mouse_caps.dwButtons; ++i)
|
||||||
AddInput(new Button(i));
|
AddInput(new Button(i));
|
||||||
// mouse axes
|
// mouse axes
|
||||||
for ( unsigned int i = 0; i < mouse_caps.dwAxes; ++i )
|
for (unsigned int i = 0; i < mouse_caps.dwAxes; ++i)
|
||||||
{
|
{
|
||||||
// each axis gets a negative and a positive input instance associated with it
|
// each axis gets a negative and a positive input instance associated with it
|
||||||
AddInput(new Axis(i, (2==i) ? -1 : -MOUSE_AXIS_SENSITIVITY));
|
AddInput(new Axis(i, (2==i) ? -1 : -MOUSE_AXIS_SENSITIVITY));
|
||||||
AddInput(new Axis(i, -(2==i) ? 1 : MOUSE_AXIS_SENSITIVITY));
|
AddInput(new Axis(i, -(2==i) ? 1 : MOUSE_AXIS_SENSITIVITY));
|
||||||
}
|
}
|
||||||
|
// cursor, with a hax for-loop
|
||||||
|
for (unsigned int i=0; i<4; ++i)
|
||||||
|
AddInput(new Cursor(!!(i&2), !!(i&1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetMousePos(float* const x, float* const y)
|
||||||
|
{
|
||||||
|
unsigned int win_width = 2, win_height = 2;
|
||||||
|
POINT point = { 1, 1 };
|
||||||
|
GetCursorPos(&point);
|
||||||
|
// Get the cursor position relative to the upper left corner of the rendering window
|
||||||
|
ScreenToClient(hwnd, &point);
|
||||||
|
|
||||||
|
// Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.)
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(hwnd, &rect);
|
||||||
|
// Width and height is the size of the rendering window
|
||||||
|
win_width = rect.right - rect.left;
|
||||||
|
win_height = rect.bottom - rect.top;
|
||||||
|
|
||||||
|
// Return the mouse position as a range from -1 to 1
|
||||||
|
*x = (float)point.x / (float)win_width * 2 - 1;
|
||||||
|
*y = (float)point.y / (float)win_height * 2 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardMouse::UpdateInput()
|
bool KeyboardMouse::UpdateInput()
|
||||||
@ -148,11 +176,15 @@ bool KeyboardMouse::UpdateInput()
|
|||||||
if (SUCCEEDED(kb_hr) && SUCCEEDED(mo_hr))
|
if (SUCCEEDED(kb_hr) && SUCCEEDED(mo_hr))
|
||||||
{
|
{
|
||||||
// need to smooth out the axes, otherwise it doesnt work for shit
|
// need to smooth out the axes, otherwise it doesnt work for shit
|
||||||
for ( unsigned int i = 0; i < 3; ++i )
|
for (unsigned int i = 0; i < 3; ++i)
|
||||||
((&m_state_in.mouse.lX)[i] += (&tmp_mouse.lX)[i]) /= 2;
|
((&m_state_in.mouse.lX)[i] += (&tmp_mouse.lX)[i]) /= 2;
|
||||||
|
|
||||||
// copy over the buttons
|
// copy over the buttons
|
||||||
memcpy( m_state_in.mouse.rgbButtons, tmp_mouse.rgbButtons, sizeof(m_state_in.mouse.rgbButtons) );
|
memcpy(m_state_in.mouse.rgbButtons, tmp_mouse.rgbButtons, sizeof(m_state_in.mouse.rgbButtons));
|
||||||
|
|
||||||
|
// update mouse cursor
|
||||||
|
GetMousePos(&m_state_in.cursor.x, &m_state_in.cursor.y);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,17 +206,17 @@ bool KeyboardMouse::UpdateOutput()
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector< KInput > kbinputs;
|
std::vector< KInput > kbinputs;
|
||||||
for ( unsigned int i = 0; i < sizeof(m_state_out)/sizeof(*m_state_out); ++i )
|
for (unsigned int i = 0; i < sizeof(m_state_out)/sizeof(*m_state_out); ++i)
|
||||||
{
|
{
|
||||||
bool want_on = false;
|
bool want_on = false;
|
||||||
if ( m_state_out[i] )
|
if (m_state_out[i])
|
||||||
want_on = m_state_out[i] > GetTickCount() % 255 ; // light should flash when output is 0.5
|
want_on = m_state_out[i] > GetTickCount() % 255 ; // light should flash when output is 0.5
|
||||||
|
|
||||||
// lights are set to their original state when output is zero
|
// lights are set to their original state when output is zero
|
||||||
if ( want_on ^ m_current_state_out[i] )
|
if (want_on ^ m_current_state_out[i])
|
||||||
{
|
{
|
||||||
kbinputs.push_back( KInput( named_lights[i].code ) ); // press
|
kbinputs.push_back(KInput(named_lights[i].code)); // press
|
||||||
kbinputs.push_back( KInput( named_lights[i].code, true ) ); // release
|
kbinputs.push_back(KInput(named_lights[i].code, true)); // release
|
||||||
|
|
||||||
m_current_state_out[i] ^= 1;
|
m_current_state_out[i] ^= 1;
|
||||||
}
|
}
|
||||||
@ -214,12 +246,12 @@ std::string KeyboardMouse::GetSource() const
|
|||||||
|
|
||||||
ControlState KeyboardMouse::GetInputState(const ControllerInterface::Device::Input* const input) const
|
ControlState KeyboardMouse::GetInputState(const ControllerInterface::Device::Input* const input) const
|
||||||
{
|
{
|
||||||
return ( ((Input*)input)->GetState( &m_state_in ) );
|
return (((Input*)input)->GetState(&m_state_in));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardMouse::SetOutputState(const ControllerInterface::Device::Output* const output, const ControlState state)
|
void KeyboardMouse::SetOutputState(const ControllerInterface::Device::Output* const output, const ControlState state)
|
||||||
{
|
{
|
||||||
((Output*)output)->SetState( state, m_state_out );
|
((Output*)output)->SetState(state, m_state_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// names
|
// names
|
||||||
@ -236,7 +268,14 @@ std::string KeyboardMouse::Button::GetName() const
|
|||||||
std::string KeyboardMouse::Axis::GetName() const
|
std::string KeyboardMouse::Axis::GetName() const
|
||||||
{
|
{
|
||||||
std::string tmpstr("Axis ");
|
std::string tmpstr("Axis ");
|
||||||
tmpstr += "XYZ"[m_index]; tmpstr += ( m_range>0 ? '+' : '-' );
|
tmpstr += "XYZ"[m_index]; tmpstr += (m_range>0 ? '+' : '-');
|
||||||
|
return tmpstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string KeyboardMouse::Cursor::GetName() const
|
||||||
|
{
|
||||||
|
std::string tmpstr("Cursor ");
|
||||||
|
tmpstr += "XY"[m_index]; tmpstr += (m_positive ? '+' : '-');
|
||||||
return tmpstr;
|
return tmpstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,17 +287,22 @@ std::string KeyboardMouse::Light::GetName() const
|
|||||||
// get/set state
|
// get/set state
|
||||||
ControlState KeyboardMouse::Key::GetState(const State* const state) const
|
ControlState KeyboardMouse::Key::GetState(const State* const state) const
|
||||||
{
|
{
|
||||||
return ( state->keyboard[named_keys[m_index].code] > 0 );
|
return (state->keyboard[named_keys[m_index].code] != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState KeyboardMouse::Button::GetState(const State* const state) const
|
ControlState KeyboardMouse::Button::GetState(const State* const state) const
|
||||||
{
|
{
|
||||||
return ( state->mouse.rgbButtons[m_index] > 0 );
|
return (state->mouse.rgbButtons[m_index] != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState KeyboardMouse::Axis::GetState(const State* const state) const
|
ControlState KeyboardMouse::Axis::GetState(const State* const state) const
|
||||||
{
|
{
|
||||||
return std::max( 0.0f, ControlState((&state->mouse.lX)[m_index]) / m_range );
|
return std::max(0.0f, ControlState((&state->mouse.lX)[m_index]) / m_range);
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlState KeyboardMouse::Cursor::GetState(const State* const state) const
|
||||||
|
{
|
||||||
|
return std::max(0.0f, ControlState((&state->cursor.x)[m_index]) / (m_positive ? 1.0f : -1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardMouse::Light::SetState(const ControlState state, unsigned char* const state_out)
|
void KeyboardMouse::Light::SetState(const ControlState state, unsigned char* const state_out)
|
||||||
|
@ -14,7 +14,7 @@ namespace ciface
|
|||||||
namespace DInput
|
namespace DInput
|
||||||
{
|
{
|
||||||
|
|
||||||
void InitKeyboardMouse( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices );
|
void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices, HWND _hwnd);
|
||||||
|
|
||||||
class KeyboardMouse : public ControllerInterface::Device
|
class KeyboardMouse : public ControllerInterface::Device
|
||||||
{
|
{
|
||||||
@ -27,6 +27,10 @@ protected:
|
|||||||
{
|
{
|
||||||
BYTE keyboard[256];
|
BYTE keyboard[256];
|
||||||
DIMOUSESTATE2 mouse;
|
DIMOUSESTATE2 mouse;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
float x, y;
|
||||||
|
} cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Input : public ControllerInterface::Device::Input
|
class Input : public ControllerInterface::Device::Input
|
||||||
@ -80,6 +84,20 @@ protected:
|
|||||||
const LONG m_range;
|
const LONG m_range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Cursor : public Input
|
||||||
|
{
|
||||||
|
friend class KeyboardMouse;
|
||||||
|
public:
|
||||||
|
std::string GetName() const;
|
||||||
|
bool IsDetectable() { return false; }
|
||||||
|
protected:
|
||||||
|
Cursor(const unsigned int index, const bool positive) : m_index(index), m_positive(positive) {}
|
||||||
|
ControlState GetState(const State* const state) const;
|
||||||
|
private:
|
||||||
|
const unsigned int m_index;
|
||||||
|
const bool m_positive;
|
||||||
|
};
|
||||||
|
|
||||||
class Light : public Output
|
class Light : public Output
|
||||||
{
|
{
|
||||||
friend class KeyboardMouse;
|
friend class KeyboardMouse;
|
||||||
|
@ -9,7 +9,7 @@ namespace ciface
|
|||||||
namespace XInput
|
namespace XInput
|
||||||
{
|
{
|
||||||
|
|
||||||
struct
|
static struct
|
||||||
{
|
{
|
||||||
const char* const name;
|
const char* const name;
|
||||||
const WORD bitmask;
|
const WORD bitmask;
|
||||||
@ -31,13 +31,13 @@ struct
|
|||||||
{ "Thumb R", XINPUT_GAMEPAD_RIGHT_THUMB }
|
{ "Thumb R", XINPUT_GAMEPAD_RIGHT_THUMB }
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* named_triggers[] =
|
static const char* const named_triggers[] =
|
||||||
{
|
{
|
||||||
"Trigger L",
|
"Trigger L",
|
||||||
"Trigger R"
|
"Trigger R"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* named_axes[] =
|
static const char* const named_axes[] =
|
||||||
{
|
{
|
||||||
"Left X",
|
"Left X",
|
||||||
"Left Y",
|
"Left Y",
|
||||||
@ -45,7 +45,7 @@ const char* named_axes[] =
|
|||||||
"Right Y"
|
"Right Y"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* named_motors[] =
|
static const char* const named_motors[] =
|
||||||
{
|
{
|
||||||
"Motor L",
|
"Motor L",
|
||||||
"Motor R"
|
"Motor R"
|
||||||
|
@ -43,14 +43,22 @@ bool InputPlugin::LoadConfig()
|
|||||||
{
|
{
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
|
if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
|
||||||
|
{
|
||||||
|
controllers[0]->LoadDefaults(controller_interface);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector< ControllerEmu* >::const_iterator
|
std::vector< ControllerEmu* >::const_iterator
|
||||||
i = controllers.begin(),
|
i = controllers.begin(),
|
||||||
e = controllers.end();
|
e = controllers.end();
|
||||||
for ( ; i!=e; ++i ) {
|
for ( ; i!=e; ++i )
|
||||||
|
{
|
||||||
|
// load settings from ini
|
||||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||||
|
// update refs
|
||||||
|
(*i)->UpdateReferences(controller_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,19 +3,24 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
const char* DefaultPort(const int index)
|
||||||
|
{
|
||||||
|
static std::string s;
|
||||||
|
s = "443";
|
||||||
|
s += (char)('2' + index);
|
||||||
|
return s.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
UDPWrapper::UDPWrapper(int indx, const char* const _name) :
|
UDPWrapper::UDPWrapper(int indx, const char* const _name) :
|
||||||
ControllerEmu::ControlGroup(_name,GROUP_TYPE_UDPWII),
|
ControllerEmu::ControlGroup(_name,GROUP_TYPE_UDPWII),
|
||||||
inst(NULL), index(indx),
|
inst(NULL), index(indx),
|
||||||
updIR(false),updAccel(false),
|
updIR(false),updAccel(false),
|
||||||
updButt(false),udpEn(false)
|
updButt(false),udpEn(false)
|
||||||
|
, port(DefaultPort(indx))
|
||||||
{
|
{
|
||||||
char s[5];
|
|
||||||
sprintf(s,"%d",4432+index);
|
|
||||||
port=s;
|
|
||||||
//PanicAlert("UDPWrapper #%d ctor",index);
|
//PanicAlert("UDPWrapper #%d ctor",index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base )
|
void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base )
|
||||||
{
|
{
|
||||||
ControlGroup::LoadConfig(sec,defdev,base);
|
ControlGroup::LoadConfig(sec,defdev,base);
|
||||||
@ -23,15 +28,11 @@ void UDPWrapper::LoadConfig(IniFile::Section *sec, const std::string& defdev, co
|
|||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
|
|
||||||
int _updAccel,_updIR,_updButt,_udpEn;
|
int _updAccel,_updIR,_updButt,_udpEn;
|
||||||
sec->Get((group + "Enable").c_str(),&_udpEn,0);
|
sec->Get((group + "Enable").c_str(),&_udpEn, 0);
|
||||||
|
sec->Get((group + "Port").c_str(), &port, DefaultPort(index));
|
||||||
char s[5];
|
sec->Get((group + "Update_Accel").c_str(), &_updAccel, 1);
|
||||||
sprintf(s,"%d",4432+index);
|
sec->Get((group + "Update_IR").c_str(), &_updIR, 1);
|
||||||
sec->Get((group + "Port").c_str(),&port,s);
|
sec->Get((group + "Update_Butt").c_str(), &_updButt, 1);
|
||||||
|
|
||||||
sec->Get((group + "Update_Accel").c_str(),&_updAccel,1);
|
|
||||||
sec->Get((group + "Update_IR").c_str(),&_updIR,1);
|
|
||||||
sec->Get((group + "Update_Butt").c_str(),&_updButt,1);
|
|
||||||
|
|
||||||
udpEn=(_udpEn>0);
|
udpEn=(_udpEn>0);
|
||||||
updAccel=(_updAccel>0);
|
updAccel=(_updAccel>0);
|
||||||
@ -46,11 +47,11 @@ void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, co
|
|||||||
{
|
{
|
||||||
ControlGroup::SaveConfig(sec,defdev,base);
|
ControlGroup::SaveConfig(sec,defdev,base);
|
||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
sec->Set((group + "Enable").c_str(),(int)udpEn);
|
sec->Set((group + "Enable").c_str(), (int)udpEn, 0);
|
||||||
sec->Set((group + "Port").c_str(),port.c_str());
|
sec->Set((group + "Port").c_str(), port, DefaultPort(index));
|
||||||
sec->Set((group + "Update_Accel").c_str(),(int)updAccel);
|
sec->Set((group + "Update_Accel").c_str(), (int)updAccel, 1);
|
||||||
sec->Set((group + "Update_IR").c_str(),(int)updIR);
|
sec->Set((group + "Update_IR").c_str(), (int)updIR, 1);
|
||||||
sec->Set((group + "Update_Butt").c_str(),(int)updButt);
|
sec->Set((group + "Update_Butt").c_str(), (int)updButt, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,6 +284,17 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
|
|||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GamepadPage::LoadDefaults( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
controller->LoadDefaults(m_plugin.controller_interface);
|
||||||
|
|
||||||
|
m_plugin.controls_crit.Enter(); // enter
|
||||||
|
controller->UpdateReferences(m_plugin.controller_interface);
|
||||||
|
m_plugin.controls_crit.Leave(); // leave
|
||||||
|
|
||||||
|
UpdateGUI();
|
||||||
|
}
|
||||||
|
|
||||||
void ControlDialog::SetControl( wxCommandEvent& event )
|
void ControlDialog::SetControl( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
|
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
|
||||||
@ -877,7 +888,7 @@ GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned
|
|||||||
|
|
||||||
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Device") );
|
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Device") );
|
||||||
|
|
||||||
device_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1), 0, 0, wxTE_PROCESS_ENTER );
|
device_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1), 0, 0, wxTE_PROCESS_ENTER );
|
||||||
|
|
||||||
wxButton* refresh_button = new wxButton( this, -1, wxT("Refresh"), wxDefaultPosition, wxSize(60,-1) );
|
wxButton* refresh_button = new wxButton( this, -1, wxT("Refresh"), wxDefaultPosition, wxSize(60,-1) );
|
||||||
|
|
||||||
@ -888,13 +899,17 @@ GamepadPage::GamepadPage( wxWindow* parent, InputPlugin& plugin, const unsigned
|
|||||||
device_sbox->Add( device_cbox, 1, wxLEFT|wxRIGHT, 3 );
|
device_sbox->Add( device_cbox, 1, wxLEFT|wxRIGHT, 3 );
|
||||||
device_sbox->Add( refresh_button, 0, wxRIGHT|wxBOTTOM, 3 );
|
device_sbox->Add( refresh_button, 0, wxRIGHT|wxBOTTOM, 3 );
|
||||||
|
|
||||||
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Clear") );
|
wxButton* const default_button = new wxButton( this, -1, wxT("Default"), wxDefaultPosition, wxSize(48,-1) );
|
||||||
wxButton* all_button = new wxButton( this, -1, wxT("All"), wxDefaultPosition, wxSize(48,-1) );
|
wxButton* const clearall_button = new wxButton( this, -1, wxT("Clear"), wxDefaultPosition, wxSize(48,-1) );
|
||||||
clear_sbox->Add( all_button, 1, wxLEFT|wxRIGHT, 3 );
|
|
||||||
|
|
||||||
_connect_macro_(all_button, GamepadPage::ClearAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer( wxHORIZONTAL, this, wxT("Reset") );
|
||||||
|
clear_sbox->Add(default_button, 1, wxLEFT, 3);
|
||||||
|
clear_sbox->Add(clearall_button, 1, wxRIGHT, 3);
|
||||||
|
|
||||||
profile_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1) );
|
_connect_macro_(clearall_button, GamepadPage::ClearAll, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
||||||
|
_connect_macro_(default_button, GamepadPage::LoadDefaults, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
||||||
|
|
||||||
|
profile_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1) );
|
||||||
|
|
||||||
wxButton* const pload_btn = new wxButton( this, -1, wxT("Load"), wxDefaultPosition, wxSize(48,-1) );
|
wxButton* const pload_btn = new wxButton( this, -1, wxT("Load"), wxDefaultPosition, wxSize(48,-1) );
|
||||||
wxButton* const psave_btn = new wxButton( this, -1, wxT("Save"), wxDefaultPosition, wxSize(48,-1) );
|
wxButton* const psave_btn = new wxButton( this, -1, wxT("Save"), wxDefaultPosition, wxSize(48,-1) );
|
||||||
|
@ -206,6 +206,7 @@ public:
|
|||||||
void SetDevice( wxCommandEvent& event );
|
void SetDevice( wxCommandEvent& event );
|
||||||
|
|
||||||
void ClearAll( wxCommandEvent& event );
|
void ClearAll( wxCommandEvent& event );
|
||||||
|
void LoadDefaults( wxCommandEvent& event );
|
||||||
|
|
||||||
void AdjustControlOption( wxCommandEvent& event );
|
void AdjustControlOption( wxCommandEvent& event );
|
||||||
void AdjustSetting( wxCommandEvent& event );
|
void AdjustSetting( wxCommandEvent& event );
|
||||||
|
@ -21,8 +21,11 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() );
|
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() );
|
||||||
|
|
||||||
std::vector< ControlGroupBox* >::iterator g = current_page->control_groups.begin(),
|
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||||
ge = current_page->control_groups.end();
|
|
||||||
|
std::vector< ControlGroupBox* >::iterator
|
||||||
|
g = current_page->control_groups.begin(),
|
||||||
|
ge = current_page->control_groups.end();
|
||||||
for ( ; g != ge; ++g )
|
for ( ; g != ge; ++g )
|
||||||
{
|
{
|
||||||
// if this control group has a bitmap
|
// if this control group has a bitmap
|
||||||
@ -42,14 +45,12 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
|||||||
dc.SelectObject(bitmap);
|
dc.SelectObject(bitmap);
|
||||||
dc.Clear();
|
dc.Clear();
|
||||||
|
|
||||||
|
dc.SetFont(small_font);
|
||||||
|
dc.SetTextForeground(0xC0C0C0);
|
||||||
|
|
||||||
// label for sticks and stuff
|
// label for sticks and stuff
|
||||||
if (64 == bitmap.GetHeight())
|
if (64 == bitmap.GetHeight())
|
||||||
{
|
|
||||||
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
|
||||||
dc.SetFont(small_font);
|
|
||||||
dc.SetTextForeground(0xC0C0C0);
|
|
||||||
dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);
|
dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);
|
||||||
}
|
|
||||||
|
|
||||||
switch ( (*g)->control_group->type )
|
switch ( (*g)->control_group->type )
|
||||||
{
|
{
|
||||||
@ -208,22 +209,27 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
|||||||
dc.SetPen(*wxGREY_PEN);
|
dc.SetPen(*wxGREY_PEN);
|
||||||
|
|
||||||
unsigned int * const bitmasks = new unsigned int[ button_count ];
|
unsigned int * const bitmasks = new unsigned int[ button_count ];
|
||||||
for ( unsigned int n = 0; n<button_count; ++n )
|
for (unsigned int n = 0; n<button_count; ++n)
|
||||||
bitmasks[n] = ( 1 << n );
|
bitmasks[n] = (1 << n);
|
||||||
|
|
||||||
unsigned int buttons = 0;
|
unsigned int buttons = 0;
|
||||||
((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks );
|
((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks );
|
||||||
|
|
||||||
for ( unsigned int n = 0; n<button_count; ++n )
|
for (unsigned int n = 0; n<button_count; ++n)
|
||||||
{
|
{
|
||||||
if ( buttons & bitmasks[n] )
|
if ( buttons & bitmasks[n] )
|
||||||
dc.SetBrush( *wxRED_BRUSH );
|
dc.SetBrush( *wxRED_BRUSH );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128;
|
unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128;
|
||||||
dc.SetBrush( wxBrush( wxColor( amt, amt, amt ) ) );
|
dc.SetBrush(wxBrush(wxColor(amt, amt, amt)));
|
||||||
}
|
}
|
||||||
dc.DrawRectangle(n*12, 0, 14, 12);
|
dc.DrawRectangle(n * 12, 0, 14, 12);
|
||||||
|
|
||||||
|
// text
|
||||||
|
const char* const name = (*g)->control_group->controls[n]->name;
|
||||||
|
// bit of hax so ZL, ZR show up as L, R
|
||||||
|
dc.DrawText(wxString::FromAscii((name[1] && name[1] < 'a') ? name[1] : name[0]), n*12 + 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] bitmasks;
|
delete[] bitmasks;
|
||||||
@ -257,6 +263,9 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
|||||||
// deadzone affected
|
// deadzone affected
|
||||||
dc.SetBrush(*wxRED_BRUSH);
|
dc.SetBrush(*wxRED_BRUSH);
|
||||||
dc.DrawRectangle(0, n*12, trigs[n], 14);
|
dc.DrawRectangle(0, n*12, trigs[n], 14);
|
||||||
|
|
||||||
|
// text
|
||||||
|
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name), 3, n*12 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] trigs;
|
delete[] trigs;
|
||||||
@ -289,6 +298,10 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
|||||||
dc.SetBrush(*wxWHITE_BRUSH);
|
dc.SetBrush(*wxWHITE_BRUSH);
|
||||||
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
|
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
|
||||||
dc.DrawRectangle(64, n*12, 32, 14);
|
dc.DrawRectangle(64, n*12, 32, 14);
|
||||||
|
|
||||||
|
// text
|
||||||
|
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
|
||||||
|
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name[0]), 64 + 3, n*12 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// threshold box
|
// threshold box
|
||||||
|
@ -13,7 +13,7 @@ static const u8 classic_calibration[] =
|
|||||||
0x00, 0x00, 0x51, 0xa6
|
0x00, 0x00, 0x51, 0xa6
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 classic_button_bitmasks[] =
|
static const u16 classic_button_bitmasks[] =
|
||||||
{
|
{
|
||||||
Classic::BUTTON_A,
|
Classic::BUTTON_A,
|
||||||
Classic::BUTTON_B,
|
Classic::BUTTON_B,
|
||||||
@ -29,22 +29,22 @@ const u16 classic_button_bitmasks[] =
|
|||||||
Classic::BUTTON_HOME,
|
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,
|
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"
|
"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
|
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 )
|
void Classic::GetState( u8* const data, const bool focus )
|
||||||
{
|
{
|
||||||
wm_classic_extension* const ccdata = (wm_classic_extension*)data;
|
wm_classic_extension* const ccdata = (wm_classic_extension*)data;
|
||||||
|
ccdata->bt = 0;
|
||||||
|
|
||||||
// not using calibration data, o well
|
// not using calibration data, o well
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace WiimoteEmu
|
|||||||
|
|
||||||
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
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_RED,
|
||||||
Drums::PAD_YELLOW,
|
Drums::PAD_YELLOW,
|
||||||
@ -16,12 +16,12 @@ const u16 drum_pad_bitmasks[] =
|
|||||||
Drums::PAD_BASS,
|
Drums::PAD_BASS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* drum_pad_names[] =
|
static const char* const drum_pad_names[] =
|
||||||
{
|
{
|
||||||
"Red","Yellow","Blue","Green","Orange","Bass"
|
"Red","Yellow","Blue","Green","Orange","Bass"
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 drum_button_bitmasks[] =
|
static const u16 drum_button_bitmasks[] =
|
||||||
{
|
{
|
||||||
Drums::BUTTON_MINUS,
|
Drums::BUTTON_MINUS,
|
||||||
Drums::BUTTON_PLUS,
|
Drums::BUTTON_PLUS,
|
||||||
@ -39,8 +39,8 @@ Drums::Drums() : Attachment( "Drums" )
|
|||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back( m_buttons = new Buttons( "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("-") );
|
||||||
m_buttons->controls.push_back( new ControlGroup::Input("Plus") );
|
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// id
|
// id
|
||||||
@ -50,6 +50,7 @@ Drums::Drums() : Attachment( "Drums" )
|
|||||||
void Drums::GetState(u8* const data, const bool focus)
|
void Drums::GetState(u8* const data, const bool focus)
|
||||||
{
|
{
|
||||||
wm_drums_extension* const ddata = (wm_drums_extension*)data;
|
wm_drums_extension* const ddata = (wm_drums_extension*)data;
|
||||||
|
ddata->bt = 0;
|
||||||
|
|
||||||
// calibration data not figured out yet?
|
// calibration data not figured out yet?
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace WiimoteEmu
|
|||||||
|
|
||||||
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
|
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_GREEN,
|
||||||
Guitar::FRET_RED,
|
Guitar::FRET_RED,
|
||||||
@ -15,18 +15,18 @@ const u16 guitar_fret_bitmasks[] =
|
|||||||
Guitar::FRET_ORANGE,
|
Guitar::FRET_ORANGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* guitar_fret_names[] =
|
static const char* const guitar_fret_names[] =
|
||||||
{
|
{
|
||||||
"Green","Red","Yellow","Blue","Orange",
|
"Green","Red","Yellow","Blue","Orange",
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 guitar_button_bitmasks[] =
|
static const u16 guitar_button_bitmasks[] =
|
||||||
{
|
{
|
||||||
Guitar::BUTTON_MINUS,
|
Guitar::BUTTON_MINUS,
|
||||||
Guitar::BUTTON_PLUS,
|
Guitar::BUTTON_PLUS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 guitar_strum_bitmasks[] =
|
static const u16 guitar_strum_bitmasks[] =
|
||||||
{
|
{
|
||||||
Guitar::BAR_UP,
|
Guitar::BAR_UP,
|
||||||
Guitar::BAR_DOWN,
|
Guitar::BAR_DOWN,
|
||||||
@ -53,8 +53,8 @@ Guitar::Guitar() : Attachment( "Guitar" )
|
|||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back( m_buttons = new Buttons( "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("-") );
|
||||||
m_buttons->controls.push_back( new ControlGroup::Input("Plus") );
|
m_buttons->controls.push_back( new ControlGroup::Input("+") );
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// id
|
// id
|
||||||
@ -64,6 +64,7 @@ Guitar::Guitar() : Attachment( "Guitar" )
|
|||||||
void Guitar::GetState(u8* const data, const bool focus)
|
void Guitar::GetState(u8* const data, const bool focus)
|
||||||
{
|
{
|
||||||
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
|
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
|
||||||
|
gdata->bt = 0;
|
||||||
|
|
||||||
// calibration data not figured out yet?
|
// calibration data not figured out yet?
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ static const u8 nunchuck_calibration[] =
|
|||||||
0xec, 0x41 // checksum on the last two bytes
|
0xec, 0x41 // checksum on the last two bytes
|
||||||
};
|
};
|
||||||
|
|
||||||
const u8 nunchuk_button_bitmasks[] =
|
static const u8 nunchuk_button_bitmasks[] =
|
||||||
{
|
{
|
||||||
Nunchuk::BUTTON_C,
|
Nunchuk::BUTTON_C,
|
||||||
Nunchuk::BUTTON_Z,
|
Nunchuk::BUTTON_Z,
|
||||||
@ -62,6 +62,7 @@ Nunchuk::Nunchuk() : Attachment( "Nunchuk" )
|
|||||||
void Nunchuk::GetState( u8* const data, const bool focus )
|
void Nunchuk::GetState( u8* const data, const bool focus )
|
||||||
{
|
{
|
||||||
wm_extension* const ncdata = (wm_extension*)data;
|
wm_extension* const ncdata = (wm_extension*)data;
|
||||||
|
ncdata->bt = 0;
|
||||||
|
|
||||||
// stick / not using calibration data for stick, o well
|
// stick / not using calibration data for stick, o well
|
||||||
m_stick->GetState( &ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0 );
|
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->all_the_time;
|
||||||
m_reporting_auto = dr->continuous; // this right?
|
m_reporting_auto = dr->continuous; // this right?
|
||||||
m_reporting_mode = dr->mode;
|
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
|
// reset IR camera
|
||||||
//memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack
|
//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
|
0x77, 0x88, 0x00, 0x00, 0x2B, 0x01, 0xE8, 0x13
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReportFeatures
|
static struct ReportFeatures
|
||||||
{
|
{
|
||||||
u8 core, accel, ir, ext, size;
|
u8 core, accel, ir, ext, size;
|
||||||
} const reporting_mode_features[] =
|
} const reporting_mode_features[] =
|
||||||
@ -193,10 +193,10 @@ const char* const named_buttons[] =
|
|||||||
{
|
{
|
||||||
"A",
|
"A",
|
||||||
"B",
|
"B",
|
||||||
"One",
|
"1",
|
||||||
"Two",
|
"2",
|
||||||
"Minus",
|
"-",
|
||||||
"Plus",
|
"+",
|
||||||
"Home",
|
"Home",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -395,6 +395,10 @@ void Wiimote::Update()
|
|||||||
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
|
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
|
// check if there is a read data request
|
||||||
if (m_read_requests.size())
|
if (m_read_requests.size())
|
||||||
{
|
{
|
||||||
@ -458,7 +462,7 @@ void Wiimote::Update()
|
|||||||
if (rpt.accel)
|
if (rpt.accel)
|
||||||
{
|
{
|
||||||
// ----TILT----
|
// ----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----
|
// ----SWING----
|
||||||
//const s8 swing_data[] = { 0x20, 0x40, 0x20, 0x00 };
|
//const s8 swing_data[] = { 0x20, 0x40, 0x20, 0x00 };
|
||||||
@ -496,36 +500,44 @@ void Wiimote::Update()
|
|||||||
if (rpt.ir)
|
if (rpt.ir)
|
||||||
{
|
{
|
||||||
float xx = 10000, yy = 0, zz = 0;
|
float xx = 10000, yy = 0, zz = 0;
|
||||||
|
unsigned int x[4], y[4];
|
||||||
|
|
||||||
if (is_focus)
|
if (is_focus)
|
||||||
{
|
{
|
||||||
m_ir->GetState(&xx, &yy, &zz, true);
|
m_ir->GetState(&xx, &yy, &zz, true);
|
||||||
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
|
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
|
// Fill report with valid data when full handshake was done
|
||||||
if (m_reg_ir->data[0x30] || m_reg_ir->data[0x33])
|
if (m_reg_ir->data[0x30] || m_reg_ir->data[0x33])
|
||||||
// ir mode
|
// ir mode
|
||||||
@ -534,27 +546,25 @@ void Wiimote::Update()
|
|||||||
// basic
|
// basic
|
||||||
case 1 :
|
case 1 :
|
||||||
{
|
{
|
||||||
|
memset(data + rpt.ir, 0xFF, 10);
|
||||||
wm_ir_basic* const irdata = (wm_ir_basic*)(data + rpt.ir);
|
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].y1 = u8(y[i*2]);
|
||||||
irdata[i].y1hi = y >> 8;
|
irdata[i].y1hi = y[i*2] >> 8;
|
||||||
}
|
}
|
||||||
if (x[i*2+1] < 1024)
|
if (x[i*2+1] < 1024 && y[i*2+1] < 768)
|
||||||
{
|
{
|
||||||
irdata[i].x2 = u8(x[i*2+1]);
|
irdata[i].x2 = u8(x[i*2+1]);
|
||||||
irdata[i].x2hi = x[i*2+1] >> 8;
|
irdata[i].x2hi = x[i*2+1] >> 8;
|
||||||
|
|
||||||
irdata[i].y2 = u8(y);
|
irdata[i].y2 = u8(y[i*2+1]);
|
||||||
irdata[i].y2hi = y >> 8;
|
irdata[i].y2hi = y[i*2+1] >> 8;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -562,21 +572,19 @@ void Wiimote::Update()
|
|||||||
// extended
|
// extended
|
||||||
case 3 :
|
case 3 :
|
||||||
{
|
{
|
||||||
|
memset(data + rpt.ir, 0xFF, 12);
|
||||||
wm_ir_extended* const irdata = (wm_ir_extended*)(data + rpt.ir);
|
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 && y[i] < 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;
|
||||||
irdata[i].x = u8(x[i]);
|
|
||||||
irdata[i].xhi = x[i] >> 8;
|
|
||||||
|
|
||||||
irdata[i].y = u8(y);
|
irdata[i].y = u8(y[i]);
|
||||||
irdata[i].yhi = y >> 8;
|
irdata[i].yhi = y[i] >> 8;
|
||||||
|
|
||||||
irdata[i].size = 10;
|
irdata[i].size = 10;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// full
|
// full
|
||||||
@ -628,7 +636,6 @@ void Wiimote::Update()
|
|||||||
|
|
||||||
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
|
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check for custom communication
|
// Check for custom communication
|
||||||
if (99 == _channelID)
|
if (99 == _channelID)
|
||||||
{
|
{
|
||||||
@ -640,6 +647,9 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this all good?
|
||||||
|
m_reporting_channel = _channelID;
|
||||||
|
|
||||||
hid_packet* hidp = (hid_packet*)_pData;
|
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);
|
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)
|
void Wiimote::InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
// this all good?
|
||||||
|
m_reporting_channel = _channelID;
|
||||||
|
|
||||||
hid_packet* hidp = (hid_packet*)_pData;
|
hid_packet* hidp = (hid_packet*)_pData;
|
||||||
|
|
||||||
switch (hidp->type)
|
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
|
// TODO: i need to test this
|
||||||
void Wiimote::Register::Read( size_t address, void* dst, size_t length )
|
void Wiimote::Register::Read( size_t address, void* dst, size_t length )
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,8 @@ public:
|
|||||||
|
|
||||||
void DoState(PointerWrap& p);
|
void DoState(PointerWrap& p);
|
||||||
|
|
||||||
|
void LoadDefaults(const ControllerInterface& ciface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ReadRequest
|
struct ReadRequest
|
||||||
{
|
{
|
||||||
|
@ -120,19 +120,12 @@ void InitPlugin( void* const hwnd )
|
|||||||
for ( unsigned int i = 0; i<4; ++i )
|
for ( unsigned int i = 0; i<4; ++i )
|
||||||
g_plugin.controllers.push_back( new WiimoteEmu::Wiimote(i) );
|
g_plugin.controllers.push_back( new WiimoteEmu::Wiimote(i) );
|
||||||
|
|
||||||
// load the saved controller config
|
|
||||||
g_plugin.LoadConfig();
|
|
||||||
|
|
||||||
// needed for Xlib and exclusive dinput
|
// needed for Xlib and exclusive dinput
|
||||||
g_plugin.controller_interface.SetHwnd(hwnd);
|
g_plugin.controller_interface.SetHwnd(hwnd);
|
||||||
g_plugin.controller_interface.Init();
|
g_plugin.controller_interface.Init();
|
||||||
|
|
||||||
// update control refs
|
// load the saved controller config
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
g_plugin.LoadConfig();
|
||||||
i = g_plugin.controllers.begin(),
|
|
||||||
e = g_plugin.controllers.end();
|
|
||||||
for ( ; i!=e; ++i )
|
|
||||||
(*i)->UpdateReferences( g_plugin.controller_interface );
|
|
||||||
|
|
||||||
// real wiimotes
|
// real wiimotes
|
||||||
WiimoteReal::LoadSettings();
|
WiimoteReal::LoadSettings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user