mirror of https://github.com/PCSX2/pcsx2.git
PAD: clang-format
This commit is contained in:
parent
2e0be1f75a
commit
82f7a23be4
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +104,8 @@ void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
@ -166,10 +168,12 @@ 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,8 +207,9 @@ 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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +257,10 @@ 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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -26,7 +26,8 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjo
|
||||||
{
|
{
|
||||||
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");
|
||||||
|
|
||||||
|
@ -63,7 +64,8 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjo
|
||||||
|
|
||||||
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)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +170,8 @@ JoystickInfo::JoystickInfo(int id)
|
||||||
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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ void PADSaveConfig()
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,8 @@ void PADLoadConfig()
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -38,10 +38,13 @@ char *KeysymToChar(int keysym)
|
||||||
#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;
|
||||||
}
|
}
|
||||||
|
@ -117,15 +135,18 @@ void AnalyzeKeyEvent(keyEvent &evt)
|
||||||
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;
|
||||||
|
@ -274,11 +305,15 @@ 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)) {
|
||||||
|
|
|
@ -68,7 +68,8 @@ void PollForJoystickInput(int cpad)
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -7,8 +7,12 @@
|
||||||
#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"
|
||||||
|
@ -16900,18 +16908,26 @@ GResource *PAD_res_get_resource (void)
|
||||||
#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) \
|
||||||
|
{ \
|
||||||
|
_func(); \
|
||||||
|
g_slist_find(NULL, _array##_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
__pragma(comment(linker, "/include:" _sym_prefix #_func "_wrapper")) \
|
__pragma(comment(linker, "/include:" _sym_prefix #_func "_wrapper")) \
|
||||||
__pragma(section(".CRT$XCU",read)) \
|
__pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_wrapper;
|
||||||
__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) \
|
||||||
|
{ \
|
||||||
|
atexit(_func); \
|
||||||
|
g_slist_find(NULL, _array##_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
__pragma(comment(linker, "/include:" _sym_prefix #_func "_constructor")) \
|
__pragma(comment(linker, "/include:" _sym_prefix #_func "_constructor")) \
|
||||||
__pragma(section(".CRT$XCU",read)) \
|
__pragma(section(".CRT$XCU", read)) __declspec(allocate(".CRT$XCU")) int (*_array##_func)(void) = _func##_constructor;
|
||||||
__declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
|
||||||
|
@ -16925,14 +16941,22 @@ GResource *PAD_res_get_resource (void)
|
||||||
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) \
|
||||||
|
{ \
|
||||||
|
_func(); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
__declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func##_wrapper;
|
__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) \
|
||||||
|
{ \
|
||||||
|
atexit(_func); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
__declspec(allocate(".CRT$XCU")) static int (*_array##_func)(void) = _func##_constructor;
|
__declspec(allocate(".CRT$XCU")) static int (*_array##_func)(void) = _func##_constructor;
|
||||||
|
|
||||||
#elif defined(__SUNPRO_C)
|
#elif defined(__SUNPRO_C)
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -24,7 +24,8 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -464,29 +593,40 @@ void PADDialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
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
|
||||||
|
|
|
@ -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,13 +115,20 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue