mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
Distinguish between lmeta and rmeta key, add menu key
This commit is contained in:
parent
738b2936e4
commit
9367ad586a
@ -1215,16 +1215,19 @@ handle_keypress(XKeyEvent &event) {
|
||||
|
||||
// Now get the raw unshifted button.
|
||||
ButtonHandle button = get_button(event, false);
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_down(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_down(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_down(KeyboardButton::alt());
|
||||
}
|
||||
if (button != ButtonHandle::none()) {
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_down(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_down(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_down(KeyboardButton::alt());
|
||||
}
|
||||
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
||||
_input_devices[0].button_down(KeyboardButton::meta());
|
||||
}
|
||||
_input_devices[0].button_down(button);
|
||||
}
|
||||
}
|
||||
@ -1241,16 +1244,19 @@ handle_keyrelease(XKeyEvent &event) {
|
||||
|
||||
// Now get the raw unshifted button.
|
||||
ButtonHandle button = get_button(event, false);
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_up(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_up(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_up(KeyboardButton::alt());
|
||||
}
|
||||
if (button != ButtonHandle::none()) {
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_up(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_up(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_up(KeyboardButton::alt());
|
||||
}
|
||||
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
||||
_input_devices[0].button_up(KeyboardButton::meta());
|
||||
}
|
||||
_input_devices[0].button_up(button);
|
||||
}
|
||||
}
|
||||
@ -1636,6 +1642,8 @@ map_button(KeySym key) {
|
||||
return KeyboardButton::print_screen();
|
||||
case XK_Pause:
|
||||
return KeyboardButton::pause();
|
||||
case XK_Menu:
|
||||
return KeyboardButton::menu();
|
||||
case XK_Shift_L:
|
||||
return KeyboardButton::lshift();
|
||||
case XK_Shift_R:
|
||||
@ -1649,8 +1657,9 @@ map_button(KeySym key) {
|
||||
case XK_Alt_R:
|
||||
return KeyboardButton::ralt();
|
||||
case XK_Meta_L:
|
||||
return KeyboardButton::lmeta();
|
||||
case XK_Meta_R:
|
||||
return KeyboardButton::meta();
|
||||
return KeyboardButton::rmeta();
|
||||
case XK_Caps_Lock:
|
||||
return KeyboardButton::caps_lock();
|
||||
case XK_Shift_Lock:
|
||||
|
@ -49,7 +49,6 @@ ascii_key(const string &ascii_equivalent) {
|
||||
#define DEFINE_KEYBD_BUTTON_HANDLE(KeyName) \
|
||||
static ButtonHandle _##KeyName; \
|
||||
ButtonHandle KeyboardButton::KeyName() { return _##KeyName; }
|
||||
|
||||
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(space)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(backspace)
|
||||
@ -90,6 +89,7 @@ DEFINE_KEYBD_BUTTON_HANDLE(scroll_lock)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(num_lock)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(print_screen)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(pause)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(menu)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(shift)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(control)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(alt)
|
||||
@ -99,6 +99,8 @@ DEFINE_KEYBD_BUTTON_HANDLE(lcontrol)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(rcontrol)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(lalt)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(ralt)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(lmeta)
|
||||
DEFINE_KEYBD_BUTTON_HANDLE(rmeta)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -143,7 +145,7 @@ init_keyboard_buttons() {
|
||||
ButtonRegistry::ptr()->register_button(_left, "arrow_left");
|
||||
ButtonRegistry::ptr()->register_button(_right, "arrow_right");
|
||||
ButtonRegistry::ptr()->register_button(_up, "arrow_up"); // cannot name this 'up' since it conflicts with key-release name 'up'
|
||||
ButtonRegistry::ptr()->register_button(_down, "arrow_down");
|
||||
ButtonRegistry::ptr()->register_button(_down, "arrow_down");
|
||||
ButtonRegistry::ptr()->register_button(_page_up, "page_up");
|
||||
ButtonRegistry::ptr()->register_button(_page_down, "page_down");
|
||||
ButtonRegistry::ptr()->register_button(_home, "home");
|
||||
@ -161,6 +163,7 @@ init_keyboard_buttons() {
|
||||
ButtonRegistry::ptr()->register_button(_scroll_lock, "scroll_lock");
|
||||
ButtonRegistry::ptr()->register_button(_print_screen, "print_screen");
|
||||
ButtonRegistry::ptr()->register_button(_pause, "pause");
|
||||
ButtonRegistry::ptr()->register_button(_menu, "menu");
|
||||
|
||||
ButtonRegistry::ptr()->register_button(_lshift, "lshift", _shift);
|
||||
ButtonRegistry::ptr()->register_button(_rshift, "rshift", _shift);
|
||||
@ -168,12 +171,14 @@ init_keyboard_buttons() {
|
||||
ButtonRegistry::ptr()->register_button(_rcontrol, "rcontrol", _control);
|
||||
ButtonRegistry::ptr()->register_button(_lalt, "lalt", _alt);
|
||||
ButtonRegistry::ptr()->register_button(_ralt, "ralt", _alt);
|
||||
ButtonRegistry::ptr()->register_button(_lmeta, "lmeta", _meta);
|
||||
ButtonRegistry::ptr()->register_button(_rmeta, "rmeta", _meta);
|
||||
|
||||
// Also register all of the visible ASCII characters.
|
||||
for (int i = 32; i < 127; i++) {
|
||||
if (isgraph(i)) {
|
||||
ButtonHandle key;
|
||||
ButtonRegistry::ptr()->register_button(key, string(1, (char)i),
|
||||
ButtonRegistry::ptr()->register_button(key, string(1, (char)i),
|
||||
ButtonHandle::none(), i);
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ PUBLISHED:
|
||||
static ButtonHandle insert();
|
||||
static ButtonHandle del(); // delete is a C++ keyword.
|
||||
static ButtonHandle help();
|
||||
static ButtonHandle menu();
|
||||
|
||||
static ButtonHandle shift();
|
||||
static ButtonHandle control();
|
||||
@ -84,6 +85,8 @@ PUBLISHED:
|
||||
static ButtonHandle rcontrol();
|
||||
static ButtonHandle lalt();
|
||||
static ButtonHandle ralt();
|
||||
static ButtonHandle lmeta();
|
||||
static ButtonHandle rmeta();
|
||||
|
||||
public:
|
||||
static void init_keyboard_buttons();
|
||||
|
@ -2605,9 +2605,9 @@ lookup_raw_key(LPARAM lparam) const {
|
||||
switch (vsc) {
|
||||
case 87: return KeyboardButton::f11();
|
||||
case 88: return KeyboardButton::f12();
|
||||
//case 91: return KeyboardButton::lmeta();
|
||||
//case 92: return KeyboardButton::rmeta();
|
||||
//case 93: return KeyboardButton::menu();
|
||||
case 91: return KeyboardButton::lmeta();
|
||||
case 92: return KeyboardButton::rmeta();
|
||||
case 93: return KeyboardButton::menu();
|
||||
default: return ButtonHandle::none();
|
||||
}
|
||||
}
|
||||
|
@ -1392,16 +1392,19 @@ handle_keypress(XKeyEvent &event) {
|
||||
|
||||
// Now get the raw unshifted button.
|
||||
ButtonHandle button = get_button(event, false);
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_down(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_down(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_down(KeyboardButton::alt());
|
||||
}
|
||||
if (button != ButtonHandle::none()) {
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_down(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_down(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_down(KeyboardButton::alt());
|
||||
}
|
||||
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
||||
_input_devices[0].button_down(KeyboardButton::meta());
|
||||
}
|
||||
_input_devices[0].button_down(button);
|
||||
}
|
||||
|
||||
@ -1425,16 +1428,19 @@ handle_keyrelease(XKeyEvent &event) {
|
||||
|
||||
// Now get the raw unshifted button.
|
||||
ButtonHandle button = get_button(event, false);
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_up(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_up(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_up(KeyboardButton::alt());
|
||||
}
|
||||
if (button != ButtonHandle::none()) {
|
||||
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
||||
_input_devices[0].button_up(KeyboardButton::control());
|
||||
}
|
||||
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
||||
_input_devices[0].button_up(KeyboardButton::shift());
|
||||
}
|
||||
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
||||
_input_devices[0].button_up(KeyboardButton::alt());
|
||||
}
|
||||
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
||||
_input_devices[0].button_up(KeyboardButton::meta());
|
||||
}
|
||||
_input_devices[0].button_up(button);
|
||||
}
|
||||
|
||||
@ -1825,6 +1831,8 @@ map_button(KeySym key) {
|
||||
return KeyboardButton::print_screen();
|
||||
case XK_Pause:
|
||||
return KeyboardButton::pause();
|
||||
case XK_Menu:
|
||||
return KeyboardButton::menu();
|
||||
case XK_Shift_L:
|
||||
return KeyboardButton::lshift();
|
||||
case XK_Shift_R:
|
||||
@ -1838,8 +1846,9 @@ map_button(KeySym key) {
|
||||
case XK_Alt_R:
|
||||
return KeyboardButton::ralt();
|
||||
case XK_Meta_L:
|
||||
return KeyboardButton::lmeta();
|
||||
case XK_Meta_R:
|
||||
return KeyboardButton::meta();
|
||||
return KeyboardButton::rmeta();
|
||||
case XK_Caps_Lock:
|
||||
return KeyboardButton::caps_lock();
|
||||
case XK_Shift_Lock:
|
||||
@ -1963,9 +1972,9 @@ map_raw_button(KeyCode key) {
|
||||
|
||||
case 127: return KeyboardButton::pause();
|
||||
|
||||
//case 133: return KeyboardButton::lmeta();
|
||||
//case 134: return KeyboardButton::rmeta();
|
||||
//case 135: return KeyboardButton::menu();
|
||||
case 133: return KeyboardButton::lmeta();
|
||||
case 134: return KeyboardButton::rmeta();
|
||||
case 135: return KeyboardButton::menu();
|
||||
}
|
||||
return ButtonHandle::none();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user