mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Updated SwkbdInlineCalcArg struct. Added: swkbdInlineSetKeytopBgAlpha, swkbdInlineSetFooterBgAlpha, swkbdInlineSetKeytopScale, and swkbdInlineSetKeytopTranslate. Implemented field updating in swkbdInlineUpdate.
This commit is contained in:
parent
8cc321d0f1
commit
4250fb3752
@ -156,12 +156,12 @@ typedef struct {
|
|||||||
u8 unk_x468[5];
|
u8 unk_x468[5];
|
||||||
u16 unk_x46d;
|
u16 unk_x46d;
|
||||||
u8 unk_x46f;
|
u8 unk_x46f;
|
||||||
float keytopScale0; ///< Flags bitmask 0x200.
|
float keytopScaleX; ///< Flags bitmask 0x200.
|
||||||
float keytopScale1; ///< Flags bitmask 0x200.
|
float keytopScaleY; ///< Flags bitmask 0x200.
|
||||||
float keytopTranslate0; ///< Flags bitmask 0x200.
|
float keytopTranslateX; ///< Flags bitmask 0x200.
|
||||||
float keytopTranslate1; ///< Flags bitmask 0x200.
|
float keytopTranslateY; ///< Flags bitmask 0x200.
|
||||||
float keytopBgAlpha; ///< Flags bitmask 0x100.
|
float keytopBgAlpha; ///< Flags bitmask 0x100.
|
||||||
float unk_x484;
|
float footerBgAlpha; ///< Flags bitmask 0x100.
|
||||||
float balloonScale; ///< Flags bitmask 0x200.
|
float balloonScale; ///< Flags bitmask 0x200.
|
||||||
float unk_x48c;
|
float unk_x48c;
|
||||||
u8 unk_x490[0xc];
|
u8 unk_x490[0xc];
|
||||||
@ -403,6 +403,39 @@ void swkbdInlineSetInputModeFadeType(SwkbdInline* s, u8 type);
|
|||||||
*/
|
*/
|
||||||
void swkbdInlineSetAlphaEnabledInInputMode(SwkbdInline* s, bool flag);
|
void swkbdInlineSetAlphaEnabledInInputMode(SwkbdInline* s, bool flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets KeytopBgAlpha.
|
||||||
|
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
||||||
|
* @param s SwkbdInline object.
|
||||||
|
* @param alpha Alpha, clamped to range 0.0f..1.0f.
|
||||||
|
*/
|
||||||
|
void swkbdInlineSetKeytopBgAlpha(SwkbdInline* s, float alpha);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets FooterBgAlpha.
|
||||||
|
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
||||||
|
* @param s SwkbdInline object.
|
||||||
|
* @param alpha Alpha, clamped to range 0.0f..1.0f.
|
||||||
|
*/
|
||||||
|
void swkbdInlineSetFooterBgAlpha(SwkbdInline* s, float alpha);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets gfx scaling. Configures KeytopScale* and BalloonScale based on the input value.
|
||||||
|
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
||||||
|
* @param s SwkbdInline object.
|
||||||
|
* @param scale Scale
|
||||||
|
*/
|
||||||
|
void swkbdInlineSetKeytopScale(SwkbdInline* s, float scale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets gfx translation for the displayed swkbd image position.
|
||||||
|
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
||||||
|
* @param s SwkbdInline object.
|
||||||
|
* @param x X
|
||||||
|
* @param y Y
|
||||||
|
*/
|
||||||
|
void swkbdInlineSetKeytopTranslate(SwkbdInline* s, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets KeytopAsFloating.
|
* @brief Sets KeytopAsFloating.
|
||||||
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
* @note \ref swkbdInlineUpdate must be called at some point afterwards for this to take affect.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <math.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "kernel/detect.h"
|
#include "kernel/detect.h"
|
||||||
@ -32,6 +33,16 @@ static ssize_t _swkbdConvertToUTF16ByteSize(u16* out, const char* in, size_t max
|
|||||||
return _swkbdConvertToUTF16(out, in, (max/sizeof(u16)) - 1);
|
return _swkbdConvertToUTF16(out, in, (max/sizeof(u16)) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clamp a float to the range 0.0f..1.0.f.
|
||||||
|
static void _swkbdClampFloat(float *val) {
|
||||||
|
float tmpval = *val;
|
||||||
|
|
||||||
|
tmpval = fminf(tmpval, 1.0f);
|
||||||
|
tmpval = fmaxf(tmpval, 0.0f);
|
||||||
|
|
||||||
|
*val = tmpval;
|
||||||
|
}
|
||||||
|
|
||||||
static void _swkbdConfigClear(SwkbdConfig* c) {
|
static void _swkbdConfigClear(SwkbdConfig* c) {
|
||||||
memset(&c->arg.arg, 0, sizeof(c->arg.arg));
|
memset(&c->arg.arg, 0, sizeof(c->arg.arg));
|
||||||
memset(c->arg.unk_x3e0, 0xff, sizeof(c->arg.unk_x3e0));
|
memset(c->arg.unk_x3e0, 0xff, sizeof(c->arg.unk_x3e0));
|
||||||
@ -354,10 +365,10 @@ Result swkbdInlineCreate(SwkbdInline* s) {
|
|||||||
s->calcArg.footerScalable = 1;
|
s->calcArg.footerScalable = 1;
|
||||||
s->calcArg.inputModeFadeType = 1;
|
s->calcArg.inputModeFadeType = 1;
|
||||||
|
|
||||||
s->calcArg.keytopScale0 = 1.0f;
|
s->calcArg.keytopScaleX = 1.0f;
|
||||||
s->calcArg.keytopScale1 = 1.0f;
|
s->calcArg.keytopScaleY = 1.0f;
|
||||||
s->calcArg.keytopBgAlpha = 1.0f;
|
s->calcArg.keytopBgAlpha = 1.0f;
|
||||||
s->calcArg.unk_x484 = 1.0f;
|
s->calcArg.footerBgAlpha = 1.0f;
|
||||||
s->calcArg.balloonScale = 1.0f;
|
s->calcArg.balloonScale = 1.0f;
|
||||||
s->calcArg.unk_x48c = 1.0f;
|
s->calcArg.unk_x48c = 1.0f;
|
||||||
|
|
||||||
@ -439,7 +450,16 @@ Result swkbdInlineUpdate(SwkbdInline* s) {
|
|||||||
AppletStorage storage;
|
AppletStorage storage;
|
||||||
u32 tmp0=0, tmp1=0;
|
u32 tmp0=0, tmp1=0;
|
||||||
|
|
||||||
//TODO: 'Normalize' floats.
|
u8 fadetype=0;
|
||||||
|
if (s->calcArg.footerScalable) {
|
||||||
|
swkbdInlineSetFooterBgAlpha(s, s->calcArg.keytopBgAlpha);
|
||||||
|
|
||||||
|
fadetype = s->calcArg.keytopBgAlpha != 1.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fadetype = 2;
|
||||||
|
}
|
||||||
|
swkbdInlineSetInputModeFadeType(s, fadetype);
|
||||||
|
|
||||||
if (appletHolderCheckFinished(&s->holder)) {
|
if (appletHolderCheckFinished(&s->holder)) {
|
||||||
appletHolderJoin(&s->holder);
|
appletHolderJoin(&s->holder);
|
||||||
@ -583,6 +603,20 @@ void swkbdInlineSetAlphaEnabledInInputMode(SwkbdInline* s, bool flag) {
|
|||||||
_swkbdInlineSetBoolFlag(s, &s->calcArg.alphaEnabledInInputMode, flag, 0x100);
|
_swkbdInlineSetBoolFlag(s, &s->calcArg.alphaEnabledInInputMode, flag, 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swkbdInlineSetKeytopBgAlpha(SwkbdInline* s, float alpha) {
|
||||||
|
_swkbdClampFloat(&alpha);
|
||||||
|
if (s->calcArg.keytopBgAlpha == alpha) return;
|
||||||
|
s->calcArg.keytopBgAlpha = alpha;
|
||||||
|
s->calcArg.flags |= 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swkbdInlineSetFooterBgAlpha(SwkbdInline* s, float alpha) {
|
||||||
|
_swkbdClampFloat(&alpha);
|
||||||
|
if (s->calcArg.footerBgAlpha == alpha) return;
|
||||||
|
s->calcArg.footerBgAlpha = alpha;
|
||||||
|
s->calcArg.flags |= 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
void swkbdInlineSetKeytopAsFloating(SwkbdInline* s, bool flag) {
|
void swkbdInlineSetKeytopAsFloating(SwkbdInline* s, bool flag) {
|
||||||
_swkbdInlineSetBoolFlag(s, &s->calcArg.keytopAsFloating, flag, 0x200);
|
_swkbdInlineSetBoolFlag(s, &s->calcArg.keytopAsFloating, flag, 0x200);
|
||||||
}
|
}
|
||||||
@ -595,6 +629,33 @@ void swkbdInlineSetTouchFlag(SwkbdInline* s, bool flag) {
|
|||||||
_swkbdInlineSetBoolDisableFlag(s, &s->calcArg.disableTouch, flag, 0x200);
|
_swkbdInlineSetBoolDisableFlag(s, &s->calcArg.disableTouch, flag, 0x200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _swkbdInlineSetKeytopScale(SwkbdInline* s, float x, float y) {
|
||||||
|
if (s->calcArg.keytopScaleX == x && s->calcArg.keytopScaleY == y) return;
|
||||||
|
s->calcArg.keytopScaleX = x;
|
||||||
|
s->calcArg.keytopScaleY = y;
|
||||||
|
s->calcArg.flags |= 0x200;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _swkbdInlineSetBalloonScale(SwkbdInline* s, float scale) {
|
||||||
|
if (s->calcArg.balloonScale == scale) return;
|
||||||
|
s->calcArg.balloonScale = scale;
|
||||||
|
s->calcArg.flags |= 0x200;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swkbdInlineSetKeytopScale(SwkbdInline* s, float scale) {
|
||||||
|
_swkbdInlineSetKeytopScale(s, scale, scale);
|
||||||
|
|
||||||
|
scale = fminf(scale + 0.15f, 1.0f);
|
||||||
|
_swkbdInlineSetBalloonScale(s, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void swkbdInlineSetKeytopTranslate(SwkbdInline* s, float x, float y) {
|
||||||
|
if (s->calcArg.keytopTranslateX == x && s->calcArg.keytopTranslateY == y) return;
|
||||||
|
s->calcArg.keytopTranslateX = x;
|
||||||
|
s->calcArg.keytopTranslateY = y;
|
||||||
|
s->calcArg.flags |= 0x200;
|
||||||
|
}
|
||||||
|
|
||||||
void swkbdInlineSetUSBKeyboardFlag(SwkbdInline* s, bool flag) {
|
void swkbdInlineSetUSBKeyboardFlag(SwkbdInline* s, bool flag) {
|
||||||
_swkbdInlineSetBoolDisableFlag(s, &s->calcArg.disableUSBKeyboard, flag, 0x800);
|
_swkbdInlineSetBoolDisableFlag(s, &s->calcArg.disableUSBKeyboard, flag, 0x800);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user