# Changes
3ds Backend: - switch to shaderProgramUse Desktop Backend - Add Pre Alpha Text Input and Keyboard Support - Move Shader Attrib Setup into a function and callit every time we need a set up vbo - Move to Mat4 api Core: - Add fquat support - Add LoadFile2Str - Move Mat4 Lib from Project n73 to Palladium - Add full supprot for vec cross types - Add Normalize, Distance and Dot to all - Add Cross to vec3 Drivers: - Add a SetViewPort func to GFX - Add Keyboard keys and Flasg to Hid Image: - Add Vertical Flipping - Add Horizontal flipping UI7: - Fix Critical Bug in IO Viewport handler - Fix library list (error on MinGW for some reason) Lazyvec: - Split into multiple source files - Generate new functions (see core updates)
This commit is contained in:
@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
@ -33,6 +34,7 @@ SOFTWARE.
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <numbers>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
55
include/pd/core/fquat.hpp
Normal file
55
include/pd/core/fquat.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is based on fvec4
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
#include <pd/core/vec4.hpp>
|
||||
|
||||
namespace PD {
|
||||
class fquat : public fvec4 {
|
||||
constexpr fquat() : fvec4(0.f, 0.f, 0.f, 1.f) {}
|
||||
constexpr fquat(float x, float y, float z, float w) : fvec4(x, y, z, w) {}
|
||||
constexpr fquat(const fvec4& v) : fvec4(v) {}
|
||||
|
||||
static fquat Identity() { return fquat(0.f, 0.f, 0.f, 1.f); }
|
||||
|
||||
constexpr fquat Conjugate() const { return fquat(-x, -y, -z, w); }
|
||||
fquat Inverse() const {
|
||||
float len = SqLen();
|
||||
if (len == 0.0f) {
|
||||
return fquat();
|
||||
}
|
||||
return Conjugate() / len;
|
||||
}
|
||||
|
||||
fquat operator*(const fquat& v) const {
|
||||
return fquat(w * v.x + x * v.w + y * v.z - z * v.y,
|
||||
w * v.y - x * v.z + y * v.w + z * v.x,
|
||||
w * v.z + x * v.y - y * v.x + z * v.w,
|
||||
w * v.w - x * v.x - y * v.y - z * v.z);
|
||||
}
|
||||
};
|
||||
} // namespace PD
|
@ -36,6 +36,12 @@ namespace IO {
|
||||
* @return 8Bit FileBuffer
|
||||
*/
|
||||
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path);
|
||||
/**
|
||||
* Load a File into a std::string
|
||||
* @param path Path to the File
|
||||
* @return std::string file content
|
||||
*/
|
||||
PD_CORE_API std::string LoadFile2Str(const std::string& path);
|
||||
/**
|
||||
* Hash a 8Bit Memory Buffer
|
||||
* @param data 8Bit input Buffer
|
||||
|
@ -25,17 +25,118 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
#include <pd/core/vec3.hpp>
|
||||
|
||||
namespace PD {
|
||||
class PD_CORE_API Mat4 {
|
||||
public:
|
||||
Mat4() { Zeros(); }
|
||||
~Mat4() = default;
|
||||
namespace Numbers {
|
||||
constexpr float Tau = std::numbers::pi * 2.f;
|
||||
}
|
||||
constexpr float Radians(float v) { return v * (Numbers::Tau / 360.0f); }
|
||||
/**
|
||||
* Minimal Mtx4 Lib that precomputes
|
||||
* basic stuff stuff at compiletime
|
||||
*
|
||||
* This Lib includes Patches for work with Citro3D as well
|
||||
*
|
||||
* @note That this is not a full Matrix Library
|
||||
*/
|
||||
|
||||
void Zeros();
|
||||
void Ortho(float left, float right, float bottom, float top, float near,
|
||||
float far);
|
||||
struct PD_CORE_API Mat4 {
|
||||
std::array<float, 16> m;
|
||||
constexpr Mat4() : m{} {}
|
||||
constexpr static Mat4 Diagonal(float x, float y, float z, float w) {
|
||||
Mat4 ret;
|
||||
ret(0, 0) = x;
|
||||
ret(1, 1) = y;
|
||||
ret(2, 2) = z;
|
||||
ret(3, 3) = w;
|
||||
return ret;
|
||||
}
|
||||
constexpr static Mat4 Identity() { return Diagonal(1, 1, 1, 1); }
|
||||
|
||||
float m[16];
|
||||
constexpr float* Ptr() { return m.data(); }
|
||||
constexpr const float* Ptr() const { return m.data(); }
|
||||
|
||||
constexpr float& operator()(int row, int col) {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
constexpr float operator()(int row, int col) const {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr Mat4 operator*(const Mat4& v) const {
|
||||
Mat4 ret;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
float t = 0.f;
|
||||
for (int k = 0; k < 4; k++) {
|
||||
t += (*this)(i, k) * v(k, j);
|
||||
}
|
||||
ret(i, j) = t;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
constexpr Mat4& operator*=(const Mat4& v) {
|
||||
*this = *this * v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr static Mat4 Translate(float x, float y, float z) {
|
||||
Mat4 ret = Identity();
|
||||
ret(0, 3) = x;
|
||||
ret(1, 3) = y;
|
||||
ret(2, 3) = z;
|
||||
return ret;
|
||||
}
|
||||
|
||||
constexpr static Mat4 Scale(float x, float y, float z) {
|
||||
Mat4 ret;
|
||||
ret(0, 0) = x;
|
||||
ret(1, 1) = y;
|
||||
ret(2, 2) = z;
|
||||
ret(3, 3) = 1.f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
constexpr static Mat4 Ortho(float l, float r, float b, float t, float n,
|
||||
float f) {
|
||||
Mat4 ret;
|
||||
#ifdef __3DS__ // Patch to rotate the Matrix correctly
|
||||
ret(0, 1) = 2.f / (t - b);
|
||||
ret(0, 3) = (b + t) / (b - t);
|
||||
ret(1, 0) = 2.f / (l - r);
|
||||
ret(1, 3) = (l + r) / (r - l);
|
||||
ret(2, 2) = 1.f / (n - f);
|
||||
ret(2, 3) = 0.5f * (n + f) / (n - f) - 0.5f;
|
||||
#else
|
||||
ret(0, 0) = 2.0f / (r - l);
|
||||
ret(0, 3) = -(r + l) / (r - l);
|
||||
ret(1, 1) = 2.0f / (t - b);
|
||||
ret(1, 3) = -(t + b) / (t - b);
|
||||
ret(2, 2) = -2.0f / (f - n);
|
||||
ret(2, 3) = -(f + n) / (f - n);
|
||||
#endif
|
||||
ret(3, 3) = 1.f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Mat4 Rotate(fvec3 axis, float a);
|
||||
static Mat4 RotateX(float a);
|
||||
static Mat4 RotateY(float a);
|
||||
static Mat4 RotateZ(float a);
|
||||
static Mat4 Perspective(float fov, float aspect, float n, float f);
|
||||
static Mat4 LookAt(const fvec3& pos, const fvec3& center, const fvec3& up);
|
||||
};
|
||||
} // namespace PD
|
@ -23,7 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is generated by lazyvec
|
||||
// This file is generated by lazyvec 2.0.0
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
@ -33,20 +34,24 @@ class vec2 {
|
||||
T x;
|
||||
T y;
|
||||
|
||||
vec2() : x(0), y(0) {}
|
||||
// Constructors
|
||||
|
||||
constexpr vec2() : x(0), y(0) {}
|
||||
template <typename T1>
|
||||
vec2(T1 v) {
|
||||
constexpr vec2(T1 v) {
|
||||
x = (T)v;
|
||||
y = (T)v;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2(vec2<T1> v) {
|
||||
constexpr vec2(const vec2<T1>& v) {
|
||||
x = (T)v.x;
|
||||
y = (T)v.y;
|
||||
}
|
||||
|
||||
vec2(T x, T y) : x(x), y(y) {}
|
||||
constexpr explicit vec2(T x, T y) : x(x), y(y) {}
|
||||
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator+=(T1 v) {
|
||||
@ -144,14 +149,42 @@ class vec2 {
|
||||
return vec2<T>(x / (T)v.x, y / (T)v.y);
|
||||
}
|
||||
|
||||
vec2 operator-() const { return vec2(-x, -y); }
|
||||
// Generic Operations
|
||||
|
||||
bool operator==(const vec2& v) const { return x == v.x && y == v.y; }
|
||||
bool operator!=(const vec2& v) const { return !(*this == v); }
|
||||
vec2 operator-() const { return vec2(-x, -y); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec2<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y;
|
||||
}
|
||||
template <typename T1>
|
||||
bool operator!=(const vec2<T1>& v) const {
|
||||
return !(*this == v);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
double Len() const { return std::sqrt(SqLen()); }
|
||||
double SqLen() const { return x * x + y * y; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec2<T1>& v) const {
|
||||
return (*this - v).Len();
|
||||
}
|
||||
|
||||
vec2<T> Normalize() const {
|
||||
double l = Len();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
return *this / (T)l;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
T Dot(const vec2<T1>& v) const {
|
||||
return x * (T)v.x + y * (T)v.y;
|
||||
}
|
||||
|
||||
// Swap Functions
|
||||
void SwapXY() {
|
||||
T t = x;
|
||||
x = y;
|
||||
@ -159,6 +192,6 @@ class vec2 {
|
||||
}
|
||||
};
|
||||
using fvec2 = vec2<float>;
|
||||
using dvec2 = vec2<double>;
|
||||
using ivec2 = vec2<int>;
|
||||
using dvec2 = vec2<double>;
|
||||
} // namespace PD
|
||||
|
@ -23,8 +23,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is generated by lazyvec
|
||||
// This file is generated by lazyvec 2.0.0
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
// Extended includes (rename if you use other filenames/paths)
|
||||
#include <pd/core/vec2.hpp>
|
||||
|
||||
namespace PD {
|
||||
template <typename T>
|
||||
@ -34,22 +37,36 @@ class vec3 {
|
||||
T y;
|
||||
T z;
|
||||
|
||||
vec3() : x(0), y(0), z(0) {}
|
||||
// Constructors
|
||||
|
||||
constexpr vec3() : x(0), y(0), z(0) {}
|
||||
template <typename T1>
|
||||
explicit vec3(T1 v) {
|
||||
constexpr vec3(T1 v) {
|
||||
x = (T)v;
|
||||
y = (T)v;
|
||||
z = (T)v;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
explicit vec3(vec3<T1> v) {
|
||||
constexpr vec3(const vec3<T1>& v) {
|
||||
x = (T)v.x;
|
||||
y = (T)v.y;
|
||||
z = (T)v.z;
|
||||
}
|
||||
|
||||
vec3(T x, T y, T z) : x(x), y(y), z(z) {}
|
||||
constexpr explicit vec3(T x, T y, T z) : x(x), y(y), z(z) {}
|
||||
|
||||
// Extended Constructors
|
||||
template <typename T1>
|
||||
constexpr explicit vec3(const vec2<T1>& xy, T1 z) {
|
||||
{
|
||||
x = (T)xy.x;
|
||||
y = (T)xy.y;
|
||||
this->z = (T)z;
|
||||
}
|
||||
}
|
||||
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator+=(T1 v) {
|
||||
@ -155,16 +172,47 @@ class vec3 {
|
||||
return vec3<T>(x / (T)v.x, y / (T)v.y, z / (T)v.z);
|
||||
}
|
||||
|
||||
vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
// Generic Operations
|
||||
|
||||
bool operator==(const vec3& v) const {
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec3<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y && z == (T)v.z;
|
||||
}
|
||||
bool operator!=(const vec3& v) const { return !(*this == v); }
|
||||
template <typename T1>
|
||||
bool operator!=(const vec3<T1>& v) const {
|
||||
return !(*this == v);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
double Len() const { return std::sqrt(SqLen()); }
|
||||
double SqLen() const { return x * x + y * y + z * z; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec3<T1>& v) const {
|
||||
return (*this - v).Len();
|
||||
}
|
||||
|
||||
vec3<T> Normalize() const {
|
||||
double l = Len();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
return *this / (T)l;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
T Dot(const vec3<T1>& v) const {
|
||||
return x * (T)v.x + y * (T)v.y + z * (T)v.z;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> Cross(const vec3<T1>& v) const {
|
||||
return vec3<T>(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
|
||||
}
|
||||
|
||||
// Swap Functions
|
||||
void SwapXY() {
|
||||
T t = x;
|
||||
x = y;
|
||||
@ -182,6 +230,6 @@ class vec3 {
|
||||
}
|
||||
};
|
||||
using fvec3 = vec3<float>;
|
||||
using dvec3 = vec3<double>;
|
||||
using ivec3 = vec3<int>;
|
||||
using dvec3 = vec3<double>;
|
||||
} // namespace PD
|
||||
|
@ -23,9 +23,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is generated by lazyvec
|
||||
// This file is generated by lazyvec 2.0.0
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
#include <pd/core/vec2.hpp> // Extended
|
||||
// Extended includes (rename if you use other filenames/paths)
|
||||
#include <pd/core/vec2.hpp>
|
||||
#include <pd/core/vec3.hpp>
|
||||
|
||||
namespace PD {
|
||||
template <typename T>
|
||||
@ -36,9 +39,11 @@ class vec4 {
|
||||
T z;
|
||||
T w;
|
||||
|
||||
vec4() : x(0), y(0), z(0), w(0) {}
|
||||
// Constructors
|
||||
|
||||
constexpr vec4() : x(0), y(0), z(0), w(0) {}
|
||||
template <typename T1>
|
||||
explicit vec4(T1 v) {
|
||||
constexpr vec4(T1 v) {
|
||||
x = (T)v;
|
||||
y = (T)v;
|
||||
z = (T)v;
|
||||
@ -46,23 +51,37 @@ class vec4 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
explicit vec4(vec4<T1> v) {
|
||||
constexpr vec4(const vec4<T1>& v) {
|
||||
x = (T)v.x;
|
||||
y = (T)v.y;
|
||||
z = (T)v.z;
|
||||
w = (T)v.w;
|
||||
}
|
||||
|
||||
/** Extended Constructor */
|
||||
constexpr explicit vec4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
|
||||
|
||||
// Extended Constructors
|
||||
template <typename T1>
|
||||
explicit vec4(vec2<T1> a, vec2<T1> b) {
|
||||
x = (T)a.x;
|
||||
y = (T)a.y;
|
||||
z = (T)b.x;
|
||||
w = (T)b.y;
|
||||
constexpr explicit vec4(const vec2<T1>& xy, const vec2<T1>& zw) {
|
||||
{
|
||||
x = (T)xy.x;
|
||||
y = (T)xy.y;
|
||||
z = (T)zw.x;
|
||||
w = (T)zw.y;
|
||||
}
|
||||
}
|
||||
|
||||
vec4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
|
||||
template <typename T1>
|
||||
constexpr explicit vec4(const vec3<T1>& xyz, T1 w) {
|
||||
{
|
||||
x = (T)xyz.x;
|
||||
y = (T)xyz.y;
|
||||
z = (T)xyz.z;
|
||||
this->w = (T)w;
|
||||
}
|
||||
}
|
||||
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec4<T>& operator+=(T1 v) {
|
||||
@ -176,16 +195,42 @@ class vec4 {
|
||||
return vec4<T>(x / (T)v.x, y / (T)v.y, z / (T)v.z, w / (T)v.w);
|
||||
}
|
||||
|
||||
vec4 operator-() const { return vec4(-x, -y, -z, -w); }
|
||||
// Generic Operations
|
||||
|
||||
bool operator==(const vec4& v) const {
|
||||
return x == v.x && y == v.y && z == v.z && w == v.w;
|
||||
vec4 operator-() const { return vec4(-x, -y, -z, -w); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec4<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y && z == (T)v.z && w == (T)v.w;
|
||||
}
|
||||
bool operator!=(const vec4& v) const { return !(*this == v); }
|
||||
template <typename T1>
|
||||
bool operator!=(const vec4<T1>& v) const {
|
||||
return !(*this == v);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
double Len() const { return std::sqrt(SqLen()); }
|
||||
double SqLen() const { return x * x + y * y + z * z + w * w; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec4<T1>& v) const {
|
||||
return (*this - v).Len();
|
||||
}
|
||||
|
||||
vec4<T> Normalize() const {
|
||||
double l = Len();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
return *this / (T)l;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
T Dot(const vec4<T1>& v) const {
|
||||
return x * (T)v.x + y * (T)v.y + z * (T)v.z + w * (T)v.w;
|
||||
}
|
||||
|
||||
// Swap Functions
|
||||
void SwapXY() {
|
||||
T t = x;
|
||||
x = y;
|
||||
@ -218,6 +263,6 @@ class vec4 {
|
||||
}
|
||||
};
|
||||
using fvec4 = vec4<float>;
|
||||
using dvec4 = vec4<double>;
|
||||
using ivec4 = vec4<int>;
|
||||
using dvec4 = vec4<double>;
|
||||
} // namespace PD
|
||||
|
@ -52,6 +52,8 @@ class GfxDriver {
|
||||
|
||||
virtual void RenderDrawData(const std::vector<Command::Ref>& Commands) {}
|
||||
|
||||
void SetViewPort(const ivec2& vp) { ViewPort = vp; }
|
||||
|
||||
virtual Texture::Ref LoadTex(
|
||||
const std::vector<u8>& pixels, int w, int h,
|
||||
Texture::Type type = Texture::Type::RGBA32,
|
||||
@ -90,6 +92,7 @@ class Gfx {
|
||||
static void NewFrame() { pGfx->NewFrame(); }
|
||||
|
||||
static void BindTex(TexAddress addr) { pGfx->BindTex(addr); }
|
||||
static void SetViewPort(const ivec2& vp) { pGfx->SetViewPort(vp); }
|
||||
|
||||
static void RenderDrawData(const std::vector<Command::Ref>& Commands) {
|
||||
pGfx->RenderDrawData(Commands);
|
||||
|
@ -28,6 +28,14 @@ SOFTWARE.
|
||||
namespace PD {
|
||||
class HidDriver {
|
||||
public:
|
||||
enum Flags : u32 {
|
||||
Flags_None,
|
||||
FLags_HasGamepad,
|
||||
Flags_HasKeyboard,
|
||||
Flags_HasTouch,
|
||||
Flags_HasMouse,
|
||||
};
|
||||
// Todo: Name to GpKey (GamepadKey)
|
||||
/** Key [Controller] */
|
||||
enum Key : u32 {
|
||||
No = 0, ///< No Key
|
||||
@ -60,8 +68,68 @@ class HidDriver {
|
||||
Right = DRight | CPRight, ///< DPad or CPad Right
|
||||
};
|
||||
|
||||
// Dont want to use some hardcoded bitset
|
||||
// so lets use just numbers
|
||||
enum KbKey : u8 {
|
||||
Kb_No = 0,
|
||||
Kb_Escape = 1,
|
||||
Kb_Q = 2,
|
||||
Kb_W = 3,
|
||||
Kb_E = 4,
|
||||
Kb_R = 5,
|
||||
Kb_T = 6,
|
||||
// Yes i use QWERTZ Keyboard
|
||||
Kb_Z = 7,
|
||||
Kb_U = 8,
|
||||
Kb_I = 9,
|
||||
Kb_O = 10,
|
||||
Kb_P = 11,
|
||||
Kb_A = 12,
|
||||
Kb_S = 13,
|
||||
Kb_D = 14,
|
||||
Kb_F = 15,
|
||||
Kb_G = 16,
|
||||
Kb_H = 17,
|
||||
Kb_J = 18,
|
||||
Kb_K = 19,
|
||||
Kb_L = 20,
|
||||
Kb_Y = 21,
|
||||
Kb_X = 22,
|
||||
Kb_C = 23,
|
||||
Kb_V = 24,
|
||||
Kb_B = 25,
|
||||
Kb_N = 26,
|
||||
Kb_M = 27,
|
||||
Kb_LShift = 28,
|
||||
Kb_F1 = 29,
|
||||
Kb_F2 = 30,
|
||||
Kb_F3 = 31,
|
||||
Kb_F4 = 32,
|
||||
Kb_F5 = 33,
|
||||
Kb_F6 = 34,
|
||||
Kb_F7 = 35,
|
||||
Kb_F8 = 36,
|
||||
Kb_F9 = 37,
|
||||
Kb_F10 = 38,
|
||||
Kb_F11 = 39,
|
||||
Kb_F12 = 40,
|
||||
Kb_1 = 41,
|
||||
Kb_2 = 42,
|
||||
Kb_3 = 43,
|
||||
Kb_4 = 44,
|
||||
Kb_5 = 45,
|
||||
Kb_6 = 46,
|
||||
Kb_7 = 47,
|
||||
Kb_8 = 48,
|
||||
Kb_9 = 49,
|
||||
Kb_0 = 50,
|
||||
Kb_Backspace = 51,
|
||||
Kb_Enter = 52,
|
||||
};
|
||||
|
||||
/** Event */
|
||||
enum Event {
|
||||
Event_Null,
|
||||
Event_Down, ///< Key Pressed
|
||||
Event_Held, ///< Key Held
|
||||
Event_Up, ///< Key released
|
||||
@ -90,6 +158,7 @@ class HidDriver {
|
||||
* @return if key(s) doing the requiested event
|
||||
*/
|
||||
bool IsEvent(Event e, Key keys);
|
||||
bool IsEvent(Event e, KbKey key);
|
||||
/**
|
||||
* Check for Key Press Event
|
||||
* @param keys set of keys
|
||||
@ -160,12 +229,19 @@ class HidDriver {
|
||||
* Template Update Function for a device specific driver
|
||||
*/
|
||||
virtual void Update() {}
|
||||
/**
|
||||
* Get Text from Keyboard
|
||||
*/
|
||||
virtual void GetInputStr(std::string& str) {}
|
||||
|
||||
/** Data Section */
|
||||
|
||||
/** Backend Identification Name */
|
||||
const std::string pName;
|
||||
|
||||
/** Flags */
|
||||
u32 Flags = 0;
|
||||
|
||||
/** Key Binds Map */
|
||||
std::unordered_map<u32, u32> pBinds;
|
||||
/** Swap Tabe Function */
|
||||
@ -176,6 +252,8 @@ class HidDriver {
|
||||
bool pLocked = false;
|
||||
/** Key Event Table Setup */
|
||||
std::unordered_map<Event, u32> KeyEvents[2];
|
||||
/** Keyboard Key Event Table Setup */
|
||||
std::unordered_map<u32, Event> KbKeyEvents[2];
|
||||
};
|
||||
|
||||
/** Static Hid Controller */
|
||||
@ -186,6 +264,7 @@ class Hid {
|
||||
|
||||
/** Referenec to Drivers enums */
|
||||
using Key = HidDriver::Key;
|
||||
using KbKey = HidDriver::KbKey;
|
||||
using Event = HidDriver::Event;
|
||||
|
||||
static void Init(HidDriver::Ref v = nullptr) {
|
||||
@ -197,6 +276,7 @@ class Hid {
|
||||
}
|
||||
|
||||
static bool IsEvent(Event e, Key keys) { return pHid->IsEvent(e, keys); }
|
||||
static bool IsEvent(Event e, KbKey key) { return pHid->IsEvent(e, key); }
|
||||
static bool IsDown(Key keys) { return pHid->IsDown(keys); }
|
||||
static bool IsUp(Key keys) { return pHid->IsUp(keys); }
|
||||
static bool IsHeld(Key keys) { return pHid->IsHeld(keys); }
|
||||
@ -208,6 +288,8 @@ class Hid {
|
||||
static void Unlock() { pHid->Unlock(); }
|
||||
static bool Locked() { return pHid->Locked(); }
|
||||
static void Update() { pHid->Update(); }
|
||||
static u32 GetFlags() { return pHid->Flags; }
|
||||
static void GetStrInput(std::string& str) { pHid->GetInputStr(str); }
|
||||
|
||||
static HidDriver::Ref pHid;
|
||||
};
|
||||
|
@ -58,6 +58,9 @@ class PD_IMAGE_API Image {
|
||||
int Height() const { return pHeight; }
|
||||
Format Fmt() const { return pFmt; }
|
||||
|
||||
void FlipVertical();
|
||||
void FlipHorizontal();
|
||||
|
||||
u8& operator[](int idx) { return pBuffer[idx]; }
|
||||
u8 operator[](int idx) const { return pBuffer[idx]; }
|
||||
|
||||
|
@ -102,7 +102,7 @@ class PD_UI7_API IO {
|
||||
}
|
||||
|
||||
ViewPort::Ref GetViewPort(const ID& id) {
|
||||
if (ViewPorts.count(id)) {
|
||||
if (!ViewPorts.count(id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return ViewPorts[id];
|
||||
|
@ -39,6 +39,7 @@ class PD_UI7_API Layout {
|
||||
this->IO = io;
|
||||
DrawList = Li::DrawList::New();
|
||||
DrawList->SetFont(IO->Font);
|
||||
DrawList->SetFontScale(io->FontScale);
|
||||
Scrolling[0] = false;
|
||||
Scrolling[1] = false;
|
||||
CursorInit();
|
||||
|
@ -37,7 +37,7 @@ SOFTWARE.
|
||||
* Major Minor Patch Build
|
||||
* 0x01010000 -> 1.1.0-0
|
||||
*/
|
||||
#define UI7_VERSION 0x00050000
|
||||
#define UI7_VERSION 0x00050001
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
|
Reference in New Issue
Block a user