Removed static library in favor of shared libhydride
This commit is contained in:
parent
81d986c2ec
commit
631f3b931d
@ -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()
|
||||
|
@ -17,9 +17,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <hydride.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "lib/xoverlay.h"
|
||||
#include <embed_resources.hpp>
|
||||
#include <glez/detail/render.hpp>
|
||||
#include <glez/draw.hpp>
|
||||
@ -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;
|
||||
}
|
||||
|
Binary file not shown.
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
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
|
@ -19,10 +19,10 @@
|
||||
|
||||
#include <X11/Xutil.h> // For xlibs keycodes, window geometry
|
||||
#include <bitset> // For caching pressed keys
|
||||
#include <hydride.h>
|
||||
|
||||
#include "functional.hpp"
|
||||
|
||||
#include "../example-src/lib/xoverlay.h"
|
||||
#include "input.hpp"
|
||||
|
||||
namespace input {
|
||||
@ -159,12 +159,12 @@ static std::pair<int, int> 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)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user