mirror of https://github.com/PCSX2/pcsx2.git
PAD: clang-format
This commit is contained in:
parent
2e0be1f75a
commit
82f7a23be4
|
@ -28,7 +28,7 @@ std::vector<std::unique_ptr<GamePad>> s_vgamePad;
|
||||||
/**
|
/**
|
||||||
* Find every interesting devices and create right structure for them(depend on backend)
|
* Find every interesting devices and create right structure for them(depend on backend)
|
||||||
**/
|
**/
|
||||||
void GamePad::EnumerateGamePads(std::vector<std::unique_ptr<GamePad>> &vgamePad)
|
void GamePad::EnumerateGamePads(std::vector<std::unique_ptr<GamePad>>& vgamePad)
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
JoystickInfo::EnumerateJoysticks(vgamePad);
|
JoystickInfo::EnumerateJoysticks(vgamePad);
|
||||||
|
@ -57,7 +57,8 @@ int GamePad::uid_to_index(int pad)
|
||||||
{
|
{
|
||||||
size_t uid = g_conf.get_joy_uid(pad);
|
size_t uid = g_conf.get_joy_uid(pad);
|
||||||
|
|
||||||
for (int i = 0; i < (int)s_vgamePad.size(); ++i) {
|
for (int i = 0; i < (int)s_vgamePad.size(); ++i)
|
||||||
|
{
|
||||||
if (s_vgamePad[i]->GetUniqueIdentifier() == uid)
|
if (s_vgamePad[i]->GetUniqueIdentifier() == uid)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePad(const GamePad &); // copy constructor
|
GamePad(const GamePad&); // copy constructor
|
||||||
GamePad &operator=(const GamePad &); // assignment
|
GamePad& operator=(const GamePad&); // assignment
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find every interesting devices and create right structure for them(depend on backend)
|
* Find every interesting devices and create right structure for them(depend on backend)
|
||||||
*/
|
*/
|
||||||
static void EnumerateGamePads(std::vector<std::unique_ptr<GamePad>> &vgamePad);
|
static void EnumerateGamePads(std::vector<std::unique_ptr<GamePad>>& vgamePad);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update state of every attached devices
|
* Update state of every attached devices
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool TestForce(float strength = 0.6) { return false; }
|
virtual bool TestForce(float strength = 0.6) { return false; }
|
||||||
|
|
||||||
virtual const char *GetName() = 0;
|
virtual const char* GetName() = 0;
|
||||||
|
|
||||||
virtual int GetInput(gamePadValues input) = 0;
|
virtual int GetInput(gamePadValues input) = 0;
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,15 @@
|
||||||
|
|
||||||
void KeyStatus::Init()
|
void KeyStatus::Init()
|
||||||
{
|
{
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
|
{
|
||||||
m_button[pad] = 0xFFFF;
|
m_button[pad] = 0xFFFF;
|
||||||
m_internal_button_kbd[pad] = 0xFFFF;
|
m_internal_button_kbd[pad] = 0xFFFF;
|
||||||
m_internal_button_joy[pad] = 0xFFFF;
|
m_internal_button_joy[pad] = 0xFFFF;
|
||||||
m_state_acces[pad] = false;
|
m_state_acces[pad] = false;
|
||||||
|
|
||||||
for (int index = 0; index < MAX_KEYS; index++) {
|
for (int index = 0; index < MAX_KEYS; index++)
|
||||||
|
{
|
||||||
m_button_pressure[pad][index] = 0xFF;
|
m_button_pressure[pad][index] = 0xFF;
|
||||||
m_internal_button_pressure[pad][index] = 0xFF;
|
m_internal_button_pressure[pad][index] = 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -45,13 +47,16 @@ void KeyStatus::Init()
|
||||||
|
|
||||||
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
||||||
{
|
{
|
||||||
if (!IsAnalogKey(index)) {
|
if (!IsAnalogKey(index))
|
||||||
|
{
|
||||||
m_internal_button_pressure[pad][index] = value;
|
m_internal_button_pressure[pad][index] = value;
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
clear_bit(m_internal_button_kbd[pad], index);
|
clear_bit(m_internal_button_kbd[pad], index);
|
||||||
else
|
else
|
||||||
clear_bit(m_internal_button_joy[pad], index);
|
clear_bit(m_internal_button_joy[pad], index);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// clamp value
|
// clamp value
|
||||||
if (value > MAX_ANALOG_VALUE)
|
if (value > MAX_ANALOG_VALUE)
|
||||||
value = MAX_ANALOG_VALUE;
|
value = MAX_ANALOG_VALUE;
|
||||||
|
@ -73,12 +78,15 @@ void KeyStatus::press(u32 pad, u32 index, s32 value)
|
||||||
|
|
||||||
void KeyStatus::release(u32 pad, u32 index)
|
void KeyStatus::release(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
if (!IsAnalogKey(index)) {
|
if (!IsAnalogKey(index))
|
||||||
|
{
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
set_bit(m_internal_button_kbd[pad], index);
|
set_bit(m_internal_button_kbd[pad], index);
|
||||||
else
|
else
|
||||||
set_bit(m_internal_button_joy[pad], index);
|
set_bit(m_internal_button_joy[pad], index);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
analog_set(pad, index, m_analog_released_val);
|
analog_set(pad, index, m_analog_released_val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,13 +98,14 @@ u16 KeyStatus::get(u32 pad)
|
||||||
|
|
||||||
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
||||||
{
|
{
|
||||||
PADAnalog *m_internal_analog_ref;
|
PADAnalog* m_internal_analog_ref;
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
m_internal_analog_ref = &m_internal_analog_kbd[pad];
|
m_internal_analog_ref = &m_internal_analog_kbd[pad];
|
||||||
else
|
else
|
||||||
m_internal_analog_ref = &m_internal_analog_joy[pad];
|
m_internal_analog_ref = &m_internal_analog_joy[pad];
|
||||||
|
|
||||||
switch (index) {
|
switch (index)
|
||||||
|
{
|
||||||
case PAD_R_LEFT:
|
case PAD_R_LEFT:
|
||||||
case PAD_R_RIGHT:
|
case PAD_R_RIGHT:
|
||||||
m_internal_analog_ref->rx = value;
|
m_internal_analog_ref->rx = value;
|
||||||
|
@ -124,7 +133,8 @@ void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
||||||
|
|
||||||
bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
|
bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index)
|
||||||
|
{
|
||||||
case PAD_L_RIGHT:
|
case PAD_L_RIGHT:
|
||||||
case PAD_L_LEFT:
|
case PAD_L_LEFT:
|
||||||
return (g_conf.pad_options[pad].reverse_lx);
|
return (g_conf.pad_options[pad].reverse_lx);
|
||||||
|
@ -148,7 +158,8 @@ bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
|
||||||
|
|
||||||
u8 KeyStatus::get(u32 pad, u32 index)
|
u8 KeyStatus::get(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index)
|
||||||
|
{
|
||||||
case PAD_R_LEFT:
|
case PAD_R_LEFT:
|
||||||
case PAD_R_RIGHT:
|
case PAD_R_RIGHT:
|
||||||
return m_analog[pad].rx;
|
return m_analog[pad].rx;
|
||||||
|
|
|
@ -41,14 +41,14 @@ static keyEvent s_event;
|
||||||
std::string s_padstrIniPath("inis/");
|
std::string s_padstrIniPath("inis/");
|
||||||
std::string s_padstrLogPath("logs/");
|
std::string s_padstrLogPath("logs/");
|
||||||
|
|
||||||
FILE *padLog = NULL;
|
FILE* padLog = NULL;
|
||||||
|
|
||||||
KeyStatus g_key_status;
|
KeyStatus g_key_status;
|
||||||
|
|
||||||
MtQueue<keyEvent> g_ev_fifo;
|
MtQueue<keyEvent> g_ev_fifo;
|
||||||
|
|
||||||
|
|
||||||
void __LogToConsole(const char *fmt, ...)
|
void __LogToConsole(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
|
@ -81,7 +81,8 @@ void initLogging()
|
||||||
void CloseLogging()
|
void CloseLogging()
|
||||||
{
|
{
|
||||||
#ifdef PAD_LOG
|
#ifdef PAD_LOG
|
||||||
if (padLog) {
|
if (padLog)
|
||||||
|
{
|
||||||
fclose(padLog);
|
fclose(padLog);
|
||||||
padLog = NULL;
|
padLog = NULL;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +110,7 @@ void PADshutdown()
|
||||||
CloseLogging();
|
CloseLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PADopen(void *pDsp)
|
s32 PADopen(void* pDsp)
|
||||||
{
|
{
|
||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
g_key_status.Init();
|
g_key_status.Init();
|
||||||
|
@ -122,13 +123,13 @@ s32 PADopen(void *pDsp)
|
||||||
return _PADopen(pDsp);
|
return _PADopen(pDsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PADsetSettingsDir(const char *dir)
|
void PADsetSettingsDir(const char* dir)
|
||||||
{
|
{
|
||||||
// Get the path to the ini directory.
|
// Get the path to the ini directory.
|
||||||
s_padstrIniPath = (dir == NULL) ? "inis/" : dir;
|
s_padstrIniPath = (dir == NULL) ? "inis/" : dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PADsetLogDir(const char *dir)
|
void PADsetLogDir(const char* dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_padstrLogPath = (dir == NULL) ? "logs/" : dir;
|
s_padstrLogPath = (dir == NULL) ? "logs/" : dir;
|
||||||
|
@ -152,7 +153,8 @@ s32 PADsetSlot(u8 port, u8 slot)
|
||||||
{
|
{
|
||||||
port--;
|
port--;
|
||||||
slot--;
|
slot--;
|
||||||
if (port > 1 || slot > 3) {
|
if (port > 1 || slot > 3)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Even if no pad there, record the slot, as it is the active slot regardless.
|
// Even if no pad there, record the slot, as it is the active slot regardless.
|
||||||
|
@ -161,16 +163,18 @@ s32 PADsetSlot(u8 port, u8 slot)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PADfreeze(int mode, freezeData *data)
|
s32 PADfreeze(int mode, freezeData* data)
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (mode == FREEZE_SIZE) {
|
if (mode == FREEZE_SIZE)
|
||||||
|
{
|
||||||
data->size = sizeof(PadPluginFreezeData);
|
data->size = sizeof(PadPluginFreezeData);
|
||||||
|
}
|
||||||
} else if (mode == FREEZE_LOAD) {
|
else if (mode == FREEZE_LOAD)
|
||||||
PadPluginFreezeData *pdata = (PadPluginFreezeData *)(data->data);
|
{
|
||||||
|
PadPluginFreezeData* pdata = (PadPluginFreezeData*)(data->data);
|
||||||
|
|
||||||
Pad::stop_vibrate_all();
|
Pad::stop_vibrate_all();
|
||||||
|
|
||||||
|
@ -179,17 +183,21 @@ s32 PADfreeze(int mode, freezeData *data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
query = pdata->query;
|
query = pdata->query;
|
||||||
if (pdata->query.slot < 4) {
|
if (pdata->query.slot < 4)
|
||||||
|
{
|
||||||
query = pdata->query;
|
query = pdata->query;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tales of the Abyss - pad fix
|
// Tales of the Abyss - pad fix
|
||||||
// - restore data for both ports
|
// - restore data for both ports
|
||||||
for (int port = 0; port < 2; port++) {
|
for (int port = 0; port < 2; port++)
|
||||||
for (int slot = 0; slot < 4; slot++) {
|
{
|
||||||
|
for (int slot = 0; slot < 4; slot++)
|
||||||
|
{
|
||||||
u8 mode = pdata->padData[port][slot].mode;
|
u8 mode = pdata->padData[port][slot].mode;
|
||||||
|
|
||||||
if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE) {
|
if (mode != MODE_DIGITAL && mode != MODE_ANALOG && mode != MODE_DS2_NATIVE)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,12 +207,13 @@ s32 PADfreeze(int mode, freezeData *data)
|
||||||
if (pdata->slot[port] < 4)
|
if (pdata->slot[port] < 4)
|
||||||
slots[port] = pdata->slot[port];
|
slots[port] = pdata->slot[port];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (mode == FREEZE_SAVE) {
|
else if (mode == FREEZE_SAVE)
|
||||||
|
{
|
||||||
if (data->size != sizeof(PadPluginFreezeData))
|
if (data->size != sizeof(PadPluginFreezeData))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PadPluginFreezeData *pdata = (PadPluginFreezeData *)(data->data);
|
PadPluginFreezeData* pdata = (PadPluginFreezeData*)(data->data);
|
||||||
|
|
||||||
// Tales of the Abyss - pad fix
|
// Tales of the Abyss - pad fix
|
||||||
// - PCSX2 only saves port0 (save #1), then port1 (save #2)
|
// - PCSX2 only saves port0 (save #1), then port1 (save #2)
|
||||||
|
@ -214,15 +223,18 @@ s32 PADfreeze(int mode, freezeData *data)
|
||||||
pdata->version = PAD_SAVE_STATE_VERSION;
|
pdata->version = PAD_SAVE_STATE_VERSION;
|
||||||
pdata->query = query;
|
pdata->query = query;
|
||||||
|
|
||||||
for (int port = 0; port < 2; port++) {
|
for (int port = 0; port < 2; port++)
|
||||||
for (int slot = 0; slot < 4; slot++) {
|
{
|
||||||
|
for (int slot = 0; slot < 4; slot++)
|
||||||
|
{
|
||||||
pdata->padData[port][slot] = pads[port][slot];
|
pdata->padData[port][slot] = pads[port][slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata->slot[port] = slots[port];
|
pdata->slot[port] = slots[port];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,13 +252,15 @@ u8 PADpoll(u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||||
keyEvent * PADkeyEvent()
|
keyEvent* PADkeyEvent()
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
// Take the opportunity to handle hot plugging here
|
// Take the opportunity to handle hot plugging here
|
||||||
SDL_Event events;
|
SDL_Event events;
|
||||||
while (SDL_PollEvent(&events)) {
|
while (SDL_PollEvent(&events))
|
||||||
switch (events.type) {
|
{
|
||||||
|
switch (events.type)
|
||||||
|
{
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
case SDL_CONTROLLERDEVICEREMOVED:
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
GamePad::EnumerateGamePads(s_vgamePad);
|
GamePad::EnumerateGamePads(s_vgamePad);
|
||||||
|
@ -256,7 +270,8 @@ keyEvent * PADkeyEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (g_ev_fifo.size() == 0) {
|
if (g_ev_fifo.size() == 0)
|
||||||
|
{
|
||||||
// PAD_LOG("No events in queue, returning empty event\n");
|
// PAD_LOG("No events in queue, returning empty event\n");
|
||||||
s_event = event;
|
s_event = event;
|
||||||
event.evt = 0;
|
event.evt = 0;
|
||||||
|
@ -270,7 +285,7 @@ keyEvent * PADkeyEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
void PADWriteEvent(keyEvent &evt)
|
void PADWriteEvent(keyEvent& evt)
|
||||||
{
|
{
|
||||||
// if (evt.evt != 6) { // Skip mouse move events for logging
|
// if (evt.evt != 6) { // Skip mouse move events for logging
|
||||||
// PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key);
|
// PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key);
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
|
|
||||||
#define PADdefs
|
#define PADdefs
|
||||||
|
|
||||||
enum PadOptions {
|
enum PadOptions
|
||||||
|
{
|
||||||
PADOPTION_FORCEFEEDBACK = 0x1,
|
PADOPTION_FORCEFEEDBACK = 0x1,
|
||||||
PADOPTION_REVERSELX = 0x2,
|
PADOPTION_REVERSELX = 0x2,
|
||||||
PADOPTION_REVERSELY = 0x4,
|
PADOPTION_REVERSELY = 0x4,
|
||||||
|
@ -53,7 +54,8 @@ enum PadOptions {
|
||||||
PADOPTION_MOUSE_R = 0x40,
|
PADOPTION_MOUSE_R = 0x40,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PadCommands {
|
enum PadCommands
|
||||||
|
{
|
||||||
CMD_SET_VREF_PARAM = 0x40,
|
CMD_SET_VREF_PARAM = 0x40,
|
||||||
CMD_QUERY_DS2_ANALOG_MODE = 0x41,
|
CMD_QUERY_DS2_ANALOG_MODE = 0x41,
|
||||||
CMD_READ_DATA_AND_VIBRATE = 0x42,
|
CMD_READ_DATA_AND_VIBRATE = 0x42,
|
||||||
|
@ -67,7 +69,8 @@ enum PadCommands {
|
||||||
CMD_SET_DS2_NATIVE_MODE = 0x4F // SET_DS2_NATIVE_MODE
|
CMD_SET_DS2_NATIVE_MODE = 0x4F // SET_DS2_NATIVE_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum gamePadValues {
|
enum gamePadValues
|
||||||
|
{
|
||||||
PAD_L2 = 0, // L2 button
|
PAD_L2 = 0, // L2 button
|
||||||
PAD_R2, // R2 button
|
PAD_R2, // R2 button
|
||||||
PAD_L1, // L1 button
|
PAD_L1, // L1 button
|
||||||
|
@ -102,7 +105,7 @@ enum gamePadValues {
|
||||||
#include "KeyStatus.h"
|
#include "KeyStatus.h"
|
||||||
#include "mt_queue.h"
|
#include "mt_queue.h"
|
||||||
|
|
||||||
extern FILE *padLog;
|
extern FILE* padLog;
|
||||||
extern void initLogging();
|
extern void initLogging();
|
||||||
|
|
||||||
//#define PAD_LOG __Log
|
//#define PAD_LOG __Log
|
||||||
|
@ -111,31 +114,31 @@ extern void initLogging();
|
||||||
extern keyEvent event;
|
extern keyEvent event;
|
||||||
extern MtQueue<keyEvent> g_ev_fifo;
|
extern MtQueue<keyEvent> g_ev_fifo;
|
||||||
|
|
||||||
s32 _PADopen(void *pDsp);
|
s32 _PADopen(void* pDsp);
|
||||||
void _PADclose();
|
void _PADclose();
|
||||||
void PADsetMode(int pad, int mode);
|
void PADsetMode(int pad, int mode);
|
||||||
|
|
||||||
void __LogToConsole(const char *fmt, ...);
|
void __LogToConsole(const char* fmt, ...);
|
||||||
void PADLoadConfig();
|
void PADLoadConfig();
|
||||||
void PADSaveConfig();
|
void PADSaveConfig();
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...);
|
void SysMessage(char* fmt, ...);
|
||||||
|
|
||||||
s32 PADinit();
|
s32 PADinit();
|
||||||
void PADshutdown();
|
void PADshutdown();
|
||||||
s32 PADopen(void *pDsp);
|
s32 PADopen(void* pDsp);
|
||||||
void PADsetSettingsDir(const char *dir);
|
void PADsetSettingsDir(const char* dir);
|
||||||
void PADsetLogDir(const char *dir);
|
void PADsetLogDir(const char* dir);
|
||||||
void PADclose();
|
void PADclose();
|
||||||
u32 PADquery();
|
u32 PADquery();
|
||||||
s32 PADsetSlot(u8 port, u8 slot);
|
s32 PADsetSlot(u8 port, u8 slot);
|
||||||
s32 PADfreeze(int mode, freezeData *data);
|
s32 PADfreeze(int mode, freezeData* data);
|
||||||
u8 PADstartPoll(int pad);
|
u8 PADstartPoll(int pad);
|
||||||
u8 PADpoll(u8 value);
|
u8 PADpoll(u8 value);
|
||||||
keyEvent * PADkeyEvent();
|
keyEvent* PADkeyEvent();
|
||||||
void PADupdate(int pad);
|
void PADupdate(int pad);
|
||||||
void PADconfigure();
|
void PADconfigure();
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
void PADWriteEvent(keyEvent &evt);
|
void PADWriteEvent(keyEvent& evt);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,11 +22,12 @@
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
// opens handles to all possible joysticks
|
// opens handles to all possible joysticks
|
||||||
void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjoysticks)
|
void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>>& vjoysticks)
|
||||||
{
|
{
|
||||||
uint32_t flag = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER;
|
uint32_t flag = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER;
|
||||||
|
|
||||||
if ((SDL_WasInit(0) & flag) != flag) {
|
if ((SDL_WasInit(0) & flag) != flag)
|
||||||
|
{
|
||||||
// Tell SDL to catch event even if the windows isn't focussed
|
// Tell SDL to catch event even if the windows isn't focussed
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
|
||||||
|
@ -45,25 +46,26 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjo
|
||||||
SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE);
|
SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE);
|
||||||
|
|
||||||
{ // Support as much Joystick as possible
|
{ // Support as much Joystick as possible
|
||||||
GBytes *bytes = g_resource_lookup_data(PAD_res_get_resource(), "/PAD/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
GBytes* bytes = g_resource_lookup_data(PAD_res_get_resource(), "/PAD/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
// SDL forget to add const for SDL_RWFromMem API...
|
// SDL forget to add const for SDL_RWFromMem API...
|
||||||
void *data = const_cast<void *>(g_bytes_get_data(bytes, &size));
|
void* data = const_cast<void*>(g_bytes_get_data(bytes, &size));
|
||||||
|
|
||||||
SDL_GameControllerAddMappingsFromRW(SDL_RWFromMem(data, size), 1);
|
SDL_GameControllerAddMappingsFromRW(SDL_RWFromMem(data, size), 1);
|
||||||
|
|
||||||
g_bytes_unref(bytes);
|
g_bytes_unref(bytes);
|
||||||
|
|
||||||
// Add user mapping too
|
// Add user mapping too
|
||||||
for (auto const &map : g_conf.sdl2_mapping)
|
for (auto const& map : g_conf.sdl2_mapping)
|
||||||
SDL_GameControllerAddMapping(map.c_str());
|
SDL_GameControllerAddMapping(map.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vjoysticks.clear();
|
vjoysticks.clear();
|
||||||
|
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); ++i) {
|
for (int i = 0; i < SDL_NumJoysticks(); ++i)
|
||||||
|
{
|
||||||
vjoysticks.push_back(std::unique_ptr<GamePad>(new JoystickInfo(i)));
|
vjoysticks.push_back(std::unique_ptr<GamePad>(new JoystickInfo(i)));
|
||||||
// Something goes wrong in the init, let's drop it
|
// Something goes wrong in the init, let's drop it
|
||||||
if (!vjoysticks.back()->IsProperlyInitialized())
|
if (!vjoysticks.back()->IsProperlyInitialized())
|
||||||
|
@ -83,7 +85,8 @@ void JoystickInfo::Rumble(unsigned type, unsigned pad)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int id = m_effects_id[type];
|
int id = m_effects_id[type];
|
||||||
if (SDL_HapticRunEffect(m_haptic, id, 1) != 0) {
|
if (SDL_HapticRunEffect(m_haptic, id, 1) != 0)
|
||||||
|
{
|
||||||
fprintf(stderr, "ERROR: Effect is not working! %s, id is %d\n", SDL_GetError(), id);
|
fprintf(stderr, "ERROR: Effect is not working! %s, id is %d\n", SDL_GetError(), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,8 +94,10 @@ void JoystickInfo::Rumble(unsigned type, unsigned pad)
|
||||||
JoystickInfo::~JoystickInfo()
|
JoystickInfo::~JoystickInfo()
|
||||||
{
|
{
|
||||||
// Haptic must be closed before the joystick
|
// Haptic must be closed before the joystick
|
||||||
if (m_haptic != nullptr) {
|
if (m_haptic != nullptr)
|
||||||
for (const auto &eid : m_effects_id) {
|
{
|
||||||
|
for (const auto& eid : m_effects_id)
|
||||||
|
{
|
||||||
if (eid >= 0)
|
if (eid >= 0)
|
||||||
SDL_HapticDestroyEffect(m_haptic, eid);
|
SDL_HapticDestroyEffect(m_haptic, eid);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +105,8 @@ JoystickInfo::~JoystickInfo()
|
||||||
SDL_HapticClose(m_haptic);
|
SDL_HapticClose(m_haptic);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_controller != nullptr) {
|
if (m_controller != nullptr)
|
||||||
|
{
|
||||||
#if SDL_MINOR_VERSION >= 4
|
#if SDL_MINOR_VERSION >= 4
|
||||||
// Version before 2.0.4 are bugged, JoystickClose crashes randomly
|
// Version before 2.0.4 are bugged, JoystickClose crashes randomly
|
||||||
// Note: GameControllerClose calls JoystickClose)
|
// Note: GameControllerClose calls JoystickClose)
|
||||||
|
@ -115,7 +121,7 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
, m_haptic(nullptr)
|
, m_haptic(nullptr)
|
||||||
, m_unique_id(0)
|
, m_unique_id(0)
|
||||||
{
|
{
|
||||||
SDL_Joystick *joy = nullptr;
|
SDL_Joystick* joy = nullptr;
|
||||||
m_effects_id.fill(-1);
|
m_effects_id.fill(-1);
|
||||||
// Values are hardcoded currently but it could be later extended to allow remapping of the buttons
|
// Values are hardcoded currently but it could be later extended to allow remapping of the buttons
|
||||||
m_pad_to_sdl[PAD_L2] = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
|
m_pad_to_sdl[PAD_L2] = SDL_CONTROLLER_AXIS_TRIGGERLEFT;
|
||||||
|
@ -143,14 +149,18 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
m_pad_to_sdl[PAD_R_DOWN] = SDL_CONTROLLER_AXIS_RIGHTY;
|
m_pad_to_sdl[PAD_R_DOWN] = SDL_CONTROLLER_AXIS_RIGHTY;
|
||||||
m_pad_to_sdl[PAD_R_LEFT] = SDL_CONTROLLER_AXIS_RIGHTX;
|
m_pad_to_sdl[PAD_R_LEFT] = SDL_CONTROLLER_AXIS_RIGHTX;
|
||||||
|
|
||||||
if (SDL_IsGameController(id)) {
|
if (SDL_IsGameController(id))
|
||||||
|
{
|
||||||
m_controller = SDL_GameControllerOpen(id);
|
m_controller = SDL_GameControllerOpen(id);
|
||||||
joy = SDL_GameControllerGetJoystick(m_controller);
|
joy = SDL_GameControllerGetJoystick(m_controller);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
joy = SDL_JoystickOpen(id);
|
joy = SDL_JoystickOpen(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joy == nullptr) {
|
if (joy == nullptr)
|
||||||
|
{
|
||||||
fprintf(stderr, "PAD: failed to open joystick %d\n", id);
|
fprintf(stderr, "PAD: failed to open joystick %d\n", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -158,9 +168,10 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
// Collect Device Information
|
// Collect Device Information
|
||||||
char guid[64];
|
char guid[64];
|
||||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, 64);
|
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, 64);
|
||||||
const char *devname = SDL_JoystickNameForIndex(id);
|
const char* devname = SDL_JoystickNameForIndex(id);
|
||||||
|
|
||||||
if (m_controller == nullptr) {
|
if (m_controller == nullptr)
|
||||||
|
{
|
||||||
fprintf(stderr, "PAD: Joystick (%s,GUID:%s) isn't yet supported by the SDL2 game controller API\n"
|
fprintf(stderr, "PAD: Joystick (%s,GUID:%s) isn't yet supported by the SDL2 game controller API\n"
|
||||||
"Fortunately you can use AntiMicro (https://github.com/AntiMicro/antimicro) or Steam to configure your joystick\n"
|
"Fortunately you can use AntiMicro (https://github.com/AntiMicro/antimicro) or Steam to configure your joystick\n"
|
||||||
"The mapping can be stored in OnePAD2.ini as 'SDL2 = <...mapping description...>'\n"
|
"The mapping can be stored in OnePAD2.ini as 'SDL2 = <...mapping description...>'\n"
|
||||||
|
@ -179,7 +190,8 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
|
|
||||||
// Default haptic effect
|
// Default haptic effect
|
||||||
SDL_HapticEffect effects[NB_EFFECT];
|
SDL_HapticEffect effects[NB_EFFECT];
|
||||||
for (int i = 0; i < NB_EFFECT; i++) {
|
for (int i = 0; i < NB_EFFECT; i++)
|
||||||
|
{
|
||||||
SDL_HapticEffect effect;
|
SDL_HapticEffect effect;
|
||||||
memset(&effect, 0, sizeof(SDL_HapticEffect)); // 0 is safe default
|
memset(&effect, 0, sizeof(SDL_HapticEffect)); // 0 is safe default
|
||||||
SDL_HapticDirection direction;
|
SDL_HapticDirection direction;
|
||||||
|
@ -196,13 +208,16 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
/* Sine and triangle are quite probably the best, don't change that lightly and if you do
|
/* Sine and triangle are quite probably the best, don't change that lightly and if you do
|
||||||
* keep effects ordered by type
|
* keep effects ordered by type
|
||||||
*/
|
*/
|
||||||
if (i == 0) {
|
if (i == 0)
|
||||||
|
{
|
||||||
/* Effect for small motor */
|
/* Effect for small motor */
|
||||||
/* Sine seems to be the only effect making little motor from DS3/4 react
|
/* Sine seems to be the only effect making little motor from DS3/4 react
|
||||||
* Intensity has pretty much no effect either(which is coherent with what is explain in hid_sony driver
|
* Intensity has pretty much no effect either(which is coherent with what is explain in hid_sony driver
|
||||||
*/
|
*/
|
||||||
effect.type = SDL_HAPTIC_SINE;
|
effect.type = SDL_HAPTIC_SINE;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/** Effect for big motor **/
|
/** Effect for big motor **/
|
||||||
effect.type = SDL_HAPTIC_TRIANGLE;
|
effect.type = SDL_HAPTIC_TRIANGLE;
|
||||||
}
|
}
|
||||||
|
@ -210,12 +225,15 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
effects[i] = effect;
|
effects[i] = effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_JoystickIsHaptic(joy)) {
|
if (SDL_JoystickIsHaptic(joy))
|
||||||
|
{
|
||||||
m_haptic = SDL_HapticOpenFromJoystick(joy);
|
m_haptic = SDL_HapticOpenFromJoystick(joy);
|
||||||
|
|
||||||
for (auto &eid : m_effects_id) {
|
for (auto& eid : m_effects_id)
|
||||||
|
{
|
||||||
eid = SDL_HapticNewEffect(m_haptic, &effects[0]);
|
eid = SDL_HapticNewEffect(m_haptic, &effects[0]);
|
||||||
if (eid < 0) {
|
if (eid < 0)
|
||||||
|
{
|
||||||
fprintf(stderr, "ERROR: Effect is not uploaded! %s\n", SDL_GetError());
|
fprintf(stderr, "ERROR: Effect is not uploaded! %s\n", SDL_GetError());
|
||||||
m_haptic = nullptr;
|
m_haptic = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -229,7 +247,7 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
m_no_error = true;
|
m_no_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *JoystickInfo::GetName()
|
const char* JoystickInfo::GetName()
|
||||||
{
|
{
|
||||||
return SDL_JoystickName(SDL_GameControllerGetJoystick(m_controller));
|
return SDL_JoystickName(SDL_GameControllerGetJoystick(m_controller));
|
||||||
}
|
}
|
||||||
|
@ -248,7 +266,8 @@ bool JoystickInfo::TestForce(float strength = 0.60)
|
||||||
SDL_HapticRumbleInit(m_haptic);
|
SDL_HapticRumbleInit(m_haptic);
|
||||||
|
|
||||||
// Make the haptic pad rumble 60% strength for half a second, shoudld be enough for user to see if it works or not
|
// Make the haptic pad rumble 60% strength for half a second, shoudld be enough for user to see if it works or not
|
||||||
if (SDL_HapticRumblePlay(m_haptic, strength, 400) != 0) {
|
if (SDL_HapticRumblePlay(m_haptic, strength, 400) != 0)
|
||||||
|
{
|
||||||
fprintf(stderr, "ERROR: Rumble is not working! %s\n", SDL_GetError());
|
fprintf(stderr, "ERROR: Rumble is not working! %s\n", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -261,14 +280,16 @@ int JoystickInfo::GetInput(gamePadValues input)
|
||||||
float k = g_conf.get_sensibility() / 100.0; // convert sensibility to float
|
float k = g_conf.get_sensibility() / 100.0; // convert sensibility to float
|
||||||
|
|
||||||
// Handle analog inputs which range from -32k to +32k. Range conversion is handled later in the controller
|
// Handle analog inputs which range from -32k to +32k. Range conversion is handled later in the controller
|
||||||
if (IsAnalogKey(input)) {
|
if (IsAnalogKey(input))
|
||||||
|
{
|
||||||
int value = SDL_GameControllerGetAxis(m_controller, (SDL_GameControllerAxis)m_pad_to_sdl[input]);
|
int value = SDL_GameControllerGetAxis(m_controller, (SDL_GameControllerAxis)m_pad_to_sdl[input]);
|
||||||
value *= k;
|
value *= k;
|
||||||
return (abs(value) > m_deadzone) ? value : 0;
|
return (abs(value) > m_deadzone) ? value : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle triggers which range from 0 to +32k. They must be converted to 0-255 range
|
// Handle triggers which range from 0 to +32k. They must be converted to 0-255 range
|
||||||
if (input == PAD_L2 || input == PAD_R2) {
|
if (input == PAD_L2 || input == PAD_R2)
|
||||||
|
{
|
||||||
int value = SDL_GameControllerGetAxis(m_controller, (SDL_GameControllerAxis)m_pad_to_sdl[input]);
|
int value = SDL_GameControllerGetAxis(m_controller, (SDL_GameControllerAxis)m_pad_to_sdl[input]);
|
||||||
return (value > m_deadzone) ? value / 128 : 0;
|
return (value > m_deadzone) ? value / 128 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,18 @@ public:
|
||||||
JoystickInfo(int id);
|
JoystickInfo(int id);
|
||||||
~JoystickInfo();
|
~JoystickInfo();
|
||||||
|
|
||||||
JoystickInfo(const JoystickInfo &) = delete; // copy constructor
|
JoystickInfo(const JoystickInfo&) = delete; // copy constructor
|
||||||
JoystickInfo &operator=(const JoystickInfo &) = delete; // assignment
|
JoystickInfo& operator=(const JoystickInfo&) = delete; // assignment
|
||||||
|
|
||||||
|
|
||||||
// opens handles to all possible joysticks
|
// opens handles to all possible joysticks
|
||||||
static void EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjoysticks);
|
static void EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>>& vjoysticks);
|
||||||
|
|
||||||
void Rumble(unsigned type, unsigned pad) override;
|
void Rumble(unsigned type, unsigned pad) override;
|
||||||
|
|
||||||
bool TestForce(float) override;
|
bool TestForce(float) override;
|
||||||
|
|
||||||
const char *GetName() final;
|
const char* GetName() final;
|
||||||
|
|
||||||
int GetInput(gamePadValues input) final;
|
int GetInput(gamePadValues input) final;
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public:
|
||||||
size_t GetUniqueIdentifier() final;
|
size_t GetUniqueIdentifier() final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_GameController *m_controller;
|
SDL_GameController* m_controller;
|
||||||
SDL_Haptic *m_haptic;
|
SDL_Haptic* m_haptic;
|
||||||
std::array<int, NB_EFFECT> m_effects_id;
|
std::array<int, NB_EFFECT> m_effects_id;
|
||||||
size_t m_unique_id;
|
size_t m_unique_id;
|
||||||
std::array<int, MAX_KEYS> m_pad_to_sdl;
|
std::array<int, MAX_KEYS> m_pad_to_sdl;
|
||||||
|
|
|
@ -14,25 +14,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static void __forceinline set_bit(T &value, int bit)
|
static void __forceinline set_bit(T& value, int bit)
|
||||||
{
|
{
|
||||||
value |= (1 << bit);
|
value |= (1 << bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static void __forceinline clear_bit(T &value, int bit)
|
static void __forceinline clear_bit(T& value, int bit)
|
||||||
{
|
{
|
||||||
value &= ~(1 << bit);
|
value &= ~(1 << bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static void __forceinline toggle_bit(T &value, int bit)
|
static void __forceinline toggle_bit(T& value, int bit)
|
||||||
{
|
{
|
||||||
value ^= (1 << bit);
|
value ^= (1 << bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static bool __forceinline test_bit(T &value, int bit)
|
static bool __forceinline test_bit(T& value, int bit)
|
||||||
{
|
{
|
||||||
return (value & (1 << bit));
|
return (value & (1 << bit));
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,8 @@ public:
|
||||||
packed_options = 0;
|
packed_options = 0;
|
||||||
ff_intensity = 0x7FFF; // set it at max value by default
|
ff_intensity = 0x7FFF; // set it at max value by default
|
||||||
sensibility = 100;
|
sensibility = 100;
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
|
{
|
||||||
keysym_map[pad].clear();
|
keysym_map[pad].clear();
|
||||||
}
|
}
|
||||||
unique_id.fill(0);
|
unique_id.fill(0);
|
||||||
|
@ -94,7 +95,8 @@ public:
|
||||||
**/
|
**/
|
||||||
void set_ff_intensity(u32 new_intensity)
|
void set_ff_intensity(u32 new_intensity)
|
||||||
{
|
{
|
||||||
if (new_intensity <= 0x7FFF) {
|
if (new_intensity <= 0x7FFF)
|
||||||
|
{
|
||||||
ff_intensity = new_intensity;
|
ff_intensity = new_intensity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,12 @@ void DefaultKeyboardValues()
|
||||||
|
|
||||||
void PADSaveConfig()
|
void PADSaveConfig()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE* f;
|
||||||
|
|
||||||
const std::string iniFile(s_padstrIniPath + "PAD.ini");
|
const std::string iniFile(s_padstrIniPath + "PAD.ini");
|
||||||
f = fopen(iniFile.c_str(), "w");
|
f = fopen(iniFile.c_str(), "w");
|
||||||
if (f == NULL) {
|
if (f == NULL)
|
||||||
|
{
|
||||||
printf("PAD: failed to save ini %s\n", iniFile.c_str());
|
printf("PAD: failed to save ini %s\n", iniFile.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -59,10 +60,10 @@ void PADSaveConfig()
|
||||||
fprintf(f, "uid[1] = %zu\n", g_conf.get_joy_uid(1));
|
fprintf(f, "uid[1] = %zu\n", g_conf.get_joy_uid(1));
|
||||||
|
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
for (auto const &it : g_conf.keysym_map[pad])
|
for (auto const& it : g_conf.keysym_map[pad])
|
||||||
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it.first, it.second);
|
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it.first, it.second);
|
||||||
|
|
||||||
for (auto const &it : g_conf.sdl2_mapping)
|
for (auto const& it : g_conf.sdl2_mapping)
|
||||||
fprintf(f, "SDL2 = %s\n", it.c_str());
|
fprintf(f, "SDL2 = %s\n", it.c_str());
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -70,14 +71,15 @@ void PADSaveConfig()
|
||||||
|
|
||||||
void PADLoadConfig()
|
void PADLoadConfig()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE* f;
|
||||||
bool have_user_setting = false;
|
bool have_user_setting = false;
|
||||||
|
|
||||||
g_conf.init();
|
g_conf.init();
|
||||||
|
|
||||||
const std::string iniFile(s_padstrIniPath + "PAD.ini");
|
const std::string iniFile(s_padstrIniPath + "PAD.ini");
|
||||||
f = fopen(iniFile.c_str(), "r");
|
f = fopen(iniFile.c_str(), "r");
|
||||||
if (f == NULL) {
|
if (f == NULL)
|
||||||
|
{
|
||||||
printf("OnePAD: failed to load ini %s\n", iniFile.c_str());
|
printf("OnePAD: failed to load ini %s\n", iniFile.c_str());
|
||||||
PADSaveConfig(); //save and return
|
PADSaveConfig(); //save and return
|
||||||
return;
|
return;
|
||||||
|
@ -109,7 +111,8 @@ void PADLoadConfig()
|
||||||
u32 pad;
|
u32 pad;
|
||||||
u32 keysym;
|
u32 keysym;
|
||||||
u32 index;
|
u32 index;
|
||||||
while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) == 3) {
|
while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) == 3)
|
||||||
|
{
|
||||||
set_keyboard_key(pad & 1, keysym, index);
|
set_keyboard_key(pad & 1, keysym, index);
|
||||||
if (pad == 0)
|
if (pad == 0)
|
||||||
have_user_setting = true;
|
have_user_setting = true;
|
||||||
|
|
|
@ -28,20 +28,23 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char *KeysymToChar(int keysym)
|
char* KeysymToChar(int keysym)
|
||||||
{
|
{
|
||||||
LPWORD temp;
|
LPWORD temp;
|
||||||
|
|
||||||
ToAscii((UINT)keysym, NULL, NULL, temp, NULL);
|
ToAscii((UINT)keysym, NULL, NULL, temp, NULL);
|
||||||
return (char *)temp;
|
return (char*)temp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// g_key_status.press but with proper handling for analog buttons
|
/// g_key_status.press but with proper handling for analog buttons
|
||||||
static void PressButton(u32 pad, u32 button) {
|
static void PressButton(u32 pad, u32 button)
|
||||||
|
{
|
||||||
// Analog controls.
|
// Analog controls.
|
||||||
if (IsAnalogKey(button)) {
|
if (IsAnalogKey(button))
|
||||||
switch (button) {
|
{
|
||||||
|
switch (button)
|
||||||
|
{
|
||||||
case PAD_R_LEFT:
|
case PAD_R_LEFT:
|
||||||
case PAD_R_UP:
|
case PAD_R_UP:
|
||||||
case PAD_L_LEFT:
|
case PAD_L_LEFT:
|
||||||
|
@ -55,7 +58,9 @@ static void PressButton(u32 pad, u32 button) {
|
||||||
g_key_status.press(pad, button, MAX_ANALOG_VALUE);
|
g_key_status.press(pad, button, MAX_ANALOG_VALUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
g_key_status.press(pad, button);
|
g_key_status.press(pad, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,36 +74,49 @@ static void PressButton(u32 pad, u32 button) {
|
||||||
// Keyboard keys use discriminator 0
|
// Keyboard keys use discriminator 0
|
||||||
// Mouse buttons use discriminator 1
|
// Mouse buttons use discriminator 1
|
||||||
|
|
||||||
void UpdateKeyboardInput() {
|
void UpdateKeyboardInput()
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
{
|
||||||
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
|
{
|
||||||
const auto& map = g_conf.keysym_map[pad];
|
const auto& map = g_conf.keysym_map[pad];
|
||||||
// If we loop over all keys press/release based on current state,
|
// If we loop over all keys press/release based on current state,
|
||||||
// joystick axes (which have two bound keys) will always go to the later-polled key
|
// joystick axes (which have two bound keys) will always go to the later-polled key
|
||||||
// Instead, release all keys first and then set the ones that are pressed
|
// Instead, release all keys first and then set the ones that are pressed
|
||||||
for (const auto& key : map) g_key_status.release(pad, key.second);
|
for (const auto& key : map)
|
||||||
for (const auto& key : map) {
|
g_key_status.release(pad, key.second);
|
||||||
|
for (const auto& key : map)
|
||||||
|
{
|
||||||
bool state;
|
bool state;
|
||||||
if (key.first >> 16 == 0) {
|
if (key.first >> 16 == 0)
|
||||||
|
{
|
||||||
state = CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, key.first);
|
state = CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, key.first);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
state = CGEventSourceButtonState(kCGEventSourceStateHIDSystemState, (CGMouseButton)(key.first & 0xFFFF));
|
state = CGEventSourceButtonState(kCGEventSourceStateHIDSystemState, (CGMouseButton)(key.first & 0xFFFF));
|
||||||
}
|
}
|
||||||
if (state) PressButton(pad, key.second);
|
if (state)
|
||||||
|
PressButton(pad, key.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PollForNewKeyboardKeys(u32 &pkey) {
|
bool PollForNewKeyboardKeys(u32& pkey)
|
||||||
|
{
|
||||||
// All keycodes in <HIToolbox/Events.h> are 0x7e or lower. If you notice
|
// All keycodes in <HIToolbox/Events.h> are 0x7e or lower. If you notice
|
||||||
// keys that aren't being recognized, bump this number up!
|
// keys that aren't being recognized, bump this number up!
|
||||||
for (int key = 0; key < 0x80; key++) {
|
for (int key = 0; key < 0x80; key++)
|
||||||
if (CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, key)) {
|
{
|
||||||
|
if (CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, key))
|
||||||
|
{
|
||||||
pkey = key == kVK_Escape ? 0 : key;
|
pkey = key == kVK_Escape ? 0 : key;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto btn : {kCGMouseButtonLeft, kCGMouseButtonCenter, kCGMouseButtonRight}) {
|
for (auto btn : {kCGMouseButtonLeft, kCGMouseButtonCenter, kCGMouseButtonRight})
|
||||||
if (CGEventSourceButtonState(kCGEventSourceStateHIDSystemState, btn)) {
|
{
|
||||||
|
if (CGEventSourceButtonState(kCGEventSourceStateHIDSystemState, btn))
|
||||||
|
{
|
||||||
pkey = btn | (1 << 16);
|
pkey = btn | (1 << 16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -111,21 +129,24 @@ static bool s_Shift = false;
|
||||||
static unsigned int s_previous_mouse_x = 0;
|
static unsigned int s_previous_mouse_x = 0;
|
||||||
static unsigned int s_previous_mouse_y = 0;
|
static unsigned int s_previous_mouse_y = 0;
|
||||||
|
|
||||||
void AnalyzeKeyEvent(keyEvent &evt)
|
void AnalyzeKeyEvent(keyEvent& evt)
|
||||||
{
|
{
|
||||||
KeySym key = (KeySym)evt.key;
|
KeySym key = (KeySym)evt.key;
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
|
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++)
|
||||||
|
{
|
||||||
int tmp_index = get_keyboard_key(cpad, key);
|
int tmp_index = get_keyboard_key(cpad, key);
|
||||||
if (tmp_index != -1) {
|
if (tmp_index != -1)
|
||||||
|
{
|
||||||
pad = cpad;
|
pad = cpad;
|
||||||
index = tmp_index;
|
index = tmp_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (evt.evt) {
|
switch (evt.evt)
|
||||||
|
{
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
// Shift F12 is not yet use by pcsx2. So keep it to grab/ungrab input
|
// Shift F12 is not yet use by pcsx2. So keep it to grab/ungrab input
|
||||||
// I found it very handy vs the automatic fullscreen detection
|
// I found it very handy vs the automatic fullscreen detection
|
||||||
|
@ -134,12 +155,16 @@ void AnalyzeKeyEvent(keyEvent &evt)
|
||||||
// 3/ Can grab input in window without the need of a pixelated full-screen
|
// 3/ Can grab input in window without the need of a pixelated full-screen
|
||||||
if (key == XK_Shift_R || key == XK_Shift_L)
|
if (key == XK_Shift_R || key == XK_Shift_L)
|
||||||
s_Shift = true;
|
s_Shift = true;
|
||||||
if (key == XK_F12 && s_Shift) {
|
if (key == XK_F12 && s_Shift)
|
||||||
if (!s_grab_input) {
|
{
|
||||||
|
if (!s_grab_input)
|
||||||
|
{
|
||||||
s_grab_input = true;
|
s_grab_input = true;
|
||||||
XGrabPointer(GSdsp, GSwin, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, GSwin, None, CurrentTime);
|
XGrabPointer(GSdsp, GSwin, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, GSwin, None, CurrentTime);
|
||||||
XGrabKeyboard(GSdsp, GSwin, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
XGrabKeyboard(GSdsp, GSwin, True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s_grab_input = false;
|
s_grab_input = false;
|
||||||
XUngrabPointer(GSdsp, CurrentTime);
|
XUngrabPointer(GSdsp, CurrentTime);
|
||||||
XUngrabKeyboard(GSdsp, CurrentTime);
|
XUngrabKeyboard(GSdsp, CurrentTime);
|
||||||
|
@ -188,14 +213,18 @@ void AnalyzeKeyEvent(keyEvent &evt)
|
||||||
// 1/ small move == no move. Cons : can not do small movement
|
// 1/ small move == no move. Cons : can not do small movement
|
||||||
// 2/ use a watchdog timer thread
|
// 2/ use a watchdog timer thread
|
||||||
// 3/ ??? idea welcome ;)
|
// 3/ ??? idea welcome ;)
|
||||||
if (g_conf.pad_options[pad].mouse_l | g_conf.pad_options[pad].mouse_r) {
|
if (g_conf.pad_options[pad].mouse_l | g_conf.pad_options[pad].mouse_r)
|
||||||
|
{
|
||||||
unsigned int pad_x;
|
unsigned int pad_x;
|
||||||
unsigned int pad_y;
|
unsigned int pad_y;
|
||||||
// Note when both PADOPTION_MOUSE_R and PADOPTION_MOUSE_L are set, take only the right one
|
// Note when both PADOPTION_MOUSE_R and PADOPTION_MOUSE_L are set, take only the right one
|
||||||
if (g_conf.pad_options[pad].mouse_r) {
|
if (g_conf.pad_options[pad].mouse_r)
|
||||||
|
{
|
||||||
pad_x = PAD_R_RIGHT;
|
pad_x = PAD_R_RIGHT;
|
||||||
pad_y = PAD_R_UP;
|
pad_y = PAD_R_UP;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pad_x = PAD_L_RIGHT;
|
pad_x = PAD_L_RIGHT;
|
||||||
pad_y = PAD_L_UP;
|
pad_y = PAD_L_UP;
|
||||||
}
|
}
|
||||||
|
@ -248,13 +277,15 @@ void UpdateKeyboardInput()
|
||||||
g_ev_fifo.consume_all(AnalyzeKeyEvent);
|
g_ev_fifo.consume_all(AnalyzeKeyEvent);
|
||||||
|
|
||||||
// keyboard input
|
// keyboard input
|
||||||
while (XPending(GSdsp) > 0) {
|
while (XPending(GSdsp) > 0)
|
||||||
|
{
|
||||||
XNextEvent(GSdsp, &E);
|
XNextEvent(GSdsp, &E);
|
||||||
|
|
||||||
// Change the format of the structure to be compatible with GSOpen2
|
// Change the format of the structure to be compatible with GSOpen2
|
||||||
// mode (event come from pcsx2 not X)
|
// mode (event come from pcsx2 not X)
|
||||||
evt.evt = E.type;
|
evt.evt = E.type;
|
||||||
switch (E.type) {
|
switch (E.type)
|
||||||
|
{
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
|
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
|
||||||
break;
|
break;
|
||||||
|
@ -270,15 +301,19 @@ void UpdateKeyboardInput()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PollForNewKeyboardKeys(u32 &pkey)
|
bool PollForNewKeyboardKeys(u32& pkey)
|
||||||
{
|
{
|
||||||
GdkEvent *ev = gdk_event_get();
|
GdkEvent* ev = gdk_event_get();
|
||||||
|
|
||||||
if (ev != NULL) {
|
if (ev != NULL)
|
||||||
if (ev->type == GDK_KEY_PRESS) {
|
{
|
||||||
|
if (ev->type == GDK_KEY_PRESS)
|
||||||
|
{
|
||||||
pkey = ev->key.keyval != GDK_KEY_Escape ? ev->key.keyval : 0;
|
pkey = ev->key.keyval != GDK_KEY_Escape ? ev->key.keyval : 0;
|
||||||
return true;
|
return true;
|
||||||
} else if (ev->type == GDK_BUTTON_PRESS) {
|
}
|
||||||
|
else if (ev->type == GDK_BUTTON_PRESS)
|
||||||
|
{
|
||||||
pkey = ev->button.button;
|
pkey = ev->button.button;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -296,13 +331,16 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
g_key_status.keyboard_state_acces(pad);
|
g_key_status.keyboard_state_acces(pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg)
|
||||||
|
{
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
if (lParam & 0x40000000)
|
if (lParam & 0x40000000)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
|
||||||
for (int i = 0; i < MAX_KEYS; i++) {
|
{
|
||||||
|
for (int i = 0; i < MAX_KEYS; i++)
|
||||||
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
#if 0
|
#if 0
|
||||||
if (wParam == get_key(pad, i)) {
|
if (wParam == get_key(pad, i)) {
|
||||||
|
@ -318,8 +356,10 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
|
||||||
for (int i = 0; i < MAX_KEYS; i++) {
|
{
|
||||||
|
for (int i = 0; i < MAX_KEYS; i++)
|
||||||
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
#if 0
|
#if 0
|
||||||
if (wParam == get_key(pad, i)) {
|
if (wParam == get_key(pad, i)) {
|
||||||
|
|
|
@ -24,17 +24,17 @@
|
||||||
|
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
|
|
||||||
extern void AnalyzeKeyEvent(keyEvent &evt);
|
extern void AnalyzeKeyEvent(keyEvent& evt);
|
||||||
extern void UpdateKeyboardInput();
|
extern void UpdateKeyboardInput();
|
||||||
extern bool PollForNewKeyboardKeys(u32 &pkey);
|
extern bool PollForNewKeyboardKeys(u32& pkey);
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
extern Display *GSdsp;
|
extern Display* GSdsp;
|
||||||
extern Window GSwin;
|
extern Window GSwin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern char *KeysymToChar(int keysym);
|
extern char* KeysymToChar(int keysym);
|
||||||
extern WNDPROC GSwndProc;
|
extern WNDPROC GSwndProc;
|
||||||
extern HWND GShwnd;
|
extern HWND GShwnd;
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
#include "wx_dialog/dialog.h"
|
#include "wx_dialog/dialog.h"
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
Display *GSdsp;
|
Display* GSdsp;
|
||||||
Window GSwin;
|
Window GSwin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void SysMessage(const char *fmt, ...)
|
static void SysMessage(const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -43,11 +43,11 @@ static void SysMessage(const char *fmt, ...)
|
||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _PADopen(void *pDsp)
|
s32 _PADopen(void* pDsp)
|
||||||
{
|
{
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
GSdsp = *(Display **)pDsp;
|
GSdsp = *(Display**)pDsp;
|
||||||
GSwin = (Window) * (((u32 *)pDsp) + 1);
|
GSwin = (Window) * (((u32*)pDsp) + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -64,11 +64,12 @@ void PollForJoystickInput(int cpad)
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto &gamePad = s_vgamePad[index];
|
auto& gamePad = s_vgamePad[index];
|
||||||
|
|
||||||
gamePad->UpdateGamePadState();
|
gamePad->UpdateGamePadState();
|
||||||
|
|
||||||
for (int i = 0; i < MAX_KEYS; i++) {
|
for (int i = 0; i < MAX_KEYS; i++)
|
||||||
|
{
|
||||||
s32 value = gamePad->GetInput((gamePadValues)i);
|
s32 value = gamePad->GetInput((gamePadValues)i);
|
||||||
if (value != 0)
|
if (value != 0)
|
||||||
g_key_status.press(cpad, i, value);
|
g_key_status.press(cpad, i, value);
|
||||||
|
@ -85,7 +86,8 @@ void PADupdate(int pad)
|
||||||
// Emulate an user activity
|
// Emulate an user activity
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
count++;
|
count++;
|
||||||
if ((count & 0xFFF) == 0) {
|
if ((count & 0xFFF) == 0)
|
||||||
|
{
|
||||||
// 1 call every 4096 Vsync is enough
|
// 1 call every 4096 Vsync is enough
|
||||||
XResetScreenSaver(GSdsp);
|
XResetScreenSaver(GSdsp);
|
||||||
}
|
}
|
||||||
|
@ -96,13 +98,15 @@ void PADupdate(int pad)
|
||||||
|
|
||||||
// Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
|
// Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
|
||||||
// So we will populate both pad in the same time
|
// So we will populate both pad in the same time
|
||||||
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
|
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++)
|
||||||
|
{
|
||||||
g_key_status.keyboard_state_acces(cpad);
|
g_key_status.keyboard_state_acces(cpad);
|
||||||
}
|
}
|
||||||
UpdateKeyboardInput();
|
UpdateKeyboardInput();
|
||||||
|
|
||||||
// Get joystick state + Commit
|
// Get joystick state + Commit
|
||||||
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
|
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++)
|
||||||
|
{
|
||||||
g_key_status.joystick_state_acces(cpad);
|
g_key_status.joystick_state_acces(cpad);
|
||||||
|
|
||||||
PollForJoystickInput(cpad);
|
PollForJoystickInput(cpad);
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
|
#if defined(__ELF__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
|
||||||
# define SECTION __attribute__ ((section (".gresource.PAD_res"), aligned (8)))
|
#define SECTION __attribute__((section(".gresource.PAD_res"), aligned(8)))
|
||||||
#else
|
#else
|
||||||
# define SECTION
|
#define SECTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
static const SECTION union { const guint8 data[134558]; const double alignment; void * const ptr;} PAD_res_resource_data = { {
|
static const SECTION union
|
||||||
0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
|
{
|
||||||
|
const guint8 data[134558];
|
||||||
|
const double alignment;
|
||||||
|
void* const ptr;
|
||||||
|
} PAD_res_resource_data = {{0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
|
||||||
0030, 0000, 0000, 0000, 0220, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0004, 0000, 0000, 0000,
|
0030, 0000, 0000, 0000, 0220, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0004, 0000, 0000, 0000,
|
||||||
0000, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0004, 0000, 0000, 0000, 0004, 0000, 0000, 0000,
|
0000, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0004, 0000, 0000, 0000, 0004, 0000, 0000, 0000,
|
||||||
0230, 0173, 0176, 0013, 0001, 0000, 0000, 0000, 0220, 0000, 0000, 0000, 0004, 0000, 0114, 0000,
|
0230, 0173, 0176, 0013, 0001, 0000, 0000, 0000, 0220, 0000, 0000, 0000, 0004, 0000, 0114, 0000,
|
||||||
|
@ -8417,10 +8421,14 @@ static const SECTION union { const guint8 data[134558]; const double alignment;
|
||||||
0147, 0150, 0164, 0170, 0072, 0141, 0062, 0054, 0162, 0151, 0147, 0150, 0164, 0171, 0072, 0141,
|
0147, 0150, 0164, 0170, 0072, 0141, 0062, 0054, 0162, 0151, 0147, 0150, 0164, 0171, 0072, 0141,
|
||||||
0065, 0054, 0163, 0164, 0141, 0162, 0164, 0072, 0142, 0071, 0054, 0170, 0072, 0142, 0060, 0054,
|
0065, 0054, 0163, 0164, 0141, 0162, 0164, 0072, 0142, 0071, 0054, 0170, 0072, 0142, 0060, 0054,
|
||||||
0171, 0072, 0142, 0063, 0054, 0160, 0154, 0141, 0164, 0146, 0157, 0162, 0155, 0072, 0114, 0151,
|
0171, 0072, 0142, 0063, 0054, 0160, 0154, 0141, 0164, 0146, 0157, 0162, 0155, 0072, 0114, 0151,
|
||||||
0156, 0165, 0170, 0054, 0012, 0000, 0000, 0050, 0165, 0165, 0141, 0171, 0051
|
0156, 0165, 0170, 0054, 0012, 0000, 0000, 0050, 0165, 0165, 0141, 0171, 0051}};
|
||||||
} };
|
|
||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
static const SECTION union { const guint8 data[134558]; const double alignment; void * const ptr;} PAD_res_resource_data = {
|
static const SECTION union
|
||||||
|
{
|
||||||
|
const guint8 data[134558];
|
||||||
|
const double alignment;
|
||||||
|
void* const ptr;
|
||||||
|
} PAD_res_resource_data = {
|
||||||
"\107\126\141\162\151\141\156\164\000\000\000\000\000\000\000\000"
|
"\107\126\141\162\151\141\156\164\000\000\000\000\000\000\000\000"
|
||||||
"\030\000\000\000\220\000\000\000\000\000\000\050\004\000\000\000"
|
"\030\000\000\000\220\000\000\000\000\000\000\050\004\000\000\000"
|
||||||
"\000\000\000\000\002\000\000\000\004\000\000\000\004\000\000\000"
|
"\000\000\000\000\002\000\000\000\004\000\000\000\004\000\000\000"
|
||||||
|
@ -16830,16 +16838,16 @@ static const SECTION union { const guint8 data[134558]; const double alignment;
|
||||||
"\147\150\164\170\072\141\062\054\162\151\147\150\164\171\072\141"
|
"\147\150\164\170\072\141\062\054\162\151\147\150\164\171\072\141"
|
||||||
"\065\054\163\164\141\162\164\072\142\071\054\170\072\142\060\054"
|
"\065\054\163\164\141\162\164\072\142\071\054\170\072\142\060\054"
|
||||||
"\171\072\142\063\054\160\154\141\164\146\157\162\155\072\114\151"
|
"\171\072\142\063\054\160\154\141\164\146\157\162\155\072\114\151"
|
||||||
"\156\165\170\054\012\000\000\050\165\165\141\171\051" };
|
"\156\165\170\054\012\000\000\050\165\165\141\171\051"};
|
||||||
#endif /* !_MSC_VER */
|
#endif /* !_MSC_VER */
|
||||||
|
|
||||||
static GStaticResource static_resource = { PAD_res_resource_data.data, sizeof (PAD_res_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
|
static GStaticResource static_resource = {PAD_res_resource_data.data, sizeof(PAD_res_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL};
|
||||||
|
|
||||||
G_MODULE_EXPORT
|
G_MODULE_EXPORT
|
||||||
GResource *PAD_res_get_resource (void);
|
GResource* PAD_res_get_resource(void);
|
||||||
GResource *PAD_res_get_resource (void)
|
GResource* PAD_res_get_resource(void)
|
||||||
{
|
{
|
||||||
return g_static_resource_get_resource (&static_resource);
|
return g_static_resource_get_resource(&static_resource);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
|
If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
|
||||||
|
@ -16865,10 +16873,10 @@ GResource *PAD_res_get_resource (void)
|
||||||
|
|
||||||
#define G_HAS_CONSTRUCTORS 1
|
#define G_HAS_CONSTRUCTORS 1
|
||||||
|
|
||||||
#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
|
#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func(void);
|
||||||
#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
|
#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func(void);
|
||||||
|
|
||||||
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||||
/* Visual studio 2008 and later has _Pragma */
|
/* Visual studio 2008 and later has _Pragma */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -16894,26 +16902,34 @@ GResource *PAD_res_get_resource (void)
|
||||||
#define G_MSVC_SYMBOL_PREFIX ""
|
#define G_MSVC_SYMBOL_PREFIX ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
|
#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR(_func, G_MSVC_SYMBOL_PREFIX)
|
||||||
#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
|
#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR(_func, G_MSVC_SYMBOL_PREFIX)
|
||||||
|
|
||||||
#define G_MSVC_CTOR(_func,_sym_prefix) \
|
#define G_MSVC_CTOR(_func, _sym_prefix) \
|
||||||
static void _func(void); \
|
static void _func(void); \
|
||||||
extern int (* _array ## _func)(void); \
|
extern int (*_array##_func)(void); \
|
||||||
int _func ## _wrapper(void) { _func(); g_slist_find (NULL, _array ## _func); return 0; } \
|
int _func##_wrapper(void) \
|
||||||
__pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
|
{ \
|
||||||
__pragma(section(".CRT$XCU",read)) \
|
_func(); \
|
||||||
__declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
|
g_slist_find(NULL, _array##_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
__pragma(comment(linker, "/include:" _sym_prefix #_func "_wrapper")) \
|
||||||
|
__pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_wrapper;
|
||||||
|
|
||||||
#define G_MSVC_DTOR(_func,_sym_prefix) \
|
#define G_MSVC_DTOR(_func, _sym_prefix) \
|
||||||
static void _func(void); \
|
static void _func(void); \
|
||||||
extern int (* _array ## _func)(void); \
|
extern int (*_array##_func)(void); \
|
||||||
int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL, _array ## _func); return 0; } \
|
int _func##_constructor(void) \
|
||||||
__pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
|
{ \
|
||||||
__pragma(section(".CRT$XCU",read)) \
|
atexit(_func); \
|
||||||
__declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
|
g_slist_find(NULL, _array##_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
__pragma(comment(linker, "/include:" _sym_prefix #_func "_constructor")) \
|
||||||
|
__pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_constructor;
|
||||||
|
|
||||||
#elif defined (_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
|
||||||
#define G_HAS_CONSTRUCTORS 1
|
#define G_HAS_CONSTRUCTORS 1
|
||||||
|
|
||||||
|
@ -16922,18 +16938,26 @@ GResource *PAD_res_get_resource (void)
|
||||||
#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
|
#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
|
||||||
|
|
||||||
#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
|
#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
|
||||||
section(".CRT$XCU",read)
|
section(".CRT$XCU", read)
|
||||||
#define G_DEFINE_CONSTRUCTOR(_func) \
|
#define G_DEFINE_CONSTRUCTOR(_func) \
|
||||||
static void _func(void); \
|
static void _func(void); \
|
||||||
static int _func ## _wrapper(void) { _func(); return 0; } \
|
static int _func##_wrapper(void) \
|
||||||
__declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
|
{ \
|
||||||
|
_func(); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
__declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func##_wrapper;
|
||||||
|
|
||||||
#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
|
#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
|
||||||
section(".CRT$XCU",read)
|
section(".CRT$XCU", read)
|
||||||
#define G_DEFINE_DESTRUCTOR(_func) \
|
#define G_DEFINE_DESTRUCTOR(_func) \
|
||||||
static void _func(void); \
|
static void _func(void); \
|
||||||
static int _func ## _constructor(void) { atexit (_func); return 0; } \
|
static int _func##_constructor(void) \
|
||||||
__declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
|
{ \
|
||||||
|
atexit(_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
__declspec(allocate(".CRT$XCU")) static int (*_array##_func)(void) = _func##_constructor;
|
||||||
|
|
||||||
#elif defined(__SUNPRO_C)
|
#elif defined(__SUNPRO_C)
|
||||||
|
|
||||||
|
@ -16979,12 +17003,12 @@ G_DEFINE_DESTRUCTOR(resource_destructor)
|
||||||
#warning "Constructor not supported on this compiler, linking in resources will not work"
|
#warning "Constructor not supported on this compiler, linking in resources will not work"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void resource_constructor (void)
|
static void resource_constructor(void)
|
||||||
{
|
{
|
||||||
g_static_resource_init (&static_resource);
|
g_static_resource_init(&static_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resource_destructor (void)
|
static void resource_destructor(void)
|
||||||
{
|
{
|
||||||
g_static_resource_fini (&static_resource);
|
g_static_resource_fini(&static_resource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
extern GResource *PAD_res_get_resource (void);
|
extern GResource* PAD_res_get_resource(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,7 +53,8 @@ void QueryInfo::reset()
|
||||||
|
|
||||||
u8 QueryInfo::start_poll(int _port)
|
u8 QueryInfo::start_poll(int _port)
|
||||||
{
|
{
|
||||||
if (port > 1) {
|
if (port > 1)
|
||||||
|
{
|
||||||
reset();
|
reset();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -114,9 +115,11 @@ void Pad::reset()
|
||||||
|
|
||||||
void Pad::rumble(unsigned port)
|
void Pad::rumble(unsigned port)
|
||||||
{
|
{
|
||||||
for (unsigned motor = 0; motor < 2; motor++) {
|
for (unsigned motor = 0; motor < 2; motor++)
|
||||||
|
{
|
||||||
// TODO: Probably be better to send all of these at once.
|
// TODO: Probably be better to send all of these at once.
|
||||||
if (nextVibrate[motor] | currentVibrate[motor]) {
|
if (nextVibrate[motor] | currentVibrate[motor])
|
||||||
|
{
|
||||||
currentVibrate[motor] = nextVibrate[motor];
|
currentVibrate[motor] = nextVibrate[motor];
|
||||||
|
|
||||||
GamePad::DoRumble(motor, port);
|
GamePad::DoRumble(motor, port);
|
||||||
|
@ -174,29 +177,35 @@ u8 pad_start_poll(u8 pad)
|
||||||
|
|
||||||
u8 pad_poll(u8 value)
|
u8 pad_poll(u8 value)
|
||||||
{
|
{
|
||||||
if (query.lastByte + 1 >= query.numBytes) {
|
if (query.lastByte + 1 >= query.numBytes)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (query.lastByte && query.queryDone) {
|
if (query.lastByte && query.queryDone)
|
||||||
|
{
|
||||||
return query.response[++query.lastByte];
|
return query.response[++query.lastByte];
|
||||||
}
|
}
|
||||||
|
|
||||||
Pad *pad = &pads[query.port][query.slot];
|
Pad* pad = &pads[query.port][query.slot];
|
||||||
|
|
||||||
if (query.lastByte == 0) {
|
if (query.lastByte == 0)
|
||||||
|
{
|
||||||
query.lastByte++;
|
query.lastByte++;
|
||||||
query.currentCommand = value;
|
query.currentCommand = value;
|
||||||
|
|
||||||
switch (value) {
|
switch (value)
|
||||||
|
{
|
||||||
case CMD_CONFIG_MODE:
|
case CMD_CONFIG_MODE:
|
||||||
if (pad->config) {
|
if (pad->config)
|
||||||
|
{
|
||||||
// In config mode. Might not actually be leaving it.
|
// In config mode. Might not actually be leaving it.
|
||||||
query.set_result(ConfigExit);
|
query.set_result(ConfigExit);
|
||||||
return 0xF3;
|
return 0xF3;
|
||||||
}
|
}
|
||||||
[[fallthrough]]; // fallthrough on purpose (but I don't know why)
|
[[fallthrough]]; // fallthrough on purpose (but I don't know why)
|
||||||
|
|
||||||
case CMD_READ_DATA_AND_VIBRATE: {
|
case CMD_READ_DATA_AND_VIBRATE:
|
||||||
|
{
|
||||||
query.response[2] = 0x5A;
|
query.response[2] = 0x5A;
|
||||||
#if 0
|
#if 0
|
||||||
int i;
|
int i;
|
||||||
|
@ -241,7 +250,8 @@ u8 pad_poll(u8 value)
|
||||||
query.response[3] = (buttons >> 8) & 0xFF;
|
query.response[3] = (buttons >> 8) & 0xFF;
|
||||||
query.response[4] = (buttons >> 0) & 0xFF;
|
query.response[4] = (buttons >> 0) & 0xFF;
|
||||||
|
|
||||||
if (pad->mode != MODE_DIGITAL) { // ANALOG || DS2 native
|
if (pad->mode != MODE_DIGITAL)
|
||||||
|
{ // ANALOG || DS2 native
|
||||||
query.numBytes = 9;
|
query.numBytes = 9;
|
||||||
|
|
||||||
query.response[5] = g_key_status.get(query.port, PAD_R_RIGHT);
|
query.response[5] = g_key_status.get(query.port, PAD_R_RIGHT);
|
||||||
|
@ -249,7 +259,8 @@ u8 pad_poll(u8 value)
|
||||||
query.response[7] = g_key_status.get(query.port, PAD_L_RIGHT);
|
query.response[7] = g_key_status.get(query.port, PAD_L_RIGHT);
|
||||||
query.response[8] = g_key_status.get(query.port, PAD_L_UP);
|
query.response[8] = g_key_status.get(query.port, PAD_L_UP);
|
||||||
|
|
||||||
if (pad->mode != MODE_ANALOG) { // DS2 native
|
if (pad->mode != MODE_ANALOG)
|
||||||
|
{ // DS2 native
|
||||||
query.numBytes = 21;
|
query.numBytes = 21;
|
||||||
|
|
||||||
query.response[9] = !test_bit(buttons, 13) ? g_key_status.get(query.port, PAD_RIGHT) : 0;
|
query.response[9] = !test_bit(buttons, 13) ? g_key_status.get(query.port, PAD_RIGHT) : 0;
|
||||||
|
@ -314,10 +325,13 @@ u8 pad_poll(u8 value)
|
||||||
|
|
||||||
case CMD_QUERY_DS2_ANALOG_MODE:
|
case CMD_QUERY_DS2_ANALOG_MODE:
|
||||||
// Right? Wrong? No clue.
|
// Right? Wrong? No clue.
|
||||||
if (pad->mode == MODE_DIGITAL) {
|
if (pad->mode == MODE_DIGITAL)
|
||||||
|
{
|
||||||
queryMaskMode[1] = queryMaskMode[2] = queryMaskMode[3] = 0;
|
queryMaskMode[1] = queryMaskMode[2] = queryMaskMode[3] = 0;
|
||||||
queryMaskMode[6] = 0x00;
|
queryMaskMode[6] = 0x00;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
queryMaskMode[1] = pad->umask[0];
|
queryMaskMode[1] = pad->umask[0];
|
||||||
queryMaskMode[2] = pad->umask[1];
|
queryMaskMode[2] = pad->umask[1];
|
||||||
queryMaskMode[3] = 0x03;
|
queryMaskMode[3] = 0x03;
|
||||||
|
@ -334,9 +348,12 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_QUERY_MODEL_AND_MODE:
|
case CMD_QUERY_MODEL_AND_MODE:
|
||||||
if (IsDualshock2()) {
|
if (IsDualshock2())
|
||||||
|
{
|
||||||
query.set_final_result(queryModelDS2);
|
query.set_final_result(queryModelDS2);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
query.set_final_result(queryModelDS1);
|
query.set_final_result(queryModelDS1);
|
||||||
}
|
}
|
||||||
// Not digital mode.
|
// Not digital mode.
|
||||||
|
@ -363,9 +380,12 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_SET_DS2_NATIVE_MODE:
|
case CMD_SET_DS2_NATIVE_MODE:
|
||||||
if (IsDualshock2()) {
|
if (IsDualshock2())
|
||||||
|
{
|
||||||
query.set_result(setNativeMode);
|
query.set_result(setNativeMode);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
query.set_final_result(setNativeMode);
|
query.set_final_result(setNativeMode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -377,11 +397,13 @@ u8 pad_poll(u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0xF3;
|
return 0xF3;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
query.lastByte++;
|
query.lastByte++;
|
||||||
|
|
||||||
switch (query.currentCommand) {
|
switch (query.currentCommand)
|
||||||
|
{
|
||||||
case CMD_READ_DATA_AND_VIBRATE:
|
case CMD_READ_DATA_AND_VIBRATE:
|
||||||
if (query.lastByte == pad->vibrateI[0])
|
if (query.lastByte == pad->vibrateI[0])
|
||||||
pad->set_vibrate(1, 255 * (value & 1));
|
pad->set_vibrate(1, 255 * (value & 1));
|
||||||
|
@ -391,16 +413,20 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_CONFIG_MODE:
|
case CMD_CONFIG_MODE:
|
||||||
if (query.lastByte == 3) {
|
if (query.lastByte == 3)
|
||||||
|
{
|
||||||
query.queryDone = 1;
|
query.queryDone = 1;
|
||||||
pad->config = value;
|
pad->config = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_SET_MODE_AND_LOCK:
|
case CMD_SET_MODE_AND_LOCK:
|
||||||
if (query.lastByte == 3 && value < 2) {
|
if (query.lastByte == 3 && value < 2)
|
||||||
|
{
|
||||||
pad->set_mode(value ? MODE_ANALOG : MODE_DIGITAL);
|
pad->set_mode(value ? MODE_ANALOG : MODE_DIGITAL);
|
||||||
} else if (query.lastByte == 4) {
|
}
|
||||||
|
else if (query.lastByte == 4)
|
||||||
|
{
|
||||||
if (value == 3)
|
if (value == 3)
|
||||||
pad->modeLock = 3;
|
pad->modeLock = 3;
|
||||||
else
|
else
|
||||||
|
@ -411,7 +437,8 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_QUERY_ACT:
|
case CMD_QUERY_ACT:
|
||||||
if (query.lastByte == 3) {
|
if (query.lastByte == 3)
|
||||||
|
{
|
||||||
if (value < 2)
|
if (value < 2)
|
||||||
query.set_result(queryAct[value]);
|
query.set_result(queryAct[value]);
|
||||||
// bunch of 0's
|
// bunch of 0's
|
||||||
|
@ -421,7 +448,8 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_QUERY_MODE:
|
case CMD_QUERY_MODE:
|
||||||
if (query.lastByte == 3 && value < 2) {
|
if (query.lastByte == 3 && value < 2)
|
||||||
|
{
|
||||||
query.response[6] = 4 + value * 3;
|
query.response[6] = 4 + value * 3;
|
||||||
query.queryDone = 1;
|
query.queryDone = 1;
|
||||||
}
|
}
|
||||||
|
@ -430,10 +458,14 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_VIBRATION_TOGGLE:
|
case CMD_VIBRATION_TOGGLE:
|
||||||
if (query.lastByte >= 3) {
|
if (query.lastByte >= 3)
|
||||||
if (value == 0) {
|
{
|
||||||
|
if (value == 0)
|
||||||
|
{
|
||||||
pad->vibrateI[0] = (u8)query.lastByte;
|
pad->vibrateI[0] = (u8)query.lastByte;
|
||||||
} else if (value == 1) {
|
}
|
||||||
|
else if (value == 1)
|
||||||
|
{
|
||||||
pad->vibrateI[1] = (u8)query.lastByte;
|
pad->vibrateI[1] = (u8)query.lastByte;
|
||||||
}
|
}
|
||||||
pad->vibrate[query.lastByte - 2] = value;
|
pad->vibrate[query.lastByte - 2] = value;
|
||||||
|
@ -441,9 +473,12 @@ u8 pad_poll(u8 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_SET_DS2_NATIVE_MODE:
|
case CMD_SET_DS2_NATIVE_MODE:
|
||||||
if (query.lastByte == 3 || query.lastByte == 4) {
|
if (query.lastByte == 3 || query.lastByte == 4)
|
||||||
|
{
|
||||||
pad->umask[query.lastByte - 3] = value;
|
pad->umask[query.lastByte - 3] = value;
|
||||||
} else if (query.lastByte == 5) {
|
}
|
||||||
|
else if (query.lastByte == 5)
|
||||||
|
{
|
||||||
if (!(value & 1))
|
if (!(value & 1))
|
||||||
pad->set_mode(MODE_DIGITAL);
|
pad->set_mode(MODE_DIGITAL);
|
||||||
else if (!(value & 2))
|
else if (!(value & 2))
|
||||||
|
|
|
@ -15,27 +15,28 @@
|
||||||
|
|
||||||
#include "GamepadConfiguration.h"
|
#include "GamepadConfiguration.h"
|
||||||
|
|
||||||
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
|
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow* parent)
|
||||||
: wxDialog(parent, wxID_ANY, _T("Gamepad"), wxDefaultPosition, wxDefaultSize,
|
: wxDialog(parent, wxID_ANY, _T("Gamepad"), wxDefaultPosition, wxDefaultSize,
|
||||||
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
||||||
{
|
{
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
|
|
||||||
wxBoxSizer *gamepad_box = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* gamepad_box = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
for (const auto &j : s_vgamePad) {
|
for (const auto& j : s_vgamePad)
|
||||||
|
{
|
||||||
choices.Add(j->GetName());
|
choices.Add(j->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_joy_map = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
|
m_joy_map = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
|
||||||
m_cb_rumble = new wxCheckBox(this, enable_rumble_id, _T("&Enable rumble"));
|
m_cb_rumble = new wxCheckBox(this, enable_rumble_id, _T("&Enable rumble"));
|
||||||
|
|
||||||
wxStaticBoxSizer *rumble_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Rumble intensity"));
|
wxStaticBoxSizer* rumble_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Rumble intensity"));
|
||||||
m_sl_rumble_intensity = new wxSlider(this, rumble_slider_id, 0, 0, 0x7FFF, wxDefaultPosition, wxDefaultSize,
|
m_sl_rumble_intensity = new wxSlider(this, rumble_slider_id, 0, 0, 0x7FFF, wxDefaultPosition, wxDefaultSize,
|
||||||
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
||||||
|
|
||||||
wxStaticBoxSizer *joy_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Joystick sensibility"));
|
wxStaticBoxSizer* joy_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Joystick sensibility"));
|
||||||
m_sl_joystick_sensibility = new wxSlider(this, joy_slider_id, 0, 0, 200, wxDefaultPosition, wxDefaultSize,
|
m_sl_joystick_sensibility = new wxSlider(this, joy_slider_id, 0, 0, 200, wxDefaultPosition, wxDefaultSize,
|
||||||
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
||||||
|
|
||||||
|
@ -74,7 +75,8 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
* if the pad id is 1, you need at least 2 gamepads connected,
|
* if the pad id is 1, you need at least 2 gamepads connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if (s_vgamePad.size() >= m_pad_id + 1) {
|
if (s_vgamePad.size() >= m_pad_id + 1)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Determine if the device can use rumble
|
* Determine if the device can use rumble
|
||||||
* Use TestForce with a very low strength (can't be felt)
|
* Use TestForce with a very low strength (can't be felt)
|
||||||
|
@ -87,7 +89,9 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
// m_cb_rumble->Disable(); // disable the rumble checkbox
|
// m_cb_rumble->Disable(); // disable the rumble checkbox
|
||||||
// m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
// m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
||||||
// }
|
// }
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
wxMessageBox(L"No gamepad detected.");
|
wxMessageBox(L"No gamepad detected.");
|
||||||
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
|
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
|
||||||
m_cb_rumble->Disable(); // disable the rumble checkbox
|
m_cb_rumble->Disable(); // disable the rumble checkbox
|
||||||
|
@ -95,7 +99,7 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadConfiguration::OnOk(wxCommandEvent &event)
|
void GamepadConfiguration::OnOk(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
@ -105,9 +109,9 @@ void GamepadConfiguration::OnOk(wxCommandEvent &event)
|
||||||
* @FIXME The current solution can't change the joystick sensibility and the rumble intensity
|
* @FIXME The current solution can't change the joystick sensibility and the rumble intensity
|
||||||
* for a specific gamepad. The same value is used for both
|
* for a specific gamepad. The same value is used for both
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
void GamepadConfiguration::OnSliderReleased(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxSlider *sl_tmp = (wxSlider *)event.GetEventObject();
|
wxSlider* sl_tmp = (wxSlider*)event.GetEventObject();
|
||||||
int sl_id = sl_tmp->GetId();
|
int sl_id = sl_tmp->GetId();
|
||||||
|
|
||||||
if (sl_id == rumble_slider_id)
|
if (sl_id == rumble_slider_id)
|
||||||
|
@ -127,9 +131,9 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
||||||
/**
|
/**
|
||||||
* Checkbox event, called when the value of the checkbox change
|
* Checkbox event, called when the value of the checkbox change
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
wxCheckBox* cb_tmp = (wxCheckBox*)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
|
|
||||||
if (cb_id == enable_rumble_id)
|
if (cb_id == enable_rumble_id)
|
||||||
|
@ -150,9 +154,9 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
/*
|
/*
|
||||||
* Checkbox event, called when the value of the choice box change
|
* Checkbox event, called when the value of the choice box change
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnChoiceChange(wxCommandEvent &event)
|
void GamepadConfiguration::OnChoiceChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxChoice *choice_tmp = (wxChoice *)event.GetEventObject();
|
wxChoice* choice_tmp = (wxChoice*)event.GetEventObject();
|
||||||
int id = choice_tmp->GetSelection();
|
int id = choice_tmp->GetSelection();
|
||||||
if (id != wxNOT_FOUND)
|
if (id != wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,9 +30,9 @@ static const s32 enable_rumble_id = wxID_HIGHEST + 200 + 3;
|
||||||
|
|
||||||
class GamepadConfiguration : public wxDialog
|
class GamepadConfiguration : public wxDialog
|
||||||
{
|
{
|
||||||
wxCheckBox *m_cb_rumble;
|
wxCheckBox* m_cb_rumble;
|
||||||
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
||||||
wxChoice *m_joy_map;
|
wxChoice* m_joy_map;
|
||||||
|
|
||||||
u32 m_pad_id;
|
u32 m_pad_id;
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ class GamepadConfiguration : public wxDialog
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnOk(wxCommandEvent &);
|
void OnOk(wxCommandEvent&);
|
||||||
void OnSliderReleased(wxCommandEvent &);
|
void OnSliderReleased(wxCommandEvent&);
|
||||||
void OnCheckboxChange(wxCommandEvent &);
|
void OnCheckboxChange(wxCommandEvent&);
|
||||||
void OnChoiceChange(wxCommandEvent &);
|
void OnChoiceChange(wxCommandEvent&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GamepadConfiguration(int, wxWindow *);
|
GamepadConfiguration(int, wxWindow*);
|
||||||
void InitGamepadConfiguration();
|
void InitGamepadConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "JoystickConfiguration.h"
|
#include "JoystickConfiguration.h"
|
||||||
|
|
||||||
// Constructor of JoystickConfiguration
|
// Constructor of JoystickConfiguration
|
||||||
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent)
|
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow* parent)
|
||||||
: wxDialog(parent, wxID_ANY, _T("Joystick configuration"), wxDefaultPosition, wxDefaultSize,
|
: wxDialog(parent, wxID_ANY, _T("Joystick configuration"), wxDefaultPosition, wxDefaultSize,
|
||||||
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
m_isForLeftJoystick = left;
|
m_isForLeftJoystick = left;
|
||||||
|
|
||||||
wxBoxSizer *joy_conf_box = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* joy_conf_box = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
if (m_isForLeftJoystick)
|
if (m_isForLeftJoystick)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,6 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren
|
||||||
joy_conf_box->Add(m_cb_mouse_Ljoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
joy_conf_box->Add(m_cb_mouse_Ljoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
|
|
||||||
m_cb_reverse_Rx = m_cb_reverse_Ry = m_cb_mouse_Rjoy = nullptr;
|
m_cb_reverse_Rx = m_cb_reverse_Ry = m_cb_mouse_Rjoy = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -77,7 +76,8 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
* if the pad id is 1, you need at least 2 gamepads connected,
|
* if the pad id is 1, you need at least 2 gamepads connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if (s_vgamePad.size() < m_pad_id + 1) {
|
if (s_vgamePad.size() < m_pad_id + 1)
|
||||||
|
{
|
||||||
if (s_vgamePad.empty())
|
if (s_vgamePad.empty())
|
||||||
wxMessageBox(L"No gamepad detected.");
|
wxMessageBox(L"No gamepad detected.");
|
||||||
else
|
else
|
||||||
|
@ -97,12 +97,12 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoystickConfiguration::OnOk(wxCommandEvent &event)
|
void JoystickConfiguration::OnOk(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoystickConfiguration::OnCancel(wxCommandEvent &event)
|
void JoystickConfiguration::OnCancel(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
Destroy();
|
Destroy();
|
||||||
|
@ -111,9 +111,9 @@ void JoystickConfiguration::OnCancel(wxCommandEvent &event)
|
||||||
/**
|
/**
|
||||||
* Checkbox event, called when the value of the checkbox change
|
* Checkbox event, called when the value of the checkbox change
|
||||||
*/
|
*/
|
||||||
void JoystickConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
wxCheckBox* cb_tmp = (wxCheckBox*)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
|
|
||||||
if (m_isForLeftJoystick)
|
if (m_isForLeftJoystick)
|
||||||
|
|
|
@ -48,12 +48,12 @@ class JoystickConfiguration : public wxDialog
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnCheckboxChange(wxCommandEvent &);
|
void OnCheckboxChange(wxCommandEvent&);
|
||||||
void OnOk(wxCommandEvent &);
|
void OnOk(wxCommandEvent&);
|
||||||
void OnCancel(wxCommandEvent &);
|
void OnCancel(wxCommandEvent&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JoystickConfiguration(int, bool, wxWindow *);
|
JoystickConfiguration(int, bool, wxWindow*);
|
||||||
void InitJoystickConfiguration();
|
void InitJoystickConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
static std::string KeyName(int pad, int key, int keysym)
|
static std::string KeyName(int pad, int key, int keysym)
|
||||||
{
|
{
|
||||||
// Mouse
|
// Mouse
|
||||||
if (keysym >> 16) {
|
if (keysym >> 16)
|
||||||
switch (keysym & 0xFFFF) {
|
{
|
||||||
|
switch (keysym & 0xFFFF)
|
||||||
|
{
|
||||||
case kCGMouseButtonLeft:
|
case kCGMouseButtonLeft:
|
||||||
return "Mouse Left";
|
return "Mouse Left";
|
||||||
case kCGMouseButtonRight:
|
case kCGMouseButtonRight:
|
||||||
|
@ -34,135 +36,258 @@ static std::string KeyName(int pad, int key, int keysym)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (keysym) {
|
switch (keysym)
|
||||||
case kVK_ANSI_A: return "A";
|
{
|
||||||
case kVK_ANSI_B: return "B";
|
case kVK_ANSI_A:
|
||||||
case kVK_ANSI_C: return "C";
|
return "A";
|
||||||
case kVK_ANSI_D: return "D";
|
case kVK_ANSI_B:
|
||||||
case kVK_ANSI_E: return "E";
|
return "B";
|
||||||
case kVK_ANSI_F: return "F";
|
case kVK_ANSI_C:
|
||||||
case kVK_ANSI_G: return "G";
|
return "C";
|
||||||
case kVK_ANSI_H: return "H";
|
case kVK_ANSI_D:
|
||||||
case kVK_ANSI_I: return "I";
|
return "D";
|
||||||
case kVK_ANSI_J: return "J";
|
case kVK_ANSI_E:
|
||||||
case kVK_ANSI_K: return "K";
|
return "E";
|
||||||
case kVK_ANSI_L: return "L";
|
case kVK_ANSI_F:
|
||||||
case kVK_ANSI_M: return "M";
|
return "F";
|
||||||
case kVK_ANSI_N: return "N";
|
case kVK_ANSI_G:
|
||||||
case kVK_ANSI_O: return "O";
|
return "G";
|
||||||
case kVK_ANSI_P: return "P";
|
case kVK_ANSI_H:
|
||||||
case kVK_ANSI_Q: return "Q";
|
return "H";
|
||||||
case kVK_ANSI_R: return "R";
|
case kVK_ANSI_I:
|
||||||
case kVK_ANSI_S: return "S";
|
return "I";
|
||||||
case kVK_ANSI_T: return "T";
|
case kVK_ANSI_J:
|
||||||
case kVK_ANSI_U: return "U";
|
return "J";
|
||||||
case kVK_ANSI_V: return "V";
|
case kVK_ANSI_K:
|
||||||
case kVK_ANSI_W: return "W";
|
return "K";
|
||||||
case kVK_ANSI_X: return "X";
|
case kVK_ANSI_L:
|
||||||
case kVK_ANSI_Y: return "Y";
|
return "L";
|
||||||
case kVK_ANSI_Z: return "Z";
|
case kVK_ANSI_M:
|
||||||
case kVK_ANSI_0: return "0";
|
return "M";
|
||||||
case kVK_ANSI_1: return "1";
|
case kVK_ANSI_N:
|
||||||
case kVK_ANSI_2: return "2";
|
return "N";
|
||||||
case kVK_ANSI_3: return "3";
|
case kVK_ANSI_O:
|
||||||
case kVK_ANSI_4: return "4";
|
return "O";
|
||||||
case kVK_ANSI_5: return "5";
|
case kVK_ANSI_P:
|
||||||
case kVK_ANSI_6: return "6";
|
return "P";
|
||||||
case kVK_ANSI_7: return "7";
|
case kVK_ANSI_Q:
|
||||||
case kVK_ANSI_8: return "8";
|
return "Q";
|
||||||
case kVK_ANSI_9: return "9";
|
case kVK_ANSI_R:
|
||||||
case kVK_ANSI_Grave: return "`";
|
return "R";
|
||||||
case kVK_ANSI_Minus: return "-";
|
case kVK_ANSI_S:
|
||||||
case kVK_ANSI_Equal: return "=";
|
return "S";
|
||||||
case kVK_ANSI_LeftBracket: return "[";
|
case kVK_ANSI_T:
|
||||||
case kVK_ANSI_RightBracket: return "]";
|
return "T";
|
||||||
case kVK_ANSI_Backslash: return "\\";
|
case kVK_ANSI_U:
|
||||||
case kVK_ANSI_Semicolon: return ";";
|
return "U";
|
||||||
case kVK_ANSI_Quote: return "'";
|
case kVK_ANSI_V:
|
||||||
case kVK_ANSI_Comma: return ",";
|
return "V";
|
||||||
case kVK_ANSI_Period: return ".";
|
case kVK_ANSI_W:
|
||||||
case kVK_ANSI_Slash: return "/";
|
return "W";
|
||||||
case kVK_Escape: return "⎋";
|
case kVK_ANSI_X:
|
||||||
case kVK_Tab: return "⇥";
|
return "X";
|
||||||
case kVK_Delete: return "⌫";
|
case kVK_ANSI_Y:
|
||||||
case kVK_ForwardDelete: return "⌦";
|
return "Y";
|
||||||
case kVK_Return: return "↩";
|
case kVK_ANSI_Z:
|
||||||
case kVK_Space: return "␣";
|
return "Z";
|
||||||
case kVK_ANSI_KeypadDecimal: return "Keypad .";
|
case kVK_ANSI_0:
|
||||||
case kVK_ANSI_KeypadMultiply: return "Keypad *";
|
return "0";
|
||||||
case kVK_ANSI_KeypadPlus: return "Keypad +";
|
case kVK_ANSI_1:
|
||||||
case kVK_ANSI_KeypadClear: return "⌧";
|
return "1";
|
||||||
case kVK_ANSI_KeypadDivide: return "Keypad /";
|
case kVK_ANSI_2:
|
||||||
case kVK_ANSI_KeypadEnter: return "⌤";
|
return "2";
|
||||||
case kVK_ANSI_KeypadMinus: return "Keypad -";
|
case kVK_ANSI_3:
|
||||||
case kVK_ANSI_KeypadEquals: return "Keypad =";
|
return "3";
|
||||||
case kVK_ANSI_Keypad0: return "Keypad 0";
|
case kVK_ANSI_4:
|
||||||
case kVK_ANSI_Keypad1: return "Keypad 1";
|
return "4";
|
||||||
case kVK_ANSI_Keypad2: return "Keypad 2";
|
case kVK_ANSI_5:
|
||||||
case kVK_ANSI_Keypad3: return "Keypad 3";
|
return "5";
|
||||||
case kVK_ANSI_Keypad4: return "Keypad 4";
|
case kVK_ANSI_6:
|
||||||
case kVK_ANSI_Keypad5: return "Keypad 5";
|
return "6";
|
||||||
case kVK_ANSI_Keypad6: return "Keypad 6";
|
case kVK_ANSI_7:
|
||||||
case kVK_ANSI_Keypad7: return "Keypad 7";
|
return "7";
|
||||||
case kVK_ANSI_Keypad8: return "Keypad 8";
|
case kVK_ANSI_8:
|
||||||
case kVK_ANSI_Keypad9: return "Keypad 9";
|
return "8";
|
||||||
case kVK_Command: return "Left ⌘";
|
case kVK_ANSI_9:
|
||||||
case kVK_Shift: return "Left ⇧";
|
return "9";
|
||||||
case kVK_CapsLock: return "⇪";
|
case kVK_ANSI_Grave:
|
||||||
case kVK_Option: return "Left ⌥";
|
return "`";
|
||||||
case kVK_Control: return "Left ⌃";
|
case kVK_ANSI_Minus:
|
||||||
case kVK_RightCommand: return "Right ⌘";
|
return "-";
|
||||||
case kVK_RightShift: return "Right ⇧";
|
case kVK_ANSI_Equal:
|
||||||
case kVK_RightOption: return "Right ⌥";
|
return "=";
|
||||||
case kVK_RightControl: return "Right ⌃";
|
case kVK_ANSI_LeftBracket:
|
||||||
case kVK_Function: return "fn";
|
return "[";
|
||||||
case kVK_VolumeUp: return "Volume Up";
|
case kVK_ANSI_RightBracket:
|
||||||
case kVK_VolumeDown: return "Volume Down";
|
return "]";
|
||||||
case kVK_Mute: return "Mute";
|
case kVK_ANSI_Backslash:
|
||||||
case kVK_F1: return "F1";
|
return "\\";
|
||||||
case kVK_F2: return "F2";
|
case kVK_ANSI_Semicolon:
|
||||||
case kVK_F3: return "F3";
|
return ";";
|
||||||
case kVK_F4: return "F4";
|
case kVK_ANSI_Quote:
|
||||||
case kVK_F5: return "F5";
|
return "'";
|
||||||
case kVK_F6: return "F6";
|
case kVK_ANSI_Comma:
|
||||||
case kVK_F7: return "F7";
|
return ",";
|
||||||
case kVK_F8: return "F8";
|
case kVK_ANSI_Period:
|
||||||
case kVK_F9: return "F9";
|
return ".";
|
||||||
case kVK_F10: return "F10";
|
case kVK_ANSI_Slash:
|
||||||
case kVK_F11: return "F11";
|
return "/";
|
||||||
case kVK_F12: return "F12";
|
case kVK_Escape:
|
||||||
case kVK_F13: return "F13";
|
return "⎋";
|
||||||
case kVK_F14: return "F14";
|
case kVK_Tab:
|
||||||
case kVK_F15: return "F15";
|
return "⇥";
|
||||||
case kVK_F16: return "F16";
|
case kVK_Delete:
|
||||||
case kVK_F17: return "F17";
|
return "⌫";
|
||||||
case kVK_F18: return "F18";
|
case kVK_ForwardDelete:
|
||||||
case kVK_F19: return "F19";
|
return "⌦";
|
||||||
case kVK_F20: return "F20";
|
case kVK_Return:
|
||||||
case kVK_Help: return "Help";
|
return "↩";
|
||||||
case kVK_Home: return "↖";
|
case kVK_Space:
|
||||||
case kVK_PageUp: return "⇞";
|
return "␣";
|
||||||
case kVK_End: return "↘";
|
case kVK_ANSI_KeypadDecimal:
|
||||||
case kVK_PageDown: return "⇟";
|
return "Keypad .";
|
||||||
case kVK_LeftArrow: return "←";
|
case kVK_ANSI_KeypadMultiply:
|
||||||
case kVK_RightArrow: return "→";
|
return "Keypad *";
|
||||||
case kVK_DownArrow: return "↓";
|
case kVK_ANSI_KeypadPlus:
|
||||||
case kVK_UpArrow: return "↑";
|
return "Keypad +";
|
||||||
case kVK_ISO_Section: return "Section";
|
case kVK_ANSI_KeypadClear:
|
||||||
case kVK_JIS_Yen: return "¥";
|
return "⌧";
|
||||||
case kVK_JIS_Underscore: return "_";
|
case kVK_ANSI_KeypadDivide:
|
||||||
case kVK_JIS_KeypadComma: return "Keypad ,";
|
return "Keypad /";
|
||||||
case kVK_JIS_Eisu: return "英数";
|
case kVK_ANSI_KeypadEnter:
|
||||||
case kVK_JIS_Kana: return "かな";
|
return "⌤";
|
||||||
default: return "Key " + std::to_string(keysym);
|
case kVK_ANSI_KeypadMinus:
|
||||||
|
return "Keypad -";
|
||||||
|
case kVK_ANSI_KeypadEquals:
|
||||||
|
return "Keypad =";
|
||||||
|
case kVK_ANSI_Keypad0:
|
||||||
|
return "Keypad 0";
|
||||||
|
case kVK_ANSI_Keypad1:
|
||||||
|
return "Keypad 1";
|
||||||
|
case kVK_ANSI_Keypad2:
|
||||||
|
return "Keypad 2";
|
||||||
|
case kVK_ANSI_Keypad3:
|
||||||
|
return "Keypad 3";
|
||||||
|
case kVK_ANSI_Keypad4:
|
||||||
|
return "Keypad 4";
|
||||||
|
case kVK_ANSI_Keypad5:
|
||||||
|
return "Keypad 5";
|
||||||
|
case kVK_ANSI_Keypad6:
|
||||||
|
return "Keypad 6";
|
||||||
|
case kVK_ANSI_Keypad7:
|
||||||
|
return "Keypad 7";
|
||||||
|
case kVK_ANSI_Keypad8:
|
||||||
|
return "Keypad 8";
|
||||||
|
case kVK_ANSI_Keypad9:
|
||||||
|
return "Keypad 9";
|
||||||
|
case kVK_Command:
|
||||||
|
return "Left ⌘";
|
||||||
|
case kVK_Shift:
|
||||||
|
return "Left ⇧";
|
||||||
|
case kVK_CapsLock:
|
||||||
|
return "⇪";
|
||||||
|
case kVK_Option:
|
||||||
|
return "Left ⌥";
|
||||||
|
case kVK_Control:
|
||||||
|
return "Left ⌃";
|
||||||
|
case kVK_RightCommand:
|
||||||
|
return "Right ⌘";
|
||||||
|
case kVK_RightShift:
|
||||||
|
return "Right ⇧";
|
||||||
|
case kVK_RightOption:
|
||||||
|
return "Right ⌥";
|
||||||
|
case kVK_RightControl:
|
||||||
|
return "Right ⌃";
|
||||||
|
case kVK_Function:
|
||||||
|
return "fn";
|
||||||
|
case kVK_VolumeUp:
|
||||||
|
return "Volume Up";
|
||||||
|
case kVK_VolumeDown:
|
||||||
|
return "Volume Down";
|
||||||
|
case kVK_Mute:
|
||||||
|
return "Mute";
|
||||||
|
case kVK_F1:
|
||||||
|
return "F1";
|
||||||
|
case kVK_F2:
|
||||||
|
return "F2";
|
||||||
|
case kVK_F3:
|
||||||
|
return "F3";
|
||||||
|
case kVK_F4:
|
||||||
|
return "F4";
|
||||||
|
case kVK_F5:
|
||||||
|
return "F5";
|
||||||
|
case kVK_F6:
|
||||||
|
return "F6";
|
||||||
|
case kVK_F7:
|
||||||
|
return "F7";
|
||||||
|
case kVK_F8:
|
||||||
|
return "F8";
|
||||||
|
case kVK_F9:
|
||||||
|
return "F9";
|
||||||
|
case kVK_F10:
|
||||||
|
return "F10";
|
||||||
|
case kVK_F11:
|
||||||
|
return "F11";
|
||||||
|
case kVK_F12:
|
||||||
|
return "F12";
|
||||||
|
case kVK_F13:
|
||||||
|
return "F13";
|
||||||
|
case kVK_F14:
|
||||||
|
return "F14";
|
||||||
|
case kVK_F15:
|
||||||
|
return "F15";
|
||||||
|
case kVK_F16:
|
||||||
|
return "F16";
|
||||||
|
case kVK_F17:
|
||||||
|
return "F17";
|
||||||
|
case kVK_F18:
|
||||||
|
return "F18";
|
||||||
|
case kVK_F19:
|
||||||
|
return "F19";
|
||||||
|
case kVK_F20:
|
||||||
|
return "F20";
|
||||||
|
case kVK_Help:
|
||||||
|
return "Help";
|
||||||
|
case kVK_Home:
|
||||||
|
return "↖";
|
||||||
|
case kVK_PageUp:
|
||||||
|
return "⇞";
|
||||||
|
case kVK_End:
|
||||||
|
return "↘";
|
||||||
|
case kVK_PageDown:
|
||||||
|
return "⇟";
|
||||||
|
case kVK_LeftArrow:
|
||||||
|
return "←";
|
||||||
|
case kVK_RightArrow:
|
||||||
|
return "→";
|
||||||
|
case kVK_DownArrow:
|
||||||
|
return "↓";
|
||||||
|
case kVK_UpArrow:
|
||||||
|
return "↑";
|
||||||
|
case kVK_ISO_Section:
|
||||||
|
return "Section";
|
||||||
|
case kVK_JIS_Yen:
|
||||||
|
return "¥";
|
||||||
|
case kVK_JIS_Underscore:
|
||||||
|
return "_";
|
||||||
|
case kVK_JIS_KeypadComma:
|
||||||
|
return "Keypad ,";
|
||||||
|
case kVK_JIS_Eisu:
|
||||||
|
return "英数";
|
||||||
|
case kVK_JIS_Kana:
|
||||||
|
return "かな";
|
||||||
|
default:
|
||||||
|
return "Key " + std::to_string(keysym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static std::string KeyName(int pad, int key, int keysym)
|
static std::string KeyName(int pad, int key, int keysym)
|
||||||
{
|
{
|
||||||
// Mouse
|
// Mouse
|
||||||
if (keysym < 10) {
|
if (keysym < 10)
|
||||||
switch (keysym) {
|
{
|
||||||
|
switch (keysym)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return "";
|
return "";
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -397,7 +522,8 @@ PADDialog::PADDialog()
|
||||||
|
|
||||||
// create a new Notebook
|
// create a new Notebook
|
||||||
m_tab_gamepad = new wxNotebook(this, wxID_ANY);
|
m_tab_gamepad = new wxNotebook(this, wxID_ANY);
|
||||||
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i)
|
||||||
|
{
|
||||||
// Tabs panels
|
// Tabs panels
|
||||||
m_pan_tabs[i] = new opPanel(
|
m_pan_tabs[i] = new opPanel(
|
||||||
m_tab_gamepad,
|
m_tab_gamepad,
|
||||||
|
@ -415,7 +541,8 @@ PADDialog::PADDialog()
|
||||||
wxString(sstm.str().c_str(), wxConvUTF8) // Title
|
wxString(sstm.str().c_str(), wxConvUTF8) // Title
|
||||||
);
|
);
|
||||||
|
|
||||||
for (int j = 0; j < BUTTONS_LENGHT; ++j) {
|
for (int j = 0; j < BUTTONS_LENGHT; ++j)
|
||||||
|
{
|
||||||
// Gamepad buttons
|
// Gamepad buttons
|
||||||
m_bt_gamepad[i][j] = new wxButton(
|
m_bt_gamepad[i][j] = new wxButton(
|
||||||
m_pan_tabs[i], // Parent
|
m_pan_tabs[i], // Parent
|
||||||
|
@ -440,8 +567,10 @@ PADDialog::PADDialog()
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &PADDialog::OnButtonClicked, this);
|
Bind(wxEVT_BUTTON, &PADDialog::OnButtonClicked, this);
|
||||||
|
|
||||||
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i)
|
||||||
for (int j = 0; j < NB_IMG; ++j) {
|
{
|
||||||
|
for (int j = 0; j < NB_IMG; ++j)
|
||||||
|
{
|
||||||
m_pressed[i][j] = false;
|
m_pressed[i][j] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,35 +587,46 @@ void PADDialog::InitDialog()
|
||||||
/*********** Events functions ***********/
|
/*********** Events functions ***********/
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
void PADDialog::OnButtonClicked(wxCommandEvent &event)
|
void PADDialog::OnButtonClicked(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
// Affichage d'un message à chaque clic sur le bouton
|
||||||
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
||||||
int bt_id = bt_tmp->GetId() - wxID_HIGHEST - 1; // get the real ID
|
int bt_id = bt_tmp->GetId() - wxID_HIGHEST - 1; // get the real ID
|
||||||
int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id)
|
int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id)
|
||||||
if (bt_id >= 0 && bt_id <= PAD_R_LEFT) { // if the button ID is a gamepad button
|
if (bt_id >= 0 && bt_id <= PAD_R_LEFT)
|
||||||
|
{ // if the button ID is a gamepad button
|
||||||
bt_tmp->Disable(); // switch the button state to "Disable"
|
bt_tmp->Disable(); // switch the button state to "Disable"
|
||||||
config_key(gamepad_id, bt_id);
|
config_key(gamepad_id, bt_id);
|
||||||
bt_tmp->Enable(); // switch the button state to "Enable"
|
bt_tmp->Enable(); // switch the button state to "Enable"
|
||||||
} else if (bt_id == Gamepad_config) { // If the button ID is equals to the Gamepad_config button ID
|
}
|
||||||
|
else if (bt_id == Gamepad_config)
|
||||||
|
{ // If the button ID is equals to the Gamepad_config button ID
|
||||||
GamepadConfiguration gamepad_config(gamepad_id, this);
|
GamepadConfiguration gamepad_config(gamepad_id, this);
|
||||||
|
|
||||||
gamepad_config.InitGamepadConfiguration();
|
gamepad_config.InitGamepadConfiguration();
|
||||||
gamepad_config.ShowModal();
|
gamepad_config.ShowModal();
|
||||||
} else if (bt_id == JoyL_config) { // If the button ID is equals to the JoyL_config button ID
|
}
|
||||||
|
else if (bt_id == JoyL_config)
|
||||||
|
{ // If the button ID is equals to the JoyL_config button ID
|
||||||
JoystickConfiguration joystick_config(gamepad_id, true, this);
|
JoystickConfiguration joystick_config(gamepad_id, true, this);
|
||||||
|
|
||||||
joystick_config.InitJoystickConfiguration();
|
joystick_config.InitJoystickConfiguration();
|
||||||
joystick_config.ShowModal();
|
joystick_config.ShowModal();
|
||||||
} else if (bt_id == JoyR_config) { // If the button ID is equals to the JoyR_config button ID
|
}
|
||||||
|
else if (bt_id == JoyR_config)
|
||||||
|
{ // If the button ID is equals to the JoyR_config button ID
|
||||||
JoystickConfiguration joystick_config(gamepad_id, false, this);
|
JoystickConfiguration joystick_config(gamepad_id, false, this);
|
||||||
|
|
||||||
joystick_config.InitJoystickConfiguration();
|
joystick_config.InitJoystickConfiguration();
|
||||||
joystick_config.ShowModal();
|
joystick_config.ShowModal();
|
||||||
} else if (bt_id == Set_all) { // If the button ID is equals to the Set_all button ID
|
}
|
||||||
for (int i = 0; i < MAX_KEYS; ++i) {
|
else if (bt_id == Set_all)
|
||||||
|
{ // If the button ID is equals to the Set_all button ID
|
||||||
|
for (int i = 0; i < MAX_KEYS; ++i)
|
||||||
|
{
|
||||||
bt_tmp = m_bt_gamepad[gamepad_id][i];
|
bt_tmp = m_bt_gamepad[gamepad_id][i];
|
||||||
switch (i) {
|
switch (i)
|
||||||
|
{
|
||||||
case PAD_L_UP: // Left joystick (Up) ↑
|
case PAD_L_UP: // Left joystick (Up) ↑
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
|
||||||
break;
|
break;
|
||||||
|
@ -518,7 +658,8 @@ void PADDialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
m_pan_tabs[gamepad_id]->Refresh();
|
m_pan_tabs[gamepad_id]->Refresh();
|
||||||
m_pan_tabs[gamepad_id]->Update();
|
m_pan_tabs[gamepad_id]->Update();
|
||||||
config_key(gamepad_id, i);
|
config_key(gamepad_id, i);
|
||||||
switch (i) {
|
switch (i)
|
||||||
|
{
|
||||||
case PAD_L_UP: // Left joystick (Up) ↑
|
case PAD_L_UP: // Left joystick (Up) ↑
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
|
||||||
break;
|
break;
|
||||||
|
@ -551,12 +692,18 @@ void PADDialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
m_pan_tabs[gamepad_id]->Update();
|
m_pan_tabs[gamepad_id]->Update();
|
||||||
usleep(500000); // give enough time to the user to release the button
|
usleep(500000); // give enough time to the user to release the button
|
||||||
}
|
}
|
||||||
} else if (bt_id == Ok) { // If the button ID is equals to the Ok button ID
|
}
|
||||||
|
else if (bt_id == Ok)
|
||||||
|
{ // If the button ID is equals to the Ok button ID
|
||||||
PADSaveConfig(); // Save the configuration
|
PADSaveConfig(); // Save the configuration
|
||||||
Close(); // Close the window
|
Close(); // Close the window
|
||||||
} else if (bt_id == Apply) { // If the button ID is equals to the Apply button ID
|
}
|
||||||
|
else if (bt_id == Apply)
|
||||||
|
{ // If the button ID is equals to the Apply button ID
|
||||||
PADSaveConfig(); // Save the configuration
|
PADSaveConfig(); // Save the configuration
|
||||||
} else if (bt_id == Cancel) { // If the button ID is equals to the cancel button ID
|
}
|
||||||
|
else if (bt_id == Cancel)
|
||||||
|
{ // If the button ID is equals to the cancel button ID
|
||||||
Close(); // Close the window
|
Close(); // Close the window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,11 +717,14 @@ void PADDialog::config_key(int pad, int key)
|
||||||
bool captured = false;
|
bool captured = false;
|
||||||
u32 key_pressed = 0;
|
u32 key_pressed = 0;
|
||||||
|
|
||||||
while (!captured) {
|
while (!captured)
|
||||||
if (PollForNewKeyboardKeys(key_pressed)) {
|
{
|
||||||
|
if (PollForNewKeyboardKeys(key_pressed))
|
||||||
|
{
|
||||||
// special case for keyboard/mouse to handle multiple keys
|
// special case for keyboard/mouse to handle multiple keys
|
||||||
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
||||||
if (key_pressed > 0) {
|
if (key_pressed > 0)
|
||||||
|
{
|
||||||
clear_key(pad, key);
|
clear_key(pad, key);
|
||||||
set_keyboard_key(pad, key_pressed, key);
|
set_keyboard_key(pad, key_pressed, key);
|
||||||
m_simulatedKeys[pad][key] = key_pressed;
|
m_simulatedKeys[pad][key] = key_pressed;
|
||||||
|
@ -600,9 +750,11 @@ void PADDialog::clear_key(int pad, int key)
|
||||||
// Set button values
|
// Set button values
|
||||||
void PADDialog::repopulate()
|
void PADDialog::repopulate()
|
||||||
{
|
{
|
||||||
for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) {
|
for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id)
|
||||||
|
{
|
||||||
// keyboard/mouse key
|
// keyboard/mouse key
|
||||||
for (const auto &it : g_conf.keysym_map[gamepad_id]) {
|
for (const auto& it : g_conf.keysym_map[gamepad_id])
|
||||||
|
{
|
||||||
int keysym = it.first;
|
int keysym = it.first;
|
||||||
int key = it.second;
|
int key = it.second;
|
||||||
|
|
||||||
|
@ -617,7 +769,8 @@ void PADDialog::repopulate()
|
||||||
// Main
|
// Main
|
||||||
void DisplayDialog()
|
void DisplayDialog()
|
||||||
{
|
{
|
||||||
if (g_conf.ftw) {
|
if (g_conf.ftw)
|
||||||
|
{
|
||||||
wxString info("The PAD GUI is provided to map the keyboard/mouse to the virtual PS2 pad.\n\n"
|
wxString info("The PAD GUI is provided to map the keyboard/mouse to the virtual PS2 pad.\n\n"
|
||||||
"Gamepads/Joysticks are plug and play. The active gamepad can be selected in the 'Gamepad Configuration' panel.\n\n");
|
"Gamepads/Joysticks are plug and play. The active gamepad can be selected in the 'Gamepad Configuration' panel.\n\n");
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
// e.g L2 → 0, triangle → 4, ...
|
// e.g L2 → 0, triangle → 4, ...
|
||||||
// see PAD.h for more details about gamepad button id
|
// see PAD.h for more details about gamepad button id
|
||||||
|
|
||||||
enum gui_buttons {
|
enum gui_buttons
|
||||||
|
{
|
||||||
Analog = PAD_R_LEFT + 1, // Analog button (not yet supported ?)
|
Analog = PAD_R_LEFT + 1, // Analog button (not yet supported ?)
|
||||||
JoyL_config, // Left Joystick Configuration
|
JoyL_config, // Left Joystick Configuration
|
||||||
JoyR_config, // Right Joystick Configuration
|
JoyR_config, // Right Joystick Configuration
|
||||||
|
@ -62,11 +63,11 @@ enum gui_buttons {
|
||||||
class PADDialog : public wxDialog
|
class PADDialog : public wxDialog
|
||||||
{
|
{
|
||||||
// Panels
|
// Panels
|
||||||
opPanel *m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
|
opPanel* m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
|
||||||
// Notebooks
|
// Notebooks
|
||||||
wxNotebook *m_tab_gamepad; // Joysticks Tabs
|
wxNotebook* m_tab_gamepad; // Joysticks Tabs
|
||||||
// Buttons
|
// Buttons
|
||||||
wxButton *m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
|
wxButton* m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
|
||||||
// Contain all simulated key
|
// Contain all simulated key
|
||||||
u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
|
u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
// Timer
|
// Timer
|
||||||
|
@ -80,8 +81,8 @@ class PADDialog : public wxDialog
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent &);
|
void OnButtonClicked(wxCommandEvent&);
|
||||||
void JoystickEvent(wxTimerEvent &);
|
void JoystickEvent(wxTimerEvent&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PADDialog();
|
PADDialog();
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
#include "ImgHeader/arrow_bottom.h"
|
#include "ImgHeader/arrow_bottom.h"
|
||||||
#include "ImgHeader/arrow_left.h"
|
#include "ImgHeader/arrow_left.h"
|
||||||
|
|
||||||
opPanel::opPanel(wxWindow *parent,
|
opPanel::opPanel(wxWindow* parent,
|
||||||
wxWindowID id = wxID_ANY,
|
wxWindowID id = wxID_ANY,
|
||||||
const wxPoint &pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize &size = wxDefaultSize)
|
const wxSize& size = wxDefaultSize)
|
||||||
: wxPanel(parent, id, pos, size)
|
: wxPanel(parent, id, pos, size)
|
||||||
{
|
{
|
||||||
m_picture[img_background] = EmbeddedImage<res_dualshock2>().Get();
|
m_picture[img_background] = EmbeddedImage<res_dualshock2>().Get();
|
||||||
|
@ -81,7 +81,8 @@ opPanel::opPanel(wxWindow *parent,
|
||||||
m_picture[img_r_arrow_bottom] = EmbeddedImage<res_arrow_bottom>().Get();
|
m_picture[img_r_arrow_bottom] = EmbeddedImage<res_arrow_bottom>().Get();
|
||||||
m_picture[img_r_arrow_left] = EmbeddedImage<res_arrow_left>().Get();
|
m_picture[img_r_arrow_left] = EmbeddedImage<res_arrow_left>().Get();
|
||||||
|
|
||||||
for (int i = 0; i < NB_IMG; ++i) {
|
for (int i = 0; i < NB_IMG; ++i)
|
||||||
|
{
|
||||||
m_show_image[i] = false;
|
m_show_image[i] = false;
|
||||||
HideImg(i);
|
HideImg(i);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,8 @@ opPanel::opPanel(wxWindow *parent,
|
||||||
|
|
||||||
void opPanel::HideImg(int id)
|
void opPanel::HideImg(int id)
|
||||||
{
|
{
|
||||||
if (id < NB_IMG) {
|
if (id < NB_IMG)
|
||||||
|
{
|
||||||
m_show_image[id] = false;
|
m_show_image[id] = false;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -104,7 +106,8 @@ void opPanel::HideImg(int id)
|
||||||
|
|
||||||
void opPanel::ShowImg(int id)
|
void opPanel::ShowImg(int id)
|
||||||
{
|
{
|
||||||
if (id < NB_IMG) {
|
if (id < NB_IMG)
|
||||||
|
{
|
||||||
m_show_image[id] = true;
|
m_show_image[id] = true;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -112,22 +115,29 @@ void opPanel::ShowImg(int id)
|
||||||
|
|
||||||
void opPanel::MoveJoystick(int axe, int value)
|
void opPanel::MoveJoystick(int axe, int value)
|
||||||
{
|
{
|
||||||
if (axe == 0) {
|
if (axe == 0)
|
||||||
|
{
|
||||||
m_left_cursor_x = value * 30 / 40000;
|
m_left_cursor_x = value * 30 / 40000;
|
||||||
} else if (axe == 1) {
|
}
|
||||||
|
else if (axe == 1)
|
||||||
|
{
|
||||||
m_left_cursor_y = value * 30 / 40000;
|
m_left_cursor_y = value * 30 / 40000;
|
||||||
} else if (axe == 2) {
|
}
|
||||||
|
else if (axe == 2)
|
||||||
|
{
|
||||||
m_right_cursor_x = value * 30 / 40000;
|
m_right_cursor_x = value * 30 / 40000;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_right_cursor_y = value * 30 / 40000;
|
m_right_cursor_y = value * 30 / 40000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(opPanel, wxPanel)
|
wxBEGIN_EVENT_TABLE(opPanel, wxPanel)
|
||||||
EVT_PAINT(opPanel::OnPaint)
|
EVT_PAINT(opPanel::OnPaint)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
void opPanel::OnPaint(wxPaintEvent &event)
|
void opPanel::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
|
|
||||||
#include "EmbeddedImage.h"
|
#include "EmbeddedImage.h"
|
||||||
|
|
||||||
enum gui_img {
|
enum gui_img
|
||||||
|
{
|
||||||
img_l2,
|
img_l2,
|
||||||
img_r2,
|
img_r2,
|
||||||
img_l1,
|
img_l1,
|
||||||
|
@ -61,10 +62,10 @@ class opPanel : public wxPanel
|
||||||
bool m_show_image[NB_IMG];
|
bool m_show_image[NB_IMG];
|
||||||
int m_left_cursor_x, m_left_cursor_y, m_right_cursor_x, m_right_cursor_y;
|
int m_left_cursor_x, m_left_cursor_y, m_right_cursor_x, m_right_cursor_y;
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
opPanel(wxWindow *, wxWindowID, const wxPoint &, const wxSize &);
|
opPanel(wxWindow*, wxWindowID, const wxPoint&, const wxSize&);
|
||||||
void HideImg(int);
|
void HideImg(int);
|
||||||
void ShowImg(int);
|
void ShowImg(int);
|
||||||
void MoveJoystick(int, int);
|
void MoveJoystick(int, int);
|
||||||
|
|
Loading…
Reference in New Issue