diff --git a/plugins/onepad/GamePad.cpp b/plugins/onepad/GamePad.cpp index 755f2a6f6b..0582e82139 100644 --- a/plugins/onepad/GamePad.cpp +++ b/plugins/onepad/GamePad.cpp @@ -25,13 +25,6 @@ void GamePad::EnumerateGamePads(std::vector> &vgamePad) #endif } -void GamePad::UpdateReleaseState() -{ -#ifdef SDL_BUILD - JoystickInfo::UpdateReleaseState(); -#endif -} - /** * Safely dispatch to the Rumble method above **/ diff --git a/plugins/onepad/GamePad.h b/plugins/onepad/GamePad.h index 1d974c0eda..bbc957140a 100644 --- a/plugins/onepad/GamePad.h +++ b/plugins/onepad/GamePad.h @@ -4,10 +4,6 @@ #include "controller.h" #ifdef SDL_BUILD #include -#define HAT_UP SDL_HAT_UP -#define HAT_DOWN SDL_HAT_DOWN -#define HAT_RIGHT SDL_HAT_RIGHT -#define HAT_LEFT SDL_HAT_LEFT #endif class GamePad @@ -15,16 +11,8 @@ class GamePad public: GamePad() : devname("") - , _id(-1) - , numbuttons(0) - , numaxes(0) - , numhats(0) , deadzone(1500) - , pad(-1) { - vbuttonstate.clear(); - vaxisstate.clear(); - vhatstate.clear(); } virtual ~GamePad() @@ -39,7 +27,6 @@ public: * Find every interesting devices and create right structure for them(depend on backend) */ static void EnumerateGamePads(std::vector> &vgamePad); - static void UpdateReleaseState(); /* * Update state of every attached devices @@ -63,93 +50,19 @@ public: */ virtual bool TestForce(float strength = 0.6) { return false; } - virtual bool PollButtons(u32 &pkey) { return false; } - virtual bool PollAxes(u32 &pkey) { return false; } - virtual bool PollHats(u32 &pkey) { return false; } - - virtual int GetHat(int key_to_axis) - { - return 0; - } - - virtual int GetButton(int key_to_button) - { - return 0; - } - const string &GetName() { return devname; } - int GetPAD() - { - return pad; - } - - int GetNumButtons() - { - return numbuttons; - } - - int GetNumAxes() - { - return numaxes; - } - - int GetNumHats() - { - return numhats; - } - virtual int GetDeadzone() { return deadzone; } - virtual void SaveState() {} - - int GetButtonState(int i) - { - return vbuttonstate[i]; - } - - int GetAxisState(int i) - { - return vaxisstate[i]; - } - - int GetHatState(int i) - { - //PAD_LOG("Getting POV State of %d.\n", i); - return vhatstate[i]; - } - - void SetButtonState(int i, int state) - { - vbuttonstate[i] = state; - } - - void SetAxisState(int i, int value) - { - vaxisstate[i] = value; - } - - void SetHatState(int i, int value) - { - //PAD_LOG("We should set %d to %d.\n", i, value); - vhatstate[i] = value; - } - - virtual int GetAxisFromKey(int pad, int index) { return 0; } - // These fields need to be inherited by child classes protected: string devname; // pretty device name - int _id; - int numbuttons, numaxes, numhats; int deadzone; - int pad; - std::vector vbuttonstate, vaxisstate, vhatstate; }; extern std::vector> s_vgamePad; diff --git a/plugins/onepad/Linux/dialog.cpp b/plugins/onepad/Linux/dialog.cpp index d4b0ac4947..9b235b19cf 100644 --- a/plugins/onepad/Linux/dialog.cpp +++ b/plugins/onepad/Linux/dialog.cpp @@ -279,10 +279,6 @@ Dialog::Dialog() Bind(wxEVT_BUTTON, &Dialog::OnButtonClicked, this); - m_time_update_gui.SetOwner(this); - Bind(wxEVT_TIMER, &Dialog::JoystickEvent, this); - m_time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS); - for (int i = 0; i < GAMEPAD_NUMBER; ++i) { for (int j = 0; j < NB_IMG; ++j) { m_pressed[i][j] = false; @@ -404,124 +400,6 @@ void Dialog::OnButtonClicked(wxCommandEvent &event) } } -void Dialog::JoystickEvent(wxTimerEvent &event) -{ -#ifdef SDL_BUILD - u32 key; - int map; - std::map::iterator it; - std::map::iterator it2; - SDL_JoystickEventState(SDL_ENABLE); - SDL_Event events; - while (SDL_PollEvent(&events)) { - switch (events.type) { - case SDL_KEYDOWN: - case SDL_KEYUP: - break; - case SDL_JOYAXISMOTION: - if (events.jaxis.which < GAMEPAD_NUMBER) { - key = axis_to_key(false, (events.jaxis.value < 0), events.jaxis.axis); - it = m_map_images[events.jaxis.which].find(key); - if (it != m_map_images[events.jaxis.which].end()) { - map = m_map_images[events.jaxis.which][key]; - if (events.jaxis.value == 0) { - if (map >= PAD_L_UP && map <= PAD_L_LEFT) - m_pan_tabs[events.jaxis.which]->HideImg(img_left_cursor); - else if (map >= PAD_R_UP && map <= PAD_R_LEFT) - m_pan_tabs[events.jaxis.which]->HideImg(img_right_cursor); - else if (map < PAD_L_UP) - m_pan_tabs[events.jaxis.which]->HideImg(map); - } else { - if (map >= PAD_L_UP && map <= PAD_L_LEFT) { - m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); - m_pan_tabs[events.jaxis.which]->ShowImg(img_left_cursor); - } else if (map >= PAD_R_UP && map <= PAD_R_LEFT) { - m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value); - m_pan_tabs[events.jaxis.which]->ShowImg(img_right_cursor); - } else if (map < PAD_L_UP) { // if this is not a joystick - m_pan_tabs[events.jaxis.which]->ShowImg(map); - } - } - break; - } - // Hack Dualshock 4 (L2, R2) - key = axis_to_key(false, (events.jaxis.value > 0), events.jaxis.axis); - it2 = m_map_images[events.jaxis.which].find(key); - if (it2 != m_map_images[events.jaxis.which].end()) { - map = m_map_images[events.jaxis.which][key]; - if (map < PAD_L_UP) { // if this is not a joystick - m_pan_tabs[events.jaxis.which]->HideImg(map); - } - break; - } - } - break; - case SDL_JOYBUTTONDOWN: - if (events.jbutton.which < GAMEPAD_NUMBER) { - key = button_to_key(events.jbutton.button); - it = m_map_images[events.jbutton.which].find(key); - if (it != m_map_images[events.jbutton.which].end()) { - map = m_map_images[events.jbutton.which][key]; - m_pan_tabs[events.jbutton.which]->ShowImg(map); - } - } - break; - case SDL_JOYBUTTONUP: - if (events.jbutton.which < GAMEPAD_NUMBER) { - key = button_to_key(events.jbutton.button); - it = m_map_images[events.jbutton.which].find(key); - if (it != m_map_images[events.jbutton.which].end()) { - map = m_map_images[events.jbutton.which][key]; - m_pan_tabs[events.jbutton.which]->HideImg(map); - } - } - break; - case SDL_JOYHATMOTION: - if (events.jhat.which < GAMEPAD_NUMBER) { - switch (events.jhat.value) { - case SDL_HAT_UP: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it = m_map_images[events.jhat.which].find(key); - if (it != m_map_images[events.jhat.which].end()) { - m_pan_tabs[events.jhat.which]->ShowImg(img_dp_up); - } - break; - case SDL_HAT_DOWN: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it = m_map_images[events.jhat.which].find(key); - if (it != m_map_images[events.jhat.which].end()) { - m_pan_tabs[events.jhat.which]->ShowImg(img_dp_bottom); - } - break; - case SDL_HAT_RIGHT: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it = m_map_images[events.jhat.which].find(key); - if (it != m_map_images[events.jhat.which].end()) { - m_pan_tabs[events.jhat.which]->ShowImg(img_dp_right); - } - break; - case SDL_HAT_LEFT: - key = hat_to_key(events.jhat.value, events.jhat.hat); - it = m_map_images[events.jhat.which].find(key); - if (it != m_map_images[events.jhat.which].end()) { - m_pan_tabs[events.jhat.which]->ShowImg(img_dp_left); - } - break; - case SDL_HAT_CENTERED: - m_pan_tabs[events.jhat.which]->HideImg(img_dp_up); - m_pan_tabs[events.jhat.which]->HideImg(img_dp_bottom); - m_pan_tabs[events.jhat.which]->HideImg(img_dp_right); - m_pan_tabs[events.jhat.which]->HideImg(img_dp_left); - } - } - break; - default: - break; - } - } -#endif // SDL_BUILD -} - /****************************************/ /*********** Methods functions **********/ /****************************************/ @@ -531,8 +409,6 @@ void Dialog::config_key(int pad, int key) bool captured = false; u32 key_pressed = 0; - // I don't have any guarantee that not-yet-pressed state is egual to released state - GamePad::UpdateReleaseState(); while (!captured) { if (PollX11KeyboardMouseEvent(key_pressed)) { // special case for keyboard/mouse to handle multiple keys @@ -541,32 +417,8 @@ void Dialog::config_key(int pad, int key) clear_key(pad, key); set_keyboad_key(pad, key_pressed, key); m_simulatedKeys[pad][key] = key_pressed; - m_map_images[pad][key_pressed] = key; } captured = true; - } else { - GamePad::UpdateGamePadState(); - - for (auto &j : s_vgamePad) { - if (j->PollButtons(key_pressed)) { - clear_key(pad, key); - set_key(pad, key, key_pressed); - m_map_images[pad][key_pressed] = key; - captured = true; - } else if (j->PollAxes(key_pressed)) { - clear_key(pad, key); - set_key(pad, key, key_pressed); - m_map_images[pad][key_pressed] = key; - captured = true; - } else if (j->PollHats(key_pressed)) { - clear_key(pad, key); - set_key(pad, key, key_pressed); - m_map_images[pad][key_pressed] = key; - captured = true; - } - if (captured) - break; - } } } m_bt_gamepad[pad][key]->SetLabel( @@ -580,23 +432,7 @@ void Dialog::clear_key(int pad, int key) m_simulatedKeys[pad][key] = 0; // erase gamepad entry (keysim map) - std::map::iterator it1; - it1 = conf->keysym_map[pad].find(keysim); - if (it1 != conf->keysym_map[pad].end()) - conf->keysym_map[pad].erase(it1); - - // erase gamepad entry (image map) - int val = get_key(pad, key); - std::map::iterator it2; - it2 = m_map_images[pad].find(val); - if (it2 != m_map_images[pad].end()) { - m_map_images[pad].erase(it2); - } - - // Erase the keyboard image map - //m_map_images[pad].erase(keysim); - // Erase the Gamepad binded key - set_key(pad, key, 0); + conf->keysym_map[pad].erase(keysim); } @@ -604,15 +440,6 @@ void Dialog::clear_key(int pad, int key) void Dialog::repopulate() { for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) { - for (int key = 0; key < MAX_KEYS; key++) { - if (get_key(gamepad_id, key) != 0) { - m_bt_gamepad[gamepad_id][key]->SetLabel( - KeyName(gamepad_id, key).c_str()); - - m_map_images[gamepad_id][get_key(gamepad_id, key)] = key; - } - } - // keyboard/mouse key map::iterator it; for (it = conf->keysym_map[gamepad_id].begin(); @@ -624,7 +451,6 @@ void Dialog::repopulate() KeyName(gamepad_id, key, keysym).c_str()); m_simulatedKeys[gamepad_id][key] = keysym; - m_map_images[gamepad_id][keysym] = key; } } } diff --git a/plugins/onepad/Linux/dialog.h b/plugins/onepad/Linux/dialog.h index ee10a80b86..d3039b7e60 100644 --- a/plugins/onepad/Linux/dialog.h +++ b/plugins/onepad/Linux/dialog.h @@ -77,8 +77,6 @@ class Dialog : public wxDialog wxTimer m_time_update_gui; // Check if the gui must display feddback image bool m_pressed[GAMEPAD_NUMBER][NB_IMG]; - // Map the key pressed with the feedback image id - std::map m_map_images[GAMEPAD_NUMBER]; // methods void config_key(int, int); diff --git a/plugins/onepad/Linux/ini.cpp b/plugins/onepad/Linux/ini.cpp index c53cc9a9e1..ca972a774c 100644 --- a/plugins/onepad/Linux/ini.cpp +++ b/plugins/onepad/Linux/ini.cpp @@ -55,46 +55,6 @@ string KeyName(int pad, int key, int keysym) if (pstr != NULL) tmp = pstr; } - } else { - // joystick - KeyType k = type_of_joykey(pad, key); - switch (k) { - case PAD_JOYBUTTONS: { - int button = key_to_button(pad, key); - sprintf(&tmp[0], "JBut %d", button); - break; - } - case PAD_AXIS: { - if (key_to_axis_type(pad, key)) - sprintf(&tmp[0], "JAxis %d Full", key_to_axis(pad, key)); - else - sprintf(&tmp[0], "JAxis %d Half%s", key_to_axis(pad, key), key_to_axis_sign(pad, key) ? "-" : "+"); - break; - } - case PAD_HAT: { - int axis = key_to_axis(pad, key); - switch (key_to_hat_dir(pad, key)) { - case HAT_UP: - sprintf(&tmp[0], "JPOVU-%d", axis); - break; - - case HAT_RIGHT: - sprintf(&tmp[0], "JPOVR-%d", axis); - break; - - case HAT_DOWN: - sprintf(&tmp[0], "JPOVD-%d", axis); - break; - - case HAT_LEFT: - sprintf(&tmp[0], "JPOVL-%d", axis); - break; - } - break; - } - default: - break; - } } return tmp; @@ -135,12 +95,6 @@ void SaveConfig() fprintf(f, "joy_pad_map = %d\n", conf->joyid_map); fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity()); - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) { - for (int key = 0; key < MAX_KEYS; key++) { - fprintf(f, "[%d][%d] = 0x%x\n", pad, key, get_key(pad, key)); - } - } - map::iterator it; for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it) @@ -152,7 +106,6 @@ void SaveConfig() void LoadConfig() { FILE *f; - char str[256]; bool have_user_setting = false; if (!conf) @@ -187,23 +140,11 @@ void LoadConfig() goto error; conf->set_ff_intensity(value); - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) { - for (int key = 0; key < MAX_KEYS; key++) { - sprintf(str, "[%d][%d] = 0x%%x\n", pad, key); - u32 temp = 0; - - if (fscanf(f, str, &temp) == 0) - temp = 0; - set_key(pad, key, temp); - if (temp && pad == 0) - have_user_setting = true; - } - } u32 pad; u32 keysym; u32 index; - while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) != EOF) { + while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) == 3) { set_keyboad_key(pad & 1, keysym, index); if (pad == 0) have_user_setting = true; diff --git a/plugins/onepad/Linux/linux.cpp b/plugins/onepad/Linux/linux.cpp index 48fd31b4cc..dce458b925 100644 --- a/plugins/onepad/Linux/linux.cpp +++ b/plugins/onepad/Linux/linux.cpp @@ -86,68 +86,6 @@ void PollForJoystickInput(int cpad) int joyid = conf->get_joyid(cpad); if (!GamePadIdWithinBounds(joyid)) return; - - GamePad::UpdateGamePadState(); - for (int i = 0; i < MAX_KEYS; i++) { - auto &gamePad = s_vgamePad[joyid]; - - switch (type_of_joykey(cpad, i)) { - case PAD_JOYBUTTONS: { - - int value = gamePad->GetButton(key_to_button(cpad, i)); - if (value) - key_status->press(cpad, i); - else - key_status->release(cpad, i); - - break; - } - case PAD_HAT: { - int value = gamePad->GetHat(key_to_axis(cpad, i)); - - // key_to_hat_dir and SDL_JoystickGetHat are a 4 bits bitmap, one for each directions. Only 1 bit can be high for - // key_to_hat_dir. SDL_JoystickGetHat handles diagonal too (2 bits) so you must check the intersection - // '&' not only equality '=='. -- Gregory - if (key_to_hat_dir(cpad, i) & value) - key_status->press(cpad, i); - else - key_status->release(cpad, i); - - break; - } - case PAD_AXIS: { - int value = gamePad->GetAxisFromKey(cpad, i); - bool sign = key_to_axis_sign(cpad, i); - bool full_axis = key_to_axis_type(cpad, i); - - if (IsAnalogKey(i)) { - if (abs(value) > gamePad->GetDeadzone()) - key_status->press(cpad, i, value); - else - key_status->release(cpad, i); - - } else { - if (full_axis) { - value += 0x8000; - if (value > gamePad->GetDeadzone()) - key_status->press(cpad, i, min(value / 256, 0xFF)); - else - key_status->release(cpad, i); - - } else { - if (sign && (-value > gamePad->GetDeadzone())) - key_status->press(cpad, i, min(-value / 128, 0xFF)); - else if (!sign && (value > gamePad->GetDeadzone())) - key_status->press(cpad, i, min(value / 128, 0xFF)); - else - key_status->release(cpad, i); - } - } - } - default: - break; - } - } } EXPORT_C_(void) diff --git a/plugins/onepad/SDL/joystick.cpp b/plugins/onepad/SDL/joystick.cpp index 9e7f62e7da..6b790986c6 100644 --- a/plugins/onepad/SDL/joystick.cpp +++ b/plugins/onepad/SDL/joystick.cpp @@ -26,17 +26,6 @@ // Joystick definitions // ////////////////////////// -static u32 s_bSDLInit = false; - -void JoystickInfo::UpdateReleaseState() -{ - SDL_JoystickUpdate(); - - // Save everything in the vector s_vjoysticks. - for (auto &j : s_vgamePad) - j->SaveState(); -} - // opens handles to all possible joysticks void JoystickInfo::EnumerateJoysticks(std::vector> &vjoysticks) { @@ -144,7 +133,6 @@ void JoystickInfo::Destroy() bool JoystickInfo::Init(int id) { Destroy(); - _id = id; joy = SDL_JoystickOpen(id); if (joy == NULL) { @@ -152,15 +140,8 @@ bool JoystickInfo::Init(int id) return false; } - numaxes = SDL_JoystickNumAxes(joy); - numbuttons = SDL_JoystickNumButtons(joy); - numhats = SDL_JoystickNumHats(joy); devname = SDL_JoystickName(joy); - vaxisstate.resize(numaxes); - vbuttonstate.resize(numbuttons); - vhatstate.resize(numhats); - if (haptic == NULL) { if (!SDL_JoystickIsHaptic(joy)) { PAD_LOG("Haptic devices not supported!\n"); @@ -174,16 +155,6 @@ bool JoystickInfo::Init(int id) return true; } -void JoystickInfo::SaveState() -{ - for (int i = 0; i < numbuttons; ++i) - SetButtonState(i, SDL_JoystickGetButton(joy, i)); - for (int i = 0; i < numaxes; ++i) - SetAxisState(i, SDL_JoystickGetAxis(joy, i)); - for (int i = 0; i < numhats; ++i) - SetHatState(i, SDL_JoystickGetHat(joy, i)); -} - bool JoystickInfo::TestForce(float strength = 0.60) { // This code just use standard rumble to check that SDL handles the pad correctly! --3kinox @@ -198,102 +169,3 @@ bool JoystickInfo::TestForce(float strength = 0.60) return true; } - -bool JoystickInfo::PollButtons(u32 &pkey) -{ - // MAKE sure to look for changes in the state!! - for (int i = 0; i < GetNumButtons(); ++i) { - int but = SDL_JoystickGetButton(GetJoy(), i); - if (but != GetButtonState(i)) { - // Pressure sensitive button are detected as both button (digital) and axes (analog). So better - // drop the button to emulate the pressure sensiblity of the ds2 :) - // Trick: detect the release of the button. It avoid all races condition between axes and buttons :) - // If the button support pressure it will be detected as an axis when it is pressed. - if (but) { - SetButtonState(i, but); - return false; - } - - - pkey = button_to_key(i); - return true; - } - } - - return false; -} - -bool JoystickInfo::PollAxes(u32 &pkey) -{ - for (int i = 0; i < numaxes; ++i) { - s32 value = SDL_JoystickGetAxis(GetJoy(), i); - s32 old_value = GetAxisState(i); - - if (abs(value - old_value) < 0x1000) - continue; - - if (value != old_value) { - PAD_LOG("Change in joystick %d: %d.\n", i, value); - // There are several kinds of axes - // Half+: 0 (release) -> 32768 - // Half-: 0 (release) -> -32768 - // Full (like dualshock 3): -32768 (release) ->32768 - const s32 full_axis_ceil = -0x6FFF; - const s32 half_axis_ceil = 0x1FFF; - - // Normally, old_value contains the release state so it can be used to detect the types of axis. - bool is_full_axis = (old_value < full_axis_ceil); - - if ((!is_full_axis && abs(value) <= half_axis_ceil) || (is_full_axis && value <= full_axis_ceil)) // we don't want this - { - continue; - } - - if ((!is_full_axis && abs(value) > half_axis_ceil) || (is_full_axis && value > full_axis_ceil)) { - bool sign = (value < 0); - pkey = axis_to_key(is_full_axis, sign, i); - - return true; - } - } - } - - return false; -} - -bool JoystickInfo::PollHats(u32 &pkey) -{ - for (int i = 0; i < GetNumHats(); ++i) { - int value = SDL_JoystickGetHat(GetJoy(), i); - - if ((value != GetHatState(i)) && (value != SDL_HAT_CENTERED)) { - switch (value) { - case SDL_HAT_UP: - case SDL_HAT_RIGHT: - case SDL_HAT_DOWN: - case SDL_HAT_LEFT: - pkey = hat_to_key(value, i); - PAD_LOG("Hat Pressed!"); - return true; - default: - break; - } - } - } - return false; -} - -int JoystickInfo::GetHat(int key_to_axis) -{ - return SDL_JoystickGetHat(GetJoy(), key_to_axis); -} - -int JoystickInfo::GetButton(int key_to_button) -{ - return SDL_JoystickGetButton(GetJoy(), key_to_button); -} - -int JoystickInfo::GetAxisFromKey(int pad, int index) -{ - return SDL_JoystickGetAxis(GetJoy(), key_to_axis(pad, index)); -} diff --git a/plugins/onepad/SDL/joystick.h b/plugins/onepad/SDL/joystick.h index 37d87a97a6..082cb5a5c6 100644 --- a/plugins/onepad/SDL/joystick.h +++ b/plugins/onepad/SDL/joystick.h @@ -62,21 +62,6 @@ public: bool TestForce(float); - bool PollButtons(u32 &pkey); - bool PollAxes(u32 &pkey); - bool PollHats(u32 &pkey); - - int GetHat(int key_to_axis); - - int GetButton(int key_to_button); - - - void SaveState(); - - int GetAxisFromKey(int pad, int index); - - static void UpdateReleaseState(); - private: SDL_Joystick *GetJoy() { diff --git a/plugins/onepad/controller.cpp b/plugins/onepad/controller.cpp index 09badfb5ed..d9107d6bc5 100644 --- a/plugins/onepad/controller.cpp +++ b/plugins/onepad/controller.cpp @@ -38,77 +38,7 @@ __forceinline int get_keyboard_key(int pad, int keysym) return -1; } -__forceinline void set_key(int pad, int index, int value) -{ - conf->keys[pad][index] = value; -} - -__forceinline int get_key(int pad, int index) -{ - return conf->keys[pad][index]; -} - -__forceinline KeyType type_of_joykey(int pad, int index) -{ - int key = get_key(pad, index); - - if (key >= 0x10000 && key < 0x20000) - return PAD_JOYBUTTONS; - else if (key >= 0x20000 && key < 0x30000) - return PAD_AXIS; - else if (key >= 0x30000 && key < 0x40000) - return PAD_HAT; - else - return PAD_NULL; -} - __forceinline bool IsAnalogKey(int index) { return ((index >= PAD_L_UP) && (index <= PAD_R_LEFT)); } - -//******************************************************* -// onepad key -> joy input -//******************************************************* -__forceinline int key_to_button(int pad, int index) -{ - return (get_key(pad, index) & 0xff); -} - -__forceinline int key_to_axis(int pad, int index) -{ - return (get_key(pad, index) & 0xff); -} - -__forceinline bool key_to_axis_sign(int pad, int index) -{ - return ((get_key(pad, index) >> 8) & 0x1); -} - -__forceinline bool key_to_axis_type(int pad, int index) -{ - return ((get_key(pad, index) >> 9) & 0x1); -} - -__forceinline int key_to_hat_dir(int pad, int index) -{ - return ((get_key(pad, index) >> 8) & 0xF); -} - -//******************************************************* -// joy input -> onepad key -//******************************************************* -__forceinline int button_to_key(int button_id) -{ - return (0x10000 | button_id); -} - -__forceinline int axis_to_key(int full_axis, int sign, int axis_id) -{ - return (0x20000 | (full_axis << 9) | (sign << 8) | axis_id); -} - -__forceinline int hat_to_key(int dir, int axis_id) -{ - return (0x30000 | (dir << 8) | axis_id); -} diff --git a/plugins/onepad/controller.h b/plugins/onepad/controller.h index d8d177adc3..84adb9941b 100644 --- a/plugins/onepad/controller.h +++ b/plugins/onepad/controller.h @@ -23,30 +23,10 @@ #include // for memset #define MAX_KEYS 24 -enum KeyType { - PAD_JOYBUTTONS = 0, - PAD_AXIS, - PAD_HAT, - PAD_NULL = -1 -}; - extern void set_keyboad_key(int pad, int keysym, int index); extern int get_keyboard_key(int pad, int keysym); -extern void set_key(int pad, int index, int value); -extern int get_key(int pad, int index); extern bool IsAnalogKey(int index); -extern KeyType type_of_joykey(int pad, int index); -extern int key_to_button(int pad, int index); -extern int key_to_axis(int pad, int index); -extern bool key_to_axis_sign(int pad, int index); -extern bool key_to_axis_type(int pad, int index); -extern int key_to_hat_dir(int pad, int index); - -extern int button_to_key(int button_id); -extern int axis_to_key(int full_axis, int sign, int axis_id); -extern int hat_to_key(int dir, int axis_id); - class PADconf { u32 ff_intensity; @@ -69,7 +49,6 @@ public: u32 packed_options; // Only first 8 bits of each 16 bits series are really used, rest is padding }; - u32 keys[GAMEPAD_NUMBER][MAX_KEYS]; u32 log; u32 joyid_map; map keysym_map[GAMEPAD_NUMBER]; @@ -78,7 +57,6 @@ public: void init() { - memset(&keys, 0, sizeof(keys)); log = packed_options = joyid_map = 0; ff_intensity = 0x7FFF; // set it at max value by default sensibility = 500; diff --git a/plugins/onepad/keyboard.cpp b/plugins/onepad/keyboard.cpp index 3b5f02f56d..accf2ce80d 100644 --- a/plugins/onepad/keyboard.cpp +++ b/plugins/onepad/keyboard.cpp @@ -267,10 +267,13 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) { for (int i = 0; i < MAX_KEYS; i++) { + assert(0); +#if 0 if (wParam == get_key(pad, i)) { key_status->press(pad, i); break; } +#endif } } @@ -281,10 +284,13 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_KEYUP: for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) { for (int i = 0; i < MAX_KEYS; i++) { + assert(0); +#if 0 if (wParam == get_key(pad, i)) { key_status->release(pad, i); break; } +#endif } } diff --git a/plugins/onepad/onepad.cpp b/plugins/onepad/onepad.cpp index 57c9a7b158..1b47eaa8d5 100644 --- a/plugins/onepad/onepad.cpp +++ b/plugins/onepad/onepad.cpp @@ -158,8 +158,6 @@ void CloseLogging() void clearPAD(int pad) { conf->keysym_map[pad].clear(); - for (int key = 0; key < MAX_KEYS; ++key) - set_key(pad, key, 0); } EXPORT_C_(s32)