mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 01:02:36 +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:
@@ -1,6 +1,8 @@
|
||||
namespace hiro {
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
XlibDisplay* pApplication::display = nullptr;
|
||||
#endif
|
||||
|
||||
void pApplication::run() {
|
||||
if(Application::state.onMain) {
|
||||
@@ -24,10 +26,19 @@ void pApplication::processEvents() {
|
||||
void pApplication::quit() {
|
||||
//if gtk_main() was invoked, call gtk_main_quit()
|
||||
if(gtk_main_level()) gtk_main_quit();
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
//todo: Keyboard::poll() is being called after Application::quit();
|
||||
//so if display is closed; this causes a segfault
|
||||
//XCloseDisplay(display);
|
||||
//display = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pApplication::initialize() {
|
||||
#if defined(PLATFORM_XORG)
|
||||
display = XOpenDisplay(nullptr);
|
||||
#endif
|
||||
|
||||
settings = new Settings;
|
||||
settings->load();
|
||||
@@ -48,11 +59,24 @@ void pApplication::initialize() {
|
||||
strcpy(argv[1], "--g-fatal-warnings");
|
||||
#endif
|
||||
char** argvp = argv;
|
||||
gtk_init(&argc, &argvp);
|
||||
|
||||
gtk_init(&argc, &argvp);
|
||||
GtkSettings* gtkSettings = gtk_settings_get_default();
|
||||
|
||||
//allow buttons to show icons
|
||||
g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
|
||||
g_object_set(gtkSettings, "gtk-button-images", true, nullptr);
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
//there is a serious bug in GTK 2.24 for Windows with the "ime" (Windows IME) input method:
|
||||
//by default, it will be impossible to type in text fields at all.
|
||||
//there are various tricks to get around this; but they are unintuitive and unreliable.
|
||||
//the "ime" method is chosen when various international system locales (eg Japanese) are selected.
|
||||
//here, we override the default input method to use the "Simple" type instead to avoid the bug.
|
||||
//obviously, this has a drawback: in-place editing for IMEs will not work in this mode.
|
||||
g_object_set(gtkSettings, "gtk-im-module", "gtk-im-context-simple", nullptr);
|
||||
#endif
|
||||
|
||||
gtk_rc_parse_string(R"(
|
||||
style "HiroWindow"
|
||||
{
|
||||
|
@@ -1,7 +1,9 @@
|
||||
namespace hiro {
|
||||
|
||||
struct pApplication {
|
||||
#if defined(PLATFORM_XORG)
|
||||
static XlibDisplay* display;
|
||||
#endif
|
||||
|
||||
static void run();
|
||||
static bool pendingEvents();
|
||||
|
@@ -8,6 +8,13 @@ Size pDesktop::size() {
|
||||
}
|
||||
|
||||
Geometry pDesktop::workspace() {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
RECT rc;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
|
||||
return {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top};
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
XlibDisplay* display = XOpenDisplay(nullptr);
|
||||
int screen = DefaultScreen(display);
|
||||
|
||||
@@ -35,6 +42,7 @@ Geometry pDesktop::workspace() {
|
||||
gdk_screen_get_width(gdk_screen_get_default()),
|
||||
gdk_screen_get_height(gdk_screen_get_default())
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,41 @@
|
||||
#include <nall/xorg/guard.hpp>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||
#include <cairo.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <nall/xorg/guard.hpp>
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#define UNICODE
|
||||
#define WINVER 0x0601
|
||||
#define _WIN32_WINNT WINVER
|
||||
#define _WIN32_IE WINVER
|
||||
#define __MSVCRT_VERSION__ WINVER
|
||||
#define NOMINMAX
|
||||
#define TBS_TRANSPARENTBKGND 0x1000
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <uxtheme.h>
|
||||
#include <io.h>
|
||||
#include <shlobj.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkwin32.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||
#include <cairo.h>
|
||||
#include <nall/windows/registry.hpp>
|
||||
#include <nall/windows/utf8.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
#include <nall/xorg/guard.hpp>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
#include <gtksourceview/gtksourcelanguagemanager.h>
|
||||
#include <gtksourceview/gtksourcestyleschememanager.h>
|
||||
#include <cairo.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <nall/xorg/guard.hpp>
|
||||
#endif
|
||||
|
@@ -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
|
||||
|
@@ -4,7 +4,7 @@ struct pKeyboard {
|
||||
static auto poll() -> vector<bool>;
|
||||
static auto pressed(unsigned code) -> bool;
|
||||
|
||||
static auto _pressed(char* state, uint16_t code) -> bool;
|
||||
static auto _pressed(const char* state, uint16_t code) -> bool;
|
||||
static auto _translate(unsigned code) -> signed;
|
||||
|
||||
static auto initialize() -> void;
|
||||
|
@@ -1,14 +1,31 @@
|
||||
namespace hiro {
|
||||
|
||||
auto pMouse::position() -> Position {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
POINT point = {0};
|
||||
GetCursorPos(&point);
|
||||
return {point.x, point.y};
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
XlibWindow root, child;
|
||||
int rootx, rooty, winx, winy;
|
||||
unsigned int mask;
|
||||
XQueryPointer(pApplication::display, DefaultRootWindow(pApplication::display), &root, &child, &rootx, &rooty, &winx, &winy, &mask);
|
||||
return {rootx, rooty};
|
||||
#endif
|
||||
}
|
||||
|
||||
auto pMouse::pressed(Mouse::Button button) -> bool {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
switch(button) {
|
||||
case Mouse::Button::Left: return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
|
||||
case Mouse::Button::Middle: return GetAsyncKeyState(VK_MBUTTON) & 0x8000;
|
||||
case Mouse::Button::Right: return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
XlibWindow root, child;
|
||||
int rootx, rooty, winx, winy;
|
||||
unsigned int mask;
|
||||
@@ -18,6 +35,8 @@ auto pMouse::pressed(Mouse::Button button) -> bool {
|
||||
case Mouse::Button::Middle: return mask & Button2Mask;
|
||||
case Mouse::Button::Right: return mask & Button3Mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,13 @@ auto pViewport::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pViewport::handle() const -> uintptr_t {
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
return (uintptr_t)GDK_WINDOW_HWND(gtk_widget_get_window(gtkWidget));
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_XORG)
|
||||
return GDK_WINDOW_XID(gtk_widget_get_window(gtkWidget));
|
||||
#endif
|
||||
}
|
||||
|
||||
auto pViewport::setDroppable(bool droppable) -> void {
|
||||
|
Reference in New Issue
Block a user