mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-15 10:44:14 +02:00
Update to v094r13 release.
byuu says: This version polishes up the input dialogue (reset, erase, disable button when item not focused, split device ID from mapping name), adds color emulation toggle, and add dummy menu items for remaining features (to be filled in later.) Also, it now compiles cleanly on Windows with GTK. I didn't test with TDM-GCC-32, because for god knows what reason, the 32-bit version ships with headers from Windows 95 OSR2 only. So I built with TDM-GCC-64 with arch=x86. And uh, apparently, moving or resizing a window causes a Visual C++ runtime exception in the GTK+ DLLs. This doesn't happen with trance or renshuu built with TDM-GCC-32. So, yeah, like I said, don't use -m32.
This commit is contained in:
@@ -3,7 +3,9 @@ namespace hiro {
|
||||
auto pKeyboard::poll() -> vector<bool> {
|
||||
vector<bool> result;
|
||||
char state[256];
|
||||
#if defined(PLATFORM_XORG)
|
||||
XQueryKeymap(pApplication::display, state);
|
||||
#endif
|
||||
for(auto& code : settings->keycodes) {
|
||||
result.append(_pressed(state, code));
|
||||
}
|
||||
@@ -12,15 +14,26 @@ auto pKeyboard::poll() -> vector<bool> {
|
||||
|
||||
auto pKeyboard::pressed(unsigned code) -> bool {
|
||||
char state[256];
|
||||
#if defined(PLATFORM_XORG)
|
||||
XQueryKeymap(pApplication::display, state);
|
||||
#endif
|
||||
return _pressed(state, code);
|
||||
}
|
||||
|
||||
auto pKeyboard::_pressed(char* state, uint16_t code) -> bool {
|
||||
auto pKeyboard::_pressed(const char* state, uint16_t code) -> bool {
|
||||
uint8_t lo = code >> 0;
|
||||
uint8_t hi = code >> 8;
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
if(lo && GetAsyncKeyState(lo) & 0x8000) return true;
|
||||
if(hi && GetAsyncKeyState(hi) & 0x8000) return true;
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
if(lo && state[lo >> 3] & (1 << (lo & 7))) return true;
|
||||
if(hi && state[hi >> 3] & (1 << (hi & 7))) return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -208,134 +221,24 @@ auto pKeyboard::_translate(unsigned code) -> signed {
|
||||
|
||||
auto pKeyboard::initialize() -> void {
|
||||
auto append = [](unsigned lo, unsigned hi = 0) {
|
||||
#if defined(PLATFORM_XORG)
|
||||
lo = lo ? (uint8_t)XKeysymToKeycode(pApplication::display, lo) : 0;
|
||||
hi = hi ? (uint8_t)XKeysymToKeycode(pApplication::display, hi) : 0;
|
||||
#endif
|
||||
settings->keycodes.append(lo | (hi << 8));
|
||||
};
|
||||
|
||||
#define map(name, ...) if(key == name) { append(__VA_ARGS__); continue; }
|
||||
for(auto& key : Keyboard::keys) {
|
||||
map("Escape", XK_Escape);
|
||||
map("F1", XK_F1);
|
||||
map("F2", XK_F2);
|
||||
map("F3", XK_F3);
|
||||
map("F4", XK_F4);
|
||||
map("F5", XK_F5);
|
||||
map("F6", XK_F6);
|
||||
map("F7", XK_F7);
|
||||
map("F8", XK_F8);
|
||||
map("F9", XK_F9);
|
||||
map("F10", XK_F10);
|
||||
map("F11", XK_F11);
|
||||
map("F12", XK_F12);
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include <hiro/platform/windows/keyboard.hpp>
|
||||
#endif
|
||||
|
||||
map("PrintScreen", XK_Print);
|
||||
map("ScrollLock", XK_Scroll_Lock);
|
||||
map("Pause", XK_Pause);
|
||||
#if defined(PLATFORM_XORG)
|
||||
#include <hiro/platform/xorg/keyboard.hpp>
|
||||
#endif
|
||||
|
||||
map("Insert", XK_Insert);
|
||||
map("Delete", XK_Delete);
|
||||
map("Home", XK_Home);
|
||||
map("End", XK_End);
|
||||
map("PageUp", XK_Prior);
|
||||
map("PageDown", XK_Next);
|
||||
|
||||
map("Up", XK_Up);
|
||||
map("Down", XK_Down);
|
||||
map("Left", XK_Left);
|
||||
map("Right", XK_Right);
|
||||
|
||||
map("Grave", XK_asciitilde);
|
||||
map("1", XK_1);
|
||||
map("2", XK_2);
|
||||
map("3", XK_3);
|
||||
map("4", XK_4);
|
||||
map("5", XK_5);
|
||||
map("6", XK_6);
|
||||
map("7", XK_7);
|
||||
map("8", XK_8);
|
||||
map("9", XK_9);
|
||||
map("0", XK_0);
|
||||
map("Dash", XK_minus);
|
||||
map("Equal", XK_equal);
|
||||
map("Backspace", XK_BackSpace);
|
||||
|
||||
map("Tab", XK_Tab);
|
||||
map("CapsLock", XK_Caps_Lock);
|
||||
map("LeftEnter", XK_Return);
|
||||
map("LeftShift", XK_Shift_L);
|
||||
map("RightShift", XK_Shift_R);
|
||||
map("LeftControl", XK_Control_L);
|
||||
map("RightControl", XK_Control_R);
|
||||
map("LeftAlt", XK_Alt_L);
|
||||
map("RightAlt", XK_Alt_R);
|
||||
map("LeftSuper", XK_Super_L);
|
||||
map("RightSuper", XK_Super_R);
|
||||
map("Menu", XK_Menu);
|
||||
map("Space", XK_space);
|
||||
|
||||
map("OpenBracket", XK_bracketleft);
|
||||
map("CloseBracket", XK_bracketright);
|
||||
map("Backslash", XK_backslash);
|
||||
map("Semicolon", XK_semicolon);
|
||||
map("Apostrophe", XK_apostrophe);
|
||||
map("Comma", XK_comma);
|
||||
map("Period", XK_period);
|
||||
map("Slash", XK_slash);
|
||||
|
||||
map("A", XK_A);
|
||||
map("B", XK_B);
|
||||
map("C", XK_C);
|
||||
map("D", XK_D);
|
||||
map("E", XK_E);
|
||||
map("F", XK_F);
|
||||
map("G", XK_G);
|
||||
map("H", XK_H);
|
||||
map("I", XK_I);
|
||||
map("J", XK_J);
|
||||
map("K", XK_K);
|
||||
map("L", XK_L);
|
||||
map("M", XK_M);
|
||||
map("N", XK_N);
|
||||
map("O", XK_O);
|
||||
map("P", XK_P);
|
||||
map("Q", XK_Q);
|
||||
map("R", XK_R);
|
||||
map("S", XK_S);
|
||||
map("T", XK_T);
|
||||
map("U", XK_U);
|
||||
map("V", XK_V);
|
||||
map("W", XK_W);
|
||||
map("X", XK_X);
|
||||
map("Y", XK_Y);
|
||||
map("Z", XK_Z);
|
||||
|
||||
map("NumLock", XK_Num_Lock);
|
||||
map("Divide", XK_KP_Divide);
|
||||
map("Multiply", XK_KP_Multiply);
|
||||
map("Subtract", XK_KP_Subtract);
|
||||
map("Add", XK_KP_Add);
|
||||
map("RightEnter", XK_KP_Enter);
|
||||
map("Point", XK_KP_Decimal);
|
||||
|
||||
map("One", XK_KP_1);
|
||||
map("Two", XK_KP_2);
|
||||
map("Three", XK_KP_3);
|
||||
map("Four", XK_KP_4);
|
||||
map("Five", XK_KP_5);
|
||||
map("Six", XK_KP_6);
|
||||
map("Seven", XK_KP_7);
|
||||
map("Eight", XK_KP_8);
|
||||
map("Nine", XK_KP_9);
|
||||
map("Zero", XK_KP_0);
|
||||
|
||||
map("Shift", XK_Shift_L, XK_Shift_R);
|
||||
map("Control", XK_Control_L, XK_Control_R);
|
||||
map("Alt", XK_Alt_L, XK_Alt_R);
|
||||
map("Super", XK_Super_L, XK_Super_R);
|
||||
map("Enter", XK_Return, XK_KP_Enter);
|
||||
|
||||
print("[phoenix/gtk] error: unhandled key: ", key, "\n");
|
||||
//print("[phoenix/gtk] warning: unhandled key: ", key, "\n");
|
||||
append(0);
|
||||
}
|
||||
#undef map
|
||||
|
Reference in New Issue
Block a user