From dcdbe4b339baf0134228787ecbb0f6495d1fc186 Mon Sep 17 00:00:00 2001 From: fireclawthefox Date: Thu, 21 Jul 2016 12:44:44 +0200 Subject: [PATCH] Add handling for new gamepad buttons Added handles to 1, 2, next and previous as available on the wiimote --- panda/src/device/evdevInputDevice.cxx | 12 ++++++++++++ panda/src/device/linuxJoystickDevice.cxx | 16 ++++++++++++++++ panda/src/putil/gamepadButton.cxx | 12 ++++++++++++ panda/src/putil/gamepadButton.h | 6 ++++++ 4 files changed, 46 insertions(+) diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index bb91144d6a..0bc4a8d9ff 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -693,6 +693,12 @@ map_button(int code) { case BTN_TR2: return GamepadButton::rtrigger(); + case BTN_1: + return GamepadButton::action_1(); + + case BTN_2: + return GamepadButton::action_2(); + case BTN_SELECT: return GamepadButton::back(); @@ -702,6 +708,12 @@ map_button(int code) { case BTN_MODE: return GamepadButton::guide(); + case KEY_NEXT: + return GamepadButton::next(); + + case KEY_PREVIOUS: + return GamepadButton::previous(); + case BTN_THUMBL: return GamepadButton::lstick(); diff --git a/panda/src/device/linuxJoystickDevice.cxx b/panda/src/device/linuxJoystickDevice.cxx index 8c3a91cb6b..b6b622412b 100644 --- a/panda/src/device/linuxJoystickDevice.cxx +++ b/panda/src/device/linuxJoystickDevice.cxx @@ -163,6 +163,14 @@ open_device() { handle = GamepadButton::rtrigger(); break; + case BTN_1: + handle = GamepadButton::action_1(); + break; + + case BTN_2: + handle = GamepadButton::action_2(); + break; + case BTN_SELECT: handle = GamepadButton::back(); break; @@ -175,6 +183,14 @@ open_device() { handle = GamepadButton::guide(); break; + case KEY_NEXT: + handle = GamepadButton::next(); + break; + + case KEY_PREVIOUS: + handle = GamepadButton::previous(); + break; + case BTN_THUMBL: handle = GamepadButton::lstick(); break; diff --git a/panda/src/putil/gamepadButton.cxx b/panda/src/putil/gamepadButton.cxx index fd6fa1b396..ba7fe41b5a 100644 --- a/panda/src/putil/gamepadButton.cxx +++ b/panda/src/putil/gamepadButton.cxx @@ -34,6 +34,9 @@ DEFINE_GAMEPAD_BUTTON_HANDLE(back) DEFINE_GAMEPAD_BUTTON_HANDLE(guide) DEFINE_GAMEPAD_BUTTON_HANDLE(start) +DEFINE_GAMEPAD_BUTTON_HANDLE(next) +DEFINE_GAMEPAD_BUTTON_HANDLE(previous) + DEFINE_GAMEPAD_BUTTON_HANDLE(action_a) DEFINE_GAMEPAD_BUTTON_HANDLE(action_b) DEFINE_GAMEPAD_BUTTON_HANDLE(action_c) @@ -41,6 +44,9 @@ DEFINE_GAMEPAD_BUTTON_HANDLE(action_x) DEFINE_GAMEPAD_BUTTON_HANDLE(action_y) DEFINE_GAMEPAD_BUTTON_HANDLE(action_z) +DEFINE_GAMEPAD_BUTTON_HANDLE(action_1) +DEFINE_GAMEPAD_BUTTON_HANDLE(action_2) + /** * This is intended to be called only once, by the static initialization * performed in config_util.cxx. @@ -63,10 +69,16 @@ init_gamepad_buttons() { ButtonRegistry::ptr()->register_button(_guide, "guide"); ButtonRegistry::ptr()->register_button(_start, "start"); + ButtonRegistry::ptr()->register_button(_next, "next"); + ButtonRegistry::ptr()->register_button(_previous, "previous"); + ButtonRegistry::ptr()->register_button(_action_a, "action_a"); ButtonRegistry::ptr()->register_button(_action_b, "action_b"); ButtonRegistry::ptr()->register_button(_action_c, "action_c"); ButtonRegistry::ptr()->register_button(_action_x, "action_x"); ButtonRegistry::ptr()->register_button(_action_y, "action_y"); ButtonRegistry::ptr()->register_button(_action_z, "action_z"); + + ButtonRegistry::ptr()->register_button(_action_1, "action_1"); + ButtonRegistry::ptr()->register_button(_action_2, "action_2"); } diff --git a/panda/src/putil/gamepadButton.h b/panda/src/putil/gamepadButton.h index b41f494b71..9a8597a6b9 100644 --- a/panda/src/putil/gamepadButton.h +++ b/panda/src/putil/gamepadButton.h @@ -40,6 +40,9 @@ PUBLISHED: static ButtonHandle guide(); static ButtonHandle start(); + static ButtonHandle next(); + static ButtonHandle previous(); + static ButtonHandle action_a(); static ButtonHandle action_b(); static ButtonHandle action_c(); @@ -47,6 +50,9 @@ PUBLISHED: static ButtonHandle action_y(); static ButtonHandle action_z(); + static ButtonHandle action_1(); + static ButtonHandle action_2(); + public: static void init_gamepad_buttons(); };