1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Merge pull request #150 from lioncash/unique-ptr

Misc cleanup of the Io stuff.
This commit is contained in:
Alexandro Sánchez Bach 2014-04-07 09:49:09 +02:00
commit f45223563c
18 changed files with 297 additions and 262 deletions

View File

@ -15,14 +15,20 @@ KeyboardManager::~KeyboardManager()
void KeyboardManager::Init(const u32 max_connect)
{
if(m_inited) return;
if(m_inited)
return;
// NOTE: Change these to std::make_unique assignments when C++14 comes out.
switch(Ini.KeyboardHandlerMode.GetValue())
{
case 1: m_keyboard_handler = new WindowsKeyboardHandler(); break;
case 1:
m_keyboard_handler.reset(new WindowsKeyboardHandler());
break;
default:
case 0: m_keyboard_handler = new NullKeyboardHandler(); break;
case 0:
m_keyboard_handler.reset(new NullKeyboardHandler());
break;
}
m_keyboard_handler->Init(max_connect);

View File

@ -1,11 +1,13 @@
#pragma once
#include <memory>
#include <vector>
#include "KeyboardHandler.h"
class KeyboardManager //: public wxWindow
{
bool m_inited;
KeyboardHandlerBase* m_keyboard_handler;
std::unique_ptr<KeyboardHandlerBase> m_keyboard_handler;
public:
KeyboardManager();
@ -14,9 +16,9 @@ public:
void Init(const u32 max_connect);
void Close();
Array<Keyboard>& GetKeyboards() { return m_keyboard_handler->GetKeyboards(); }
std::vector<Keyboard>& GetKeyboards() { return m_keyboard_handler->GetKeyboards(); }
KbInfo& GetInfo() { return m_keyboard_handler->GetInfo(); }
Array<KbButton>& GetButtons(const u32 keyboard) { return m_keyboard_handler->GetButtons(keyboard); }
std::vector<KbButton>& GetButtons(const u32 keyboard) { return m_keyboard_handler->GetButtons(keyboard); }
CellKbData& GetData(const u32 keyboard) { return m_keyboard_handler->GetData(keyboard); }
CellKbConfig& GetConfig(const u32 keyboard) { return m_keyboard_handler->GetConfig(keyboard); }

View File

@ -1,5 +1,7 @@
#pragma once
#include <vector>
extern u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode); // (TODO: Can it be problematic to place SysCalls in middle of nowhere?)
enum KbPortStatus
@ -248,22 +250,20 @@ struct Keyboard
{
CellKbData m_data;
CellKbConfig m_config;
Array<KbButton> m_buttons;
std::vector<KbButton> m_buttons;
Keyboard()
: m_data()
, m_config()
{
}
~Keyboard() { m_buttons.Clear(); }
};
class KeyboardHandlerBase
{
protected:
KbInfo m_info;
Array<Keyboard> m_keyboards;
std::vector<Keyboard> m_keyboards;
public:
virtual void Init(const u32 max_connect)=0;
@ -271,22 +271,22 @@ public:
void Key(const u32 code, bool pressed)
{
for(u64 p=0; p<GetKeyboards().GetCount(); ++p)
for(Keyboard& keyboard : m_keyboards)
{
for(u64 b=0; b<GetButtons(p).GetCount(); b++)
for(KbButton& button : keyboard.m_buttons)
{
KbButton& button = GetButtons(p).Get(b);
if(button.m_keyCode != code) continue;
if(button.m_keyCode != code)
continue;
CellKbData& data = GetKeyboards()[p].m_data;
CellKbConfig& config = GetKeyboards()[p].m_config;
CellKbData& data = keyboard.m_data;
CellKbConfig& config = keyboard.m_config;
if (pressed)
{
// Meta Keys
if (code == 308 || code == 307 || code == 306 ||
code == 393 || code == 396 || code == 394)
{ // Meta Keys
code == 393 || code == 396 || code == 394)
{
data.mkey |= button.m_outKeyCode;
}
else
@ -312,9 +312,10 @@ public:
if (!pressed)
{
// Meta Keys
if (code == 308 || code == 307 || code == 306 ||
code == 393 || code == 396 || code == 394)
{ // Meta Keys
code == 393 || code == 396 || code == 394)
{
data.mkey &= ~button.m_outKeyCode;
}
}
@ -324,8 +325,8 @@ public:
}
KbInfo& GetInfo() { return m_info; }
Array<Keyboard>& GetKeyboards() { return m_keyboards; }
Array<KbButton>& GetButtons(const u32 keyboard) { return GetKeyboards()[keyboard].m_buttons; }
CellKbData& GetData(const u32 keyboard) { return GetKeyboards()[keyboard].m_data; }
CellKbConfig& GetConfig(const u32 keyboard) { return GetKeyboards()[keyboard].m_config; }
std::vector<Keyboard>& GetKeyboards() { return m_keyboards; }
std::vector<KbButton>& GetButtons(const u32 keyboard) { return m_keyboards[keyboard].m_buttons; }
CellKbData& GetData(const u32 keyboard) { return m_keyboards[keyboard].m_data; }
CellKbConfig& GetConfig(const u32 keyboard) { return m_keyboards[keyboard].m_config; }
};

View File

@ -15,14 +15,20 @@ MouseManager::~MouseManager()
void MouseManager::Init(const u32 max_connect)
{
if(m_inited) return;
if(m_inited)
return;
// NOTE: Change these to std::make_unique assignments when C++14 is available.
switch(Ini.MouseHandlerMode.GetValue())
{
case 1: m_mouse_handler = new WindowsMouseHandler(); break;
case 1:
m_mouse_handler.reset(new WindowsMouseHandler());
break;
default:
case 0: m_mouse_handler = new NullMouseHandler(); break;
case 0:
m_mouse_handler.reset(new NullMouseHandler());
break;
}
m_mouse_handler->Init(max_connect);

View File

@ -1,11 +1,13 @@
#pragma once
#include <memory>
#include <vector>
#include "MouseHandler.h"
class MouseManager //: public wxWindow
{
bool m_inited;
MouseHandlerBase* m_mouse_handler;
std::unique_ptr<MouseHandlerBase> m_mouse_handler;
public:
MouseManager();
@ -14,7 +16,7 @@ public:
void Init(const u32 max_connect);
void Close();
Array<Mouse>& GetMice() { return m_mouse_handler->GetMice(); }
std::vector<Mouse>& GetMice() { return m_mouse_handler->GetMice(); }
MouseInfo& GetInfo() { return m_mouse_handler->GetInfo(); }
CellMouseData& GetData(const u32 mouse) { return m_mouse_handler->GetData(mouse); }
CellMouseRawData& GetRawData(const u32 mouse) { return m_mouse_handler->GetRawData(mouse); }

View File

@ -1,5 +1,7 @@
#pragma once
#include <vector>
enum MousePortStatus
{
CELL_MOUSE_STATUS_DISCONNECTED = 0x00000000,
@ -99,7 +101,7 @@ class MouseHandlerBase
{
protected:
MouseInfo m_info;
Array<Mouse> m_mice;
std::vector<Mouse> m_mice;
public:
virtual void Init(const u32 max_connect)=0;
@ -107,7 +109,7 @@ public:
void Button(u8 button, bool pressed)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
for(u64 p=0; p < m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
@ -121,7 +123,7 @@ public:
void Scroll(const s8 rotation)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
for(u64 p=0; p < m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
@ -134,17 +136,17 @@ public:
void Move(const s16 x_pos_new, const s16 y_pos_new)
{
for(u64 p=0; p<GetMice().GetCount(); ++p)
for(u64 p=0; p< m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
CellMouseData& data = GetData(p);
data.update = CELL_MOUSE_DATA_UPDATE;
data.x_axis += x_pos_new - GetMice()[p].x_pos;
data.y_axis += y_pos_new - GetMice()[p].y_pos;
data.x_axis += x_pos_new - m_mice[p].x_pos;
data.y_axis += y_pos_new - m_mice[p].y_pos;
GetMice()[p].x_pos = x_pos_new;
GetMice()[p].y_pos = y_pos_new;
m_mice[p].x_pos = x_pos_new;
m_mice[p].y_pos = y_pos_new;
/*CellMouseRawData& rawdata = GetRawData(p);
rawdata.data[rawdata.len % CELL_MOUSE_MAX_CODES] = 0; // (TODO)
@ -154,7 +156,7 @@ public:
}
MouseInfo& GetInfo() { return m_info; }
Array<Mouse>& GetMice() { return m_mice; }
CellMouseData& GetData(const u32 mouse) { return GetMice()[mouse].m_data; }
CellMouseRawData& GetRawData(const u32 mouse) { return GetMice()[mouse].m_rawdata; }
std::vector<Mouse>& GetMice() { return m_mice; }
CellMouseData& GetData(const u32 mouse) { return m_mice[mouse].m_data; }
CellMouseRawData& GetRawData(const u32 mouse) { return m_mice[mouse].m_rawdata; }
};

View File

@ -2,7 +2,7 @@
#include "Emu/Io/KeyboardHandler.h"
class NullKeyboardHandler : public KeyboardHandlerBase
class NullKeyboardHandler final : public KeyboardHandlerBase
{
public:
NullKeyboardHandler()
@ -13,16 +13,16 @@ public:
{
memset(&m_info, 0, sizeof(KbInfo));
m_info.max_connect = max_connect;
m_keyboards.Clear();
m_keyboards.clear();
for(u32 i=0; i<max_connect; i++)
{
m_keyboards.Move(new Keyboard());
m_keyboards.emplace_back(Keyboard());
}
}
virtual void Close()
{
memset(&m_info, 0, sizeof(KbInfo));
m_keyboards.Clear();
m_keyboards.clear();
}
};

View File

@ -2,7 +2,7 @@
#include "Emu/Io/MouseHandler.h"
class NullMouseHandler : public MouseHandlerBase
class NullMouseHandler final : public MouseHandlerBase
{
public:
NullMouseHandler()
@ -13,12 +13,12 @@ public:
{
memset(&m_info, 0, sizeof(MouseInfo));
m_info.max_connect = max_connect;
m_mice.Clear();
m_mice.clear();
}
virtual void Close()
{
memset(&m_info, 0, sizeof(MouseInfo));
m_mice.Clear();
m_mice.clear();
}
};

View File

@ -2,7 +2,7 @@
#include "Emu/Io/PadHandler.h"
class NullPadHandler : public PadHandlerBase
class NullPadHandler final : public PadHandlerBase
{
public:
NullPadHandler()
@ -13,12 +13,12 @@ public:
{
memset(&m_info, 0, sizeof(PadInfo));
m_info.max_connect = max_connect;
m_pads.Clear();
m_pads.clear();
}
virtual void Close()
{
memset(&m_info, 0, sizeof(PadInfo));
m_pads.Clear();
m_pads.clear();
}
};

View File

@ -15,14 +15,20 @@ PadManager::~PadManager()
void PadManager::Init(const u32 max_connect)
{
if(m_inited) return;
if(m_inited)
return;
// NOTE: Change these to std::make_unique assignments when C++14 is available.
switch(Ini.PadHandlerMode.GetValue())
{
case 1: m_pad_handler = new WindowsPadHandler(); break;
case 1:
m_pad_handler.reset(new WindowsPadHandler());
break;
default:
case 0: m_pad_handler = new NullPadHandler(); break;
case 0:
m_pad_handler.reset(new NullPadHandler());
break;
}
m_pad_handler->Init(max_connect);

View File

@ -1,11 +1,13 @@
#pragma once
#include <memory>
#include <vector>
#include "PadHandler.h"
class PadManager //: public wxWindow
{
bool m_inited;
PadHandlerBase* m_pad_handler;
std::unique_ptr<PadHandlerBase> m_pad_handler;
public:
PadManager();
@ -14,9 +16,9 @@ public:
void Init(const u32 max_connect);
void Close();
Array<Pad>& GetPads() { return m_pad_handler->GetPads(); }
std::vector<Pad>& GetPads() { return m_pad_handler->GetPads(); }
PadInfo& GetInfo() { return m_pad_handler->GetInfo(); }
Array<Button>& GetButtons(const u32 pad) { return m_pad_handler->GetButtons(pad); }
std::vector<Button>& GetButtons(const u32 pad) { return m_pad_handler->GetButtons(pad); }
bool IsInited() const { return m_inited; }

View File

@ -1,5 +1,7 @@
#pragma once
#include <vector>
enum PortStatus
{
CELL_PAD_STATUS_DISCONNECTED = 0x00000000,
@ -128,8 +130,8 @@ struct Pad
u32 m_device_capability;
u32 m_device_type;
Array<Button> m_buttons;
Array<AnalogStick> m_sticks;
std::vector<Button> m_buttons;
std::vector<AnalogStick> m_sticks;
s16 m_analog_left_x;
s16 m_analog_left_y;
@ -184,8 +186,6 @@ struct Pad
, m_sensor_g(0)
{
}
~Pad() { m_buttons.Clear(); m_sticks.Clear(); }
};
struct PadInfo
@ -199,7 +199,7 @@ class PadHandlerBase
{
protected:
PadInfo m_info;
Array<Pad> m_pads;
std::vector<Pad> m_pads;
public:
virtual void Init(const u32 max_connect)=0;
@ -207,14 +207,14 @@ public:
void Key(const u32 code, bool pressed)
{
for(u64 p=0; p<GetPads().GetCount(); ++p)
for(Pad& pad : m_pads)
{
for(u64 b=0; b<GetButtons(p).GetCount(); b++)
for(Button& button : pad.m_buttons)
{
Button& button = GetButtons(p).Get(b);
if(button.m_keyCode != code) continue;
if(button.m_keyCode != code)
continue;
GetPads()[p].m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
if(button.m_pressed && !pressed)
{
@ -225,12 +225,13 @@ public:
button.m_pressed = pressed;
}
}
for(u32 s = 0; s < GetSticks(p).GetCount(); s++)
{
AnalogStick& stick = GetSticks(p).Get(s);
if (stick.m_keyCodeMax != code && stick.m_keyCodeMin != code) continue;
GetPads()[p].m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
for(AnalogStick& stick : pad.m_sticks)
{
if (stick.m_keyCodeMax != code && stick.m_keyCodeMin != code)
continue;
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
if (stick.m_keyCodeMax == code)
{
@ -247,7 +248,7 @@ public:
}
PadInfo& GetInfo() { return m_info; }
Array<Pad>& GetPads() { return m_pads; }
Array<Button>& GetButtons(const u32 pad) { return GetPads()[pad].m_buttons; }
Array<AnalogStick>& GetSticks(const u32 pad) { return GetPads()[pad].m_sticks; }
std::vector<Pad>& GetPads() { return m_pads; }
std::vector<Button>& GetButtons(const u32 pad) { return m_pads[pad].m_buttons; }
std::vector<AnalogStick>& GetSticks(const u32 pad) { return m_pads[pad].m_sticks; }
};

View File

@ -1,8 +1,10 @@
#pragma once
#include <algorithm>
#include <vector>
#include "Emu/Io/KeyboardHandler.h"
class WindowsKeyboardHandler
class WindowsKeyboardHandler final
: public wxWindow
, public KeyboardHandlerBase
{
@ -22,12 +24,13 @@ public:
{
for(u32 i=0; i<max_connect; i++)
{
m_keyboards.Move(new Keyboard());
m_keyboards.emplace_back(Keyboard());
}
LoadSettings();
memset(&m_info, 0, sizeof(KbInfo));
m_info.max_connect = max_connect;
m_info.now_connect = min<int>(GetKeyboards().GetCount(), max_connect);
m_info.now_connect = std::min<size_t>(m_keyboards.size(), max_connect);
m_info.info = 0; // Ownership of keyboard data: 0=Application, 1=System
m_info.status[0] = CELL_KB_STATUS_CONNECTED; // (TODO: Support for more keyboards)
}
@ -35,139 +38,139 @@ public:
virtual void Close()
{
memset(&m_info, 0, sizeof(KbInfo));
m_keyboards.Clear();
m_keyboards.clear();
}
void LoadSettings()
{
// Meta Keys
m_keyboards[0].m_buttons.Move(new KbButton(WXK_CONTROL, CELL_KB_MKEY_L_CTRL));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SHIFT, CELL_KB_MKEY_L_SHIFT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_ALT, CELL_KB_MKEY_L_ALT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_WINDOWS_LEFT, CELL_KB_MKEY_L_WIN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_COMMAND, CELL_KB_MKEY_L_WIN));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_CTRL));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_SHIFT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KB_MKEY_R_ALT));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_WINDOWS_RIGHT, CELL_KB_MKEY_R_WIN));
m_keyboards[0].m_buttons.emplace_back(WXK_CONTROL, CELL_KB_MKEY_L_CTRL);
m_keyboards[0].m_buttons.emplace_back(WXK_SHIFT, CELL_KB_MKEY_L_SHIFT);
m_keyboards[0].m_buttons.emplace_back(WXK_ALT, CELL_KB_MKEY_L_ALT);
m_keyboards[0].m_buttons.emplace_back(WXK_WINDOWS_LEFT, CELL_KB_MKEY_L_WIN);
m_keyboards[0].m_buttons.emplace_back(WXK_COMMAND, CELL_KB_MKEY_L_WIN);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KB_MKEY_R_CTRL);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KB_MKEY_R_SHIFT);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KB_MKEY_R_ALT);
m_keyboards[0].m_buttons.emplace_back(WXK_WINDOWS_RIGHT, CELL_KB_MKEY_R_WIN);
// CELL_KB_RAWDAT
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_NO_EVENT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_ROLLOVER));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_POSTFAIL));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_E_UNDEF));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_ESCAPE, CELL_KEYC_ESCAPE));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_106_KANJI));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_CAPITAL, CELL_KEYC_CAPS_LOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F1, CELL_KEYC_F1));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F2, CELL_KEYC_F2));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F3, CELL_KEYC_F3));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F4, CELL_KEYC_F4));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F5, CELL_KEYC_F5));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F6, CELL_KEYC_F6));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F7, CELL_KEYC_F7));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F8, CELL_KEYC_F8));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F9, CELL_KEYC_F9));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F10, CELL_KEYC_F10));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F11, CELL_KEYC_F11));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_F12, CELL_KEYC_F12));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PRINT, CELL_KEYC_PRINTSCREEN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SCROLL, CELL_KEYC_SCROLL_LOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAUSE, CELL_KEYC_PAUSE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_INSERT, CELL_KEYC_INSERT));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_HOME));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAGEUP, CELL_KEYC_PAGE_UP));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_DELETE, CELL_KEYC_DELETE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_END, CELL_KEYC_END));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_PAGEDOWN, CELL_KEYC_PAGE_DOWN));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_RIGHT, CELL_KEYC_RIGHT_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_LEFT, CELL_KEYC_LEFT_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_DOWN, CELL_KEYC_DOWN_ARROW));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_UP, CELL_KEYC_UP_ARROW));
//m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMLOCK, CELL_KEYC_NUM_LOCK));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_APPLICATION));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_KANA));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_HENKAN));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_MUHENKAN));
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_NO_EVENT);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_E_ROLLOVER);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_E_POSTFAIL);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_E_UNDEF);
m_keyboards[0].m_buttons.emplace_back(WXK_ESCAPE, CELL_KEYC_ESCAPE);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_106_KANJI);
m_keyboards[0].m_buttons.emplace_back(WXK_CAPITAL, CELL_KEYC_CAPS_LOCK);
m_keyboards[0].m_buttons.emplace_back(WXK_F1, CELL_KEYC_F1);
m_keyboards[0].m_buttons.emplace_back(WXK_F2, CELL_KEYC_F2);
m_keyboards[0].m_buttons.emplace_back(WXK_F3, CELL_KEYC_F3);
m_keyboards[0].m_buttons.emplace_back(WXK_F4, CELL_KEYC_F4);
m_keyboards[0].m_buttons.emplace_back(WXK_F5, CELL_KEYC_F5);
m_keyboards[0].m_buttons.emplace_back(WXK_F6, CELL_KEYC_F6);
m_keyboards[0].m_buttons.emplace_back(WXK_F7, CELL_KEYC_F7);
m_keyboards[0].m_buttons.emplace_back(WXK_F8, CELL_KEYC_F8);
m_keyboards[0].m_buttons.emplace_back(WXK_F9, CELL_KEYC_F9);
m_keyboards[0].m_buttons.emplace_back(WXK_F10, CELL_KEYC_F10);
m_keyboards[0].m_buttons.emplace_back(WXK_F11, CELL_KEYC_F11);
m_keyboards[0].m_buttons.emplace_back(WXK_F12, CELL_KEYC_F12);
m_keyboards[0].m_buttons.emplace_back(WXK_PRINT, CELL_KEYC_PRINTSCREEN);
m_keyboards[0].m_buttons.emplace_back(WXK_SCROLL, CELL_KEYC_SCROLL_LOCK);
m_keyboards[0].m_buttons.emplace_back(WXK_PAUSE, CELL_KEYC_PAUSE);
m_keyboards[0].m_buttons.emplace_back(WXK_INSERT, CELL_KEYC_INSERT);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_HOME);
m_keyboards[0].m_buttons.emplace_back(WXK_PAGEUP, CELL_KEYC_PAGE_UP);
m_keyboards[0].m_buttons.emplace_back(WXK_DELETE, CELL_KEYC_DELETE);
m_keyboards[0].m_buttons.emplace_back(WXK_END, CELL_KEYC_END);
m_keyboards[0].m_buttons.emplace_back(WXK_PAGEDOWN, CELL_KEYC_PAGE_DOWN);
m_keyboards[0].m_buttons.emplace_back(WXK_RIGHT, CELL_KEYC_RIGHT_ARROW);
m_keyboards[0].m_buttons.emplace_back(WXK_LEFT, CELL_KEYC_LEFT_ARROW);
m_keyboards[0].m_buttons.emplace_back(WXK_DOWN, CELL_KEYC_DOWN_ARROW);
m_keyboards[0].m_buttons.emplace_back(WXK_UP, CELL_KEYC_UP_ARROW);
//m_keyboards[0].m_buttons.emplace_back(WXK_NUMLOCK, CELL_KEYC_NUM_LOCK);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_APPLICATION);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_KANA);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_HENKAN);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_MUHENKAN);
// CELL_KB_KEYPAD
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMLOCK, CELL_KEYC_KPAD_NUMLOCK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_DIVIDE, CELL_KEYC_KPAD_SLASH));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_MULTIPLY, CELL_KEYC_KPAD_ASTERISK));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_SUBTRACT, CELL_KEYC_KPAD_MINUS));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_ADD, CELL_KEYC_KPAD_PLUS));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_ENTER, CELL_KEYC_KPAD_ENTER));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD1, CELL_KEYC_KPAD_1));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD2, CELL_KEYC_KPAD_2));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD3, CELL_KEYC_KPAD_3));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD4, CELL_KEYC_KPAD_4));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD5, CELL_KEYC_KPAD_5));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD6, CELL_KEYC_KPAD_6));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD7, CELL_KEYC_KPAD_7));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD8, CELL_KEYC_KPAD_8));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD9, CELL_KEYC_KPAD_9));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD0, CELL_KEYC_KPAD_0));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_NUMPAD_DELETE, CELL_KEYC_KPAD_PERIOD));
m_keyboards[0].m_buttons.emplace_back(WXK_NUMLOCK, CELL_KEYC_KPAD_NUMLOCK);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_DIVIDE, CELL_KEYC_KPAD_SLASH);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_MULTIPLY, CELL_KEYC_KPAD_ASTERISK);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_SUBTRACT, CELL_KEYC_KPAD_MINUS);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_ADD, CELL_KEYC_KPAD_PLUS);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_ENTER, CELL_KEYC_KPAD_ENTER);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD1, CELL_KEYC_KPAD_1);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD2, CELL_KEYC_KPAD_2);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD3, CELL_KEYC_KPAD_3);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD4, CELL_KEYC_KPAD_4);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD5, CELL_KEYC_KPAD_5);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD6, CELL_KEYC_KPAD_6);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD7, CELL_KEYC_KPAD_7);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD8, CELL_KEYC_KPAD_8);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD9, CELL_KEYC_KPAD_9);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD0, CELL_KEYC_KPAD_0);
m_keyboards[0].m_buttons.emplace_back(WXK_NUMPAD_DELETE, CELL_KEYC_KPAD_PERIOD);
// ASCII Printable characters
m_keyboards[0].m_buttons.Move(new KbButton('A', CELL_KEYC_A));
m_keyboards[0].m_buttons.Move(new KbButton('B', CELL_KEYC_B));
m_keyboards[0].m_buttons.Move(new KbButton('C', CELL_KEYC_C));
m_keyboards[0].m_buttons.Move(new KbButton('D', CELL_KEYC_D));
m_keyboards[0].m_buttons.Move(new KbButton('E', CELL_KEYC_E));
m_keyboards[0].m_buttons.Move(new KbButton('F', CELL_KEYC_F));
m_keyboards[0].m_buttons.Move(new KbButton('G', CELL_KEYC_G));
m_keyboards[0].m_buttons.Move(new KbButton('H', CELL_KEYC_H));
m_keyboards[0].m_buttons.Move(new KbButton('I', CELL_KEYC_I));
m_keyboards[0].m_buttons.Move(new KbButton('J', CELL_KEYC_J));
m_keyboards[0].m_buttons.Move(new KbButton('K', CELL_KEYC_K));
m_keyboards[0].m_buttons.Move(new KbButton('L', CELL_KEYC_L));
m_keyboards[0].m_buttons.Move(new KbButton('M', CELL_KEYC_M));
m_keyboards[0].m_buttons.Move(new KbButton('N', CELL_KEYC_N));
m_keyboards[0].m_buttons.Move(new KbButton('O', CELL_KEYC_O));
m_keyboards[0].m_buttons.Move(new KbButton('P', CELL_KEYC_P));
m_keyboards[0].m_buttons.Move(new KbButton('Q', CELL_KEYC_Q));
m_keyboards[0].m_buttons.Move(new KbButton('R', CELL_KEYC_R));
m_keyboards[0].m_buttons.Move(new KbButton('S', CELL_KEYC_S));
m_keyboards[0].m_buttons.Move(new KbButton('T', CELL_KEYC_T));
m_keyboards[0].m_buttons.Move(new KbButton('U', CELL_KEYC_U));
m_keyboards[0].m_buttons.Move(new KbButton('V', CELL_KEYC_V));
m_keyboards[0].m_buttons.Move(new KbButton('W', CELL_KEYC_W));
m_keyboards[0].m_buttons.Move(new KbButton('X', CELL_KEYC_X));
m_keyboards[0].m_buttons.Move(new KbButton('Y', CELL_KEYC_Y));
m_keyboards[0].m_buttons.Move(new KbButton('Z', CELL_KEYC_Z));
m_keyboards[0].m_buttons.emplace_back('A', CELL_KEYC_A);
m_keyboards[0].m_buttons.emplace_back('B', CELL_KEYC_B);
m_keyboards[0].m_buttons.emplace_back('C', CELL_KEYC_C);
m_keyboards[0].m_buttons.emplace_back('D', CELL_KEYC_D);
m_keyboards[0].m_buttons.emplace_back('E', CELL_KEYC_E);
m_keyboards[0].m_buttons.emplace_back('F', CELL_KEYC_F);
m_keyboards[0].m_buttons.emplace_back('G', CELL_KEYC_G);
m_keyboards[0].m_buttons.emplace_back('H', CELL_KEYC_H);
m_keyboards[0].m_buttons.emplace_back('I', CELL_KEYC_I);
m_keyboards[0].m_buttons.emplace_back('J', CELL_KEYC_J);
m_keyboards[0].m_buttons.emplace_back('K', CELL_KEYC_K);
m_keyboards[0].m_buttons.emplace_back('L', CELL_KEYC_L);
m_keyboards[0].m_buttons.emplace_back('M', CELL_KEYC_M);
m_keyboards[0].m_buttons.emplace_back('N', CELL_KEYC_N);
m_keyboards[0].m_buttons.emplace_back('O', CELL_KEYC_O);
m_keyboards[0].m_buttons.emplace_back('P', CELL_KEYC_P);
m_keyboards[0].m_buttons.emplace_back('Q', CELL_KEYC_Q);
m_keyboards[0].m_buttons.emplace_back('R', CELL_KEYC_R);
m_keyboards[0].m_buttons.emplace_back('S', CELL_KEYC_S);
m_keyboards[0].m_buttons.emplace_back('T', CELL_KEYC_T);
m_keyboards[0].m_buttons.emplace_back('U', CELL_KEYC_U);
m_keyboards[0].m_buttons.emplace_back('V', CELL_KEYC_V);
m_keyboards[0].m_buttons.emplace_back('W', CELL_KEYC_W);
m_keyboards[0].m_buttons.emplace_back('X', CELL_KEYC_X);
m_keyboards[0].m_buttons.emplace_back('Y', CELL_KEYC_Y);
m_keyboards[0].m_buttons.emplace_back('Z', CELL_KEYC_Z);
m_keyboards[0].m_buttons.Move(new KbButton('1', CELL_KEYC_1));
m_keyboards[0].m_buttons.Move(new KbButton('2', CELL_KEYC_2));
m_keyboards[0].m_buttons.Move(new KbButton('3', CELL_KEYC_3));
m_keyboards[0].m_buttons.Move(new KbButton('4', CELL_KEYC_4));
m_keyboards[0].m_buttons.Move(new KbButton('5', CELL_KEYC_5));
m_keyboards[0].m_buttons.Move(new KbButton('6', CELL_KEYC_6));
m_keyboards[0].m_buttons.Move(new KbButton('7', CELL_KEYC_7));
m_keyboards[0].m_buttons.Move(new KbButton('8', CELL_KEYC_8));
m_keyboards[0].m_buttons.Move(new KbButton('9', CELL_KEYC_9));
m_keyboards[0].m_buttons.Move(new KbButton('0', CELL_KEYC_0));
m_keyboards[0].m_buttons.emplace_back('1', CELL_KEYC_1);
m_keyboards[0].m_buttons.emplace_back('2', CELL_KEYC_2);
m_keyboards[0].m_buttons.emplace_back('3', CELL_KEYC_3);
m_keyboards[0].m_buttons.emplace_back('4', CELL_KEYC_4);
m_keyboards[0].m_buttons.emplace_back('5', CELL_KEYC_5);
m_keyboards[0].m_buttons.emplace_back('6', CELL_KEYC_6);
m_keyboards[0].m_buttons.emplace_back('7', CELL_KEYC_7);
m_keyboards[0].m_buttons.emplace_back('8', CELL_KEYC_8);
m_keyboards[0].m_buttons.emplace_back('9', CELL_KEYC_9);
m_keyboards[0].m_buttons.emplace_back('0', CELL_KEYC_0);
m_keyboards[0].m_buttons.Move(new KbButton(WXK_RETURN, CELL_KEYC_ENTER));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_ESC));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_TAB, CELL_KEYC_TAB));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SPACE, CELL_KEYC_SPACE));
m_keyboards[0].m_buttons.Move(new KbButton(WXK_SUBTRACT, CELL_KEYC_MINUS));
m_keyboards[0].m_buttons.Move(new KbButton('=', CELL_KEYC_EQUAL_101));
m_keyboards[0].m_buttons.Move(new KbButton('^', CELL_KEYC_ACCENT_CIRCONFLEX_106));
//m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_LEFT_BRACKET_101));
m_keyboards[0].m_buttons.Move(new KbButton('@', CELL_KEYC_ATMARK_106));
//m_keyboards[0].m_buttons.Move(new KbButton(')', CELL_KEYC_RIGHT_BRACKET_101));
m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_LEFT_BRACKET_106));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_BACKSLASH_101));
m_keyboards[0].m_buttons.Move(new KbButton('(', CELL_KEYC_RIGHT_BRACKET_106));
m_keyboards[0].m_buttons.Move(new KbButton(';', CELL_KEYC_SEMICOLON));
m_keyboards[0].m_buttons.Move(new KbButton('"', CELL_KEYC_QUOTATION_101));
m_keyboards[0].m_buttons.Move(new KbButton(':', CELL_KEYC_COLON_106));
m_keyboards[0].m_buttons.Move(new KbButton(',', CELL_KEYC_COMMA));
m_keyboards[0].m_buttons.Move(new KbButton('.', CELL_KEYC_PERIOD));
m_keyboards[0].m_buttons.Move(new KbButton('/', CELL_KEYC_SLASH));
m_keyboards[0].m_buttons.Move(new KbButton('\\', CELL_KEYC_BACKSLASH_106));
//m_keyboards[0].m_buttons.Move(new KbButton(, CELL_KEYC_YEN_106));
m_keyboards[0].m_buttons.emplace_back(WXK_RETURN, CELL_KEYC_ENTER);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_ESC);
m_keyboards[0].m_buttons.emplace_back(WXK_TAB, CELL_KEYC_TAB);
m_keyboards[0].m_buttons.emplace_back(WXK_SPACE, CELL_KEYC_SPACE);
m_keyboards[0].m_buttons.emplace_back(WXK_SUBTRACT, CELL_KEYC_MINUS);
m_keyboards[0].m_buttons.emplace_back('=', CELL_KEYC_EQUAL_101);
m_keyboards[0].m_buttons.emplace_back('^', CELL_KEYC_ACCENT_CIRCONFLEX_106);
//m_keyboards[0].m_buttons.emplace_back('(', CELL_KEYC_LEFT_BRACKET_101);
m_keyboards[0].m_buttons.emplace_back('@', CELL_KEYC_ATMARK_106);
//m_keyboards[0].m_buttons.emplace_back(')', CELL_KEYC_RIGHT_BRACKET_101);
m_keyboards[0].m_buttons.emplace_back('(', CELL_KEYC_LEFT_BRACKET_106);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_BACKSLASH_101);
m_keyboards[0].m_buttons.emplace_back('(', CELL_KEYC_RIGHT_BRACKET_106);
m_keyboards[0].m_buttons.emplace_back(';', CELL_KEYC_SEMICOLON);
m_keyboards[0].m_buttons.emplace_back('"', CELL_KEYC_QUOTATION_101);
m_keyboards[0].m_buttons.emplace_back(':', CELL_KEYC_COLON_106);
m_keyboards[0].m_buttons.emplace_back(',', CELL_KEYC_COMMA);
m_keyboards[0].m_buttons.emplace_back('.', CELL_KEYC_PERIOD);
m_keyboards[0].m_buttons.emplace_back('/', CELL_KEYC_SLASH);
m_keyboards[0].m_buttons.emplace_back('\\', CELL_KEYC_BACKSLASH_106);
//m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_YEN_106);
}
};

View File

@ -1,8 +1,9 @@
#pragma once
#include <algorithm>
#include "Emu/Io/MouseHandler.h"
class WindowsMouseHandler
class WindowsMouseHandler final
: public wxWindow
, public MouseHandlerBase
{
@ -28,7 +29,7 @@ public:
else if (event.MiddleDown()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, 1);
event.Skip();
}
virtual void MouseButtonUp(wxMouseEvent& event)
virtual void MouseButtonUp(wxMouseEvent& event)
{
if (event.LeftUp()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, 0);
else if (event.RightUp()) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, 0);
@ -40,10 +41,10 @@ public:
virtual void Init(const u32 max_connect)
{
m_mice.Move(new Mouse());
m_mice.emplace_back(Mouse());
memset(&m_info, 0, sizeof(MouseInfo));
m_info.max_connect = max_connect;
m_info.now_connect = min<int>(GetMice().GetCount(), max_connect);
m_info.now_connect = std::min(m_mice.size(), (size_t)max_connect);
m_info.info = 0; // Ownership of mouse data: 0=Application, 1=System
m_info.status[0] = CELL_MOUSE_STATUS_CONNECTED; // (TODO: Support for more mice)
for(u32 i=1; i<max_connect; i++) m_info.status[i] = CELL_MOUSE_STATUS_DISCONNECTED;
@ -54,6 +55,6 @@ public:
virtual void Close()
{
memset(&m_info, 0, sizeof(MouseInfo));
m_mice.Clear();
m_mice.clear();
}
};

View File

@ -1,8 +1,9 @@
#pragma once
#include <algorithm>
#include "Emu/Io/PadHandler.h"
class WindowsPadHandler
class WindowsPadHandler final
: public wxWindow
, public PadHandlerBase
{
@ -23,43 +24,43 @@ public:
memset(&m_info, 0, sizeof(PadInfo));
m_info.max_connect = max_connect;
LoadSettings();
m_info.now_connect = min<int>(GetPads().GetCount(), max_connect);
m_info.now_connect = std::min(m_pads.size(), (size_t)max_connect);
}
virtual void Close()
{
memset(&m_info, 0, sizeof(PadInfo));
m_pads.Clear();
m_pads.clear();
}
void LoadSettings()
{
m_pads.Move(new Pad(
m_pads.emplace_back(
CELL_PAD_STATUS_CONNECTED, CELL_PAD_SETTING_PRESS_ON | CELL_PAD_SETTING_SENSOR_OFF,
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
CELL_PAD_DEV_TYPE_STANDARD));
CELL_PAD_DEV_TYPE_STANDARD);
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerLeft.GetValue(), CELL_PAD_CTRL_LEFT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerDown.GetValue(), CELL_PAD_CTRL_DOWN));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerRight.GetValue(), CELL_PAD_CTRL_RIGHT));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerUp.GetValue(), CELL_PAD_CTRL_UP));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerStart.GetValue(), CELL_PAD_CTRL_START));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerR3.GetValue(), CELL_PAD_CTRL_R3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerL3.GetValue(), CELL_PAD_CTRL_L3));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerSelect.GetValue(), CELL_PAD_CTRL_SELECT));
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerLeft.GetValue(), CELL_PAD_CTRL_LEFT);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerDown.GetValue(), CELL_PAD_CTRL_DOWN);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerRight.GetValue(), CELL_PAD_CTRL_RIGHT);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerUp.GetValue(), CELL_PAD_CTRL_UP);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerStart.GetValue(), CELL_PAD_CTRL_START);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerR3.GetValue(), CELL_PAD_CTRL_R3);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerL3.GetValue(), CELL_PAD_CTRL_L3);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL1, Ini.PadHandlerSelect.GetValue(), CELL_PAD_CTRL_SELECT);
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerSquare.GetValue(), CELL_PAD_CTRL_SQUARE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCross.GetValue(), CELL_PAD_CTRL_CROSS));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCircle.GetValue(), CELL_PAD_CTRL_CIRCLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerTriangle.GetValue(), CELL_PAD_CTRL_TRIANGLE));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR1.GetValue(), CELL_PAD_CTRL_R1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL1.GetValue(), CELL_PAD_CTRL_L1));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR2.GetValue(), CELL_PAD_CTRL_R2));
m_pads[0].m_buttons.Move(new Button(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL2.GetValue(), CELL_PAD_CTRL_L2));
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerSquare.GetValue(), CELL_PAD_CTRL_SQUARE);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCross.GetValue(), CELL_PAD_CTRL_CROSS);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerCircle.GetValue(), CELL_PAD_CTRL_CIRCLE);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerTriangle.GetValue(), CELL_PAD_CTRL_TRIANGLE);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR1.GetValue(), CELL_PAD_CTRL_R1);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL1.GetValue(), CELL_PAD_CTRL_L1);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerR2.GetValue(), CELL_PAD_CTRL_R2);
m_pads[0].m_buttons.emplace_back(CELL_PAD_BTN_OFFSET_DIGITAL2, Ini.PadHandlerL2.GetValue(), CELL_PAD_CTRL_L2);
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X, Ini.PadHandlerLStickLeft.GetValue(), Ini.PadHandlerLStickRight.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y, Ini.PadHandlerLStickUp.GetValue(), Ini.PadHandlerLStickDown.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X, Ini.PadHandlerRStickLeft.GetValue(), Ini.PadHandlerRStickRight.GetValue()));
m_pads[0].m_sticks.Move(new AnalogStick(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y, Ini.PadHandlerRStickUp.GetValue(), Ini.PadHandlerRStickDown.GetValue()));
m_pads[0].m_sticks.emplace_back(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X, Ini.PadHandlerLStickLeft.GetValue(), Ini.PadHandlerLStickRight.GetValue());
m_pads[0].m_sticks.emplace_back(CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y, Ini.PadHandlerLStickUp.GetValue(), Ini.PadHandlerLStickDown.GetValue());
m_pads[0].m_sticks.emplace_back(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X, Ini.PadHandlerRStickLeft.GetValue(), Ini.PadHandlerRStickRight.GetValue());
m_pads[0].m_sticks.emplace_back(CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y, Ini.PadHandlerRStickUp.GetValue(), Ini.PadHandlerRStickDown.GetValue());
}
};

View File

@ -38,7 +38,7 @@ int cellKbClearBuf(u32 port_no)
{
sys_io.Log("cellKbClearBuf(port_no=%d)", port_no);
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetKeyboardManager().GetKeyboards().GetCount()) return CELL_KB_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetKeyboardManager().GetKeyboards().size()) return CELL_KB_ERROR_INVALID_PARAMETER;
//?
@ -114,9 +114,9 @@ int cellKbRead(u32 port_no, mem_class_t data)
{
sys_io.Log("cellKbRead(port_no=%d,info_addr=0x%x)", port_no, data.GetAddr());
const Array<Keyboard>& keyboards = Emu.GetKeyboardManager().GetKeyboards();
const std::vector<Keyboard>& keyboards = Emu.GetKeyboardManager().GetKeyboards();
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
if(port_no >= keyboards.GetCount()) return CELL_KB_ERROR_INVALID_PARAMETER;
if(port_no >= keyboards.size()) return CELL_KB_ERROR_INVALID_PARAMETER;
CellKbData& current_data = Emu.GetKeyboardManager().GetData(port_no);
data += current_data.led;

View File

@ -31,7 +31,7 @@ int cellMouseClearBuf(u32 port_no)
{
sys_io.Log("cellMouseClearBuf(port_no=%d)", port_no);
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
//?
@ -66,7 +66,7 @@ int cellMouseInfoTabletMode(u32 port_no, mem_class_t info)
{
sys_io.Log("cellMouseInfoTabletMode(port_no=%d,info_addr=0x%x)", port_no, info.GetAddr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
info += 0; // Unimplemented: (0=Tablet mode is not supported)
info += 1; // Unimplemented: (1=Mouse mode)
@ -78,7 +78,7 @@ int cellMouseGetData(u32 port_no, mem_class_t data)
{
sys_io.Log("cellMouseGetData(port_no=%d,data_addr=0x%x)", port_no, data.GetAddr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_NO_DEVICE;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_NO_DEVICE;
CellMouseData& current_data = Emu.GetMouseManager().GetData(port_no);
data += current_data.update;
@ -123,7 +123,7 @@ int cellMouseGetRawData(u32 port_no, mem_class_t data)
/*sys_io.Log("cellMouseGetRawData(port_no=%d,data_addr=0x%x)", port_no, data.GetAddr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().GetCount()) return CELL_MOUSE_ERROR_NO_DEVICE;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_NO_DEVICE;
CellMouseRawData& current_rawdata = Emu.GetMouseManager().GetRawData(port_no);
data += current_rawdata.len;

View File

@ -65,7 +65,7 @@ int cellPadClearBuf(u32 port_no)
{
sys_io.Log("cellPadClearBuf(port_no=%d)", port_no);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetPadManager().GetPads().GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetPadManager().GetPads().size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
//?
@ -75,9 +75,9 @@ int cellPadClearBuf(u32 port_no)
int cellPadGetData(u32 port_no, u32 data_addr)
{
sys_io.Log("cellPadGetData[port_no: %d, data_addr: 0x%x]", port_no, data_addr);
const Array<Pad>& pads = Emu.GetPadManager().GetPads();
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
if(port_no >= pads.GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER;
if(port_no >= pads.size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
const Pad& pad = pads[port_no];
CellPadData data;
@ -86,24 +86,24 @@ int cellPadGetData(u32 port_no, u32 data_addr)
u16 d1 = 0;
u16 d2 = 0;
const Array<Button>& buttons = pads[port_no].m_buttons;
pads[port_no].m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
pad.m_port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES;
s32 len = 0;
for(uint i=0; i<buttons.GetCount(); ++i)
for(Button& button : pads[port_no].m_buttons)
{
if(!buttons[i].m_pressed) continue;
if(!button.m_pressed)
continue;
switch(buttons[i].m_offset)
switch(button.m_offset)
{
case CELL_PAD_BTN_OFFSET_DIGITAL1: if(!(d1 & buttons[i].m_outKeyCode)){d1 |= buttons[i].m_outKeyCode; len++;} break;
case CELL_PAD_BTN_OFFSET_DIGITAL2: if(!(d2 & buttons[i].m_outKeyCode)){d2 |= buttons[i].m_outKeyCode; len++;} break;
case CELL_PAD_BTN_OFFSET_DIGITAL1: if(!(d1 & button.m_outKeyCode)){d1 |= button.m_outKeyCode; len++;} break;
case CELL_PAD_BTN_OFFSET_DIGITAL2: if(!(d2 & button.m_outKeyCode)){d2 |= button.m_outKeyCode; len++;} break;
}
if(buttons[i].m_flush)
if(button.m_flush)
{
buttons[i].m_pressed = false;
buttons[i].m_flush = false;
button.m_pressed = false;
button.m_flush = false;
}
}
@ -111,11 +111,10 @@ int cellPadGetData(u32 port_no, u32 data_addr)
u16 ly = 128;
u16 rx = 128;
u16 ry = 128;
const Array<AnalogStick>& sticks = pads[port_no].m_sticks;
for (u32 s = 0; s < sticks.GetCount(); s++)
for (const AnalogStick& stick : pads[port_no].m_sticks)
{
u16* res;
switch (sticks[s].m_offset)
switch (stick.m_offset)
{
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X: res = &lx; break;
case CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y: res = &ly; break;
@ -124,9 +123,9 @@ int cellPadGetData(u32 port_no, u32 data_addr)
default: continue;
}
if (sticks[s].m_max_pressed && !sticks[s].m_min_pressed)
if (stick.m_max_pressed && !stick.m_min_pressed)
*res = 255;
if (sticks[s].m_min_pressed && !sticks[s].m_max_pressed)
if (stick.m_min_pressed && !stick.m_max_pressed)
*res = 0;
}
@ -163,7 +162,7 @@ int cellPadGetDataExtra(u32 port_no, u32 device_type_addr, u32 data_addr)
{
sys_io.Log("cellPadGetDataExtra(port_no=%d, device_type_addr=0x%x, device_type_addr=0x%x)", port_no, device_type_addr, data_addr);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetPadManager().GetPads().GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetPadManager().GetPads().size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
return CELL_OK;
}
@ -171,7 +170,7 @@ int cellPadSetActDirect(u32 port_no, u32 param_addr)
{
sys_io.Log("cellPadSetActDirect(port_no=%d, param_addr=0x%x)", port_no, param_addr);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetPadManager().GetPads().GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER;
if(port_no >= Emu.GetPadManager().GetPads().size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
return CELL_OK;
}
@ -188,11 +187,12 @@ int cellPadGetInfo(u32 info_addr)
info.now_connect = rinfo.now_connect;
info.system_info = rinfo.system_info;
const Array<Pad>& pads = Emu.GetPadManager().GetPads();
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
for(u32 i=0; i<CELL_MAX_PADS; ++i)
{
if(i >= pads.GetCount()) break;
if(i >= pads.size())
break;
info.status[i] = pads[i].m_port_status;
info.product_id[i] = 0x0268;
@ -217,11 +217,13 @@ int cellPadGetInfo2(u32 info_addr)
info.now_connect = rinfo.now_connect;
info.system_info = rinfo.system_info;
const Array<Pad>& pads = Emu.GetPadManager().GetPads();
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
for(u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
{
if(i >= pads.GetCount()) break;
if(i >= pads.size())
break;
info.port_status[i] = pads[i].m_port_status;
info.port_setting[i] = pads[i].m_port_setting;
info.device_capability[i] = pads[i].m_device_capability;
@ -237,8 +239,8 @@ int cellPadSetPortSetting(u32 port_no, u32 port_setting)
{
sys_io.Log("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
Array<Pad>& pads = Emu.GetPadManager().GetPads();
if(port_no >= pads.GetCount()) return CELL_PAD_ERROR_INVALID_PARAMETER;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
if(port_no >= pads.size()) return CELL_PAD_ERROR_INVALID_PARAMETER;
pads[port_no].m_port_setting = port_setting;