mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Basic DPI scaling hack.
This commit is contained in:
parent
e8ccae2266
commit
e7bf0303e2
4 changed files with 19 additions and 5 deletions
|
@ -22,8 +22,8 @@
|
||||||
#include "audio/mixer.h"
|
#include "audio/mixer.h"
|
||||||
#include "math/math_util.h"
|
#include "math/math_util.h"
|
||||||
|
|
||||||
#define coord_xres 800
|
#define coord_xres 480
|
||||||
#define coord_yres 480
|
#define coord_yres 800
|
||||||
|
|
||||||
static JNIEnv *jniEnvUI;
|
static JNIEnv *jniEnvUI;
|
||||||
|
|
||||||
|
@ -98,6 +98,13 @@ extern "C" void Java_com_turboviking_libnative_NativeApp_init
|
||||||
yres = yyres;
|
yres = yyres;
|
||||||
g_xres = xres;
|
g_xres = xres;
|
||||||
g_yres = yres;
|
g_yres = yres;
|
||||||
|
|
||||||
|
if (g_xres < g_yres)
|
||||||
|
{
|
||||||
|
// Portrait - let's force the imaginary resolution we want
|
||||||
|
g_xres = coord_xres;
|
||||||
|
g_yres = coord_yres;
|
||||||
|
}
|
||||||
xscale = (float)coord_xres / xres;
|
xscale = (float)coord_xres / xres;
|
||||||
yscale = (float)coord_yres / yres;
|
yscale = (float)coord_yres / yres;
|
||||||
memset(&input_state, 0, sizeof(input_state));
|
memset(&input_state, 0, sizeof(input_state));
|
||||||
|
@ -211,8 +218,8 @@ extern "C" void JNICALL Java_com_turboviking_libnative_NativeApp_touch
|
||||||
return; // We ignore 8+ pointers entirely.
|
return; // We ignore 8+ pointers entirely.
|
||||||
}
|
}
|
||||||
|
|
||||||
input_state.mouse_x[pointerId] = (int)x;
|
input_state.mouse_x[pointerId] = (int)(x * xscale);
|
||||||
input_state.mouse_y[pointerId] = (int)y;
|
input_state.mouse_y[pointerId] = (int)(y * yscale);
|
||||||
if (code == 1) {
|
if (code == 1) {
|
||||||
//ILOG("Down: %i %f %f", pointerId, x, y);
|
//ILOG("Down: %i %f %f", pointerId, x, y);
|
||||||
input_state.mouse_last[pointerId] = input_state.mouse_down[pointerId];
|
input_state.mouse_last[pointerId] = input_state.mouse_down[pointerId];
|
||||||
|
|
|
@ -16,4 +16,4 @@ public class NativeApp {
|
||||||
// Sensor/input data. These are asynchronous, beware!
|
// Sensor/input data. These are asynchronous, beware!
|
||||||
public static native void touch(float x, float y, int data, int pointerId);
|
public static native void touch(float x, float y, int data, int pointerId);
|
||||||
public static native void accelerometer(float x, float y, float z);
|
public static native void accelerometer(float x, float y, float z);
|
||||||
}
|
}
|
|
@ -14,6 +14,12 @@ uint32_t blackAlpha(float alpha) {
|
||||||
return (int)(alpha*255)<<24;
|
return (int)(alpha*255)<<24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t colorAlpha(uint32_t color, float alpha) {
|
||||||
|
if (alpha < 0.0f) alpha = 0.0f;
|
||||||
|
if (alpha > 1.0f) alpha = 1.0f;
|
||||||
|
return ((int)(alpha*255)<<24) | (color & 0xFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t rgba(float r, float g, float b, float alpha) {
|
uint32_t rgba(float r, float g, float b, float alpha) {
|
||||||
uint32_t color = (int)(alpha*255)<<24;
|
uint32_t color = (int)(alpha*255)<<24;
|
||||||
color |= (int)(b*255)<<16;
|
color |= (int)(b*255)<<16;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
uint32_t whiteAlpha(float alpha);
|
uint32_t whiteAlpha(float alpha);
|
||||||
uint32_t blackAlpha(float alpha);
|
uint32_t blackAlpha(float alpha);
|
||||||
|
uint32_t colorAlpha(uint32_t color, float alpha);
|
||||||
uint32_t rgba(float r, float g, float b, float alpha);
|
uint32_t rgba(float r, float g, float b, float alpha);
|
||||||
uint32_t rgba_clamp(float r, float g, float b, float alpha);
|
uint32_t rgba_clamp(float r, float g, float b, float alpha);
|
||||||
uint32_t hsva(float h, float s, float v, float alpha);
|
uint32_t hsva(float h, float s, float v, float alpha);
|
Loading…
Add table
Reference in a new issue