diff --git a/CMakeLists.txt b/CMakeLists.txt index 94de0f5..83c8ea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ if(PNG_FOUND AND GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND FREETYPE_FOUND) target_include_directories(example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/example-src/lib/" "${CMAKE_CURRENT_SOURCE_DIR}/include/") target_link_libraries(example libpdw - "${CMAKE_CURRENT_SOURCE_DIR}/example-src/lib/libxoverlay.a" + hydride glez ${PNG_LIBRARIES} GL GLU GLEW ${FREETYPE_LIBRARIES} ${X11_X11_LIB} ${X11_Xext_LIB} ${X11_Xfixes_LIB}) endif() diff --git a/example-src/example.cpp b/example-src/example.cpp index 7d380f7..e7c3a6d 100644 --- a/example-src/example.cpp +++ b/example-src/example.cpp @@ -17,9 +17,9 @@ * along with this program. If not, see . */ +#include #include -#include "lib/xoverlay.h" #include #include #include @@ -125,21 +125,21 @@ static const std::string menu_list = R"( )"; int main() { - xoverlay_init(); + hydride_init(); - glez::init(xoverlay_library.width, xoverlay_library.height); + glez::init(hydride_library.width, hydride_library.height); Canvas* canvas; { input::RefreshInput(); - xoverlay_draw_begin(); + hydride_draw_begin(); glez::begin(); canvas = new Canvas(); canvas->Setup(); glez::end(); - xoverlay_draw_end(); + hydride_draw_end(); } auto bounds = input::GetBounds(); @@ -178,11 +178,11 @@ int main() { /*for (auto& i : ui::BaseVar::GetList()) printf("ui::BaseVar: %s\n", i->command_name.c_str());*/ - xoverlay_show(); + hydride_show(); while (1) { input::RefreshInput(); // Must be called in that order. - xoverlay_draw_begin(); + hydride_draw_begin(); glez::begin(); { @@ -205,7 +205,7 @@ int main() { }*/ } glez::end(); - xoverlay_draw_end(); + hydride_draw_end(); } return 0; } diff --git a/example-src/lib/libxoverlay.a b/example-src/lib/libxoverlay.a deleted file mode 100644 index 5f60414..0000000 Binary files a/example-src/lib/libxoverlay.a and /dev/null differ diff --git a/example-src/lib/xoverlay.h b/example-src/lib/xoverlay.h deleted file mode 100644 index ddbb287..0000000 --- a/example-src/lib/xoverlay.h +++ /dev/null @@ -1,69 +0,0 @@ - -/* - * Copyright (C) 2017 nullifiedcat - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -struct xoverlay_library -{ - Display *display; - Window window; - Colormap colormap; - GC gc; - XGCValues gcvalues; - XFontStruct font; - int screen; - - int width; - int height; - - struct - { - int x; - int y; - } mouse; - - char init; - char drawing; - char mapped; -}; - -extern struct xoverlay_library xoverlay_library; - -int xoverlay_init(); - -void xoverlay_destroy(); - -void xoverlay_show(); - -void xoverlay_hide(); - -void xoverlay_draw_begin(); - -void xoverlay_draw_end(); - -#ifdef __cplusplus -} -#endif diff --git a/src/input.cpp b/src/input.cpp index 0d88cc1..cff2230 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -19,10 +19,10 @@ #include // For xlibs keycodes, window geometry #include // For caching pressed keys +#include #include "functional.hpp" -#include "../example-src/lib/xoverlay.h" #include "input.hpp" namespace input { @@ -159,12 +159,12 @@ static std::pair bounds(-1, -1); // Request this to update the input system on button, mouse, and window info void RefreshInput() { - if (!xoverlay_library.display || !xoverlay_library.window) + if (!hydride_library.display || !hydride_library.window) return; // Get window bounds - if (xoverlay_library.width != bounds.first || xoverlay_library.height != bounds.second) { // Activate on change - bounds = std::make_pair(xoverlay_library.width, xoverlay_library.height); + if (hydride_library.width != bounds.first || hydride_library.height != bounds.second) { // Activate on change + bounds = std::make_pair(hydride_library.width, hydride_library.height); input::bounds_event.Emit(bounds); } @@ -172,7 +172,7 @@ void RefreshInput() { Window root_return, child_return; int root_x, root_y, mousex, mousey; unsigned int mask_return; - if (XQueryPointer(xoverlay_library.display, xoverlay_library.window, &root_return, &child_return, &root_x, &root_y, &mousex, &mousey, &mask_return)) { // only update the cursor if this returns true + if (XQueryPointer(hydride_library.display, hydride_library.window, &root_return, &child_return, &root_x, &root_y, &mousex, &mousey, &mask_return)) { // only update the cursor if this returns true if ((mousex != mouse.first || mousey != mouse.second) // Activate on change && (mousex >= 0 && mousey >= 0 && mousex <= bounds.first && mousey <= bounds.second)) { // Clamp positions to the window mouse = std::make_pair(mousex, mousey); @@ -199,12 +199,12 @@ void RefreshInput() { // Find depressed keys and save them to the stored map char keys[32]; - XQueryKeymap(xoverlay_library.display, keys); + XQueryKeymap(hydride_library.display, keys); // Recurse through the map looking for depressed keys for (const auto& current : xlibToCatVar) { // Get the keycode for the key we are looking for... - int current_key = XKeysymToKeycode(xoverlay_library.display, current.first); + int current_key = XKeysymToKeycode(hydride_library.display, current.first); // Use the keymap with bitwise logic to get state, oof this took forever to make bool pressed = (keys[current_key / 8] & (1 << (current_key % 8)));