mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Misc
This commit is contained in:
parent
8e775751fc
commit
ec57b692eb
7 changed files with 91 additions and 20 deletions
|
@ -210,11 +210,11 @@ extern "C" void JNICALL Java_com_turboviking_libnative_NativeApp_touch
|
|||
input_state.mouse_x[pointerId] = (int)x;
|
||||
input_state.mouse_y[pointerId] = (int)y;
|
||||
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_down[pointerId] = true;
|
||||
} else if (code == 2) {
|
||||
ILOG("Up: %i %f %f", pointerId, x, y);
|
||||
//ILOG("Up: %i %f %f", pointerId, x, y);
|
||||
input_state.mouse_last[pointerId] = input_state.mouse_down[pointerId];
|
||||
input_state.mouse_down[pointerId] = false;
|
||||
}
|
||||
|
|
|
@ -204,13 +204,15 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
InputState input_state;
|
||||
int framecount = 0;
|
||||
|
||||
bool nextFrameMD = 0;
|
||||
while (true) {
|
||||
SDL_Event event;
|
||||
|
||||
input_state.accelerometer_valid = false;
|
||||
input_state.mouse_valid = true;
|
||||
int done = 0;
|
||||
|
||||
// input_state.mouse_down[1] = nextFrameMD;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
done = 1;
|
||||
|
@ -221,19 +223,25 @@ int main(int argc, char *argv[]) {
|
|||
} else if (event.type == SDL_MOUSEMOTION) {
|
||||
input_state.mouse_x[0] = event.motion.x;
|
||||
input_state.mouse_y[0] = event.motion.y;
|
||||
input_state.mouse_x[1] = event.motion.x + 150;
|
||||
input_state.mouse_y[1] = event.motion.y;
|
||||
} else if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||
///input_state.mouse_buttons_down = 1;
|
||||
input_state.mouse_down[0] = true;
|
||||
input_state.mouse_down[0] = true;
|
||||
nextFrameMD = true;
|
||||
}
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP) {
|
||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||
input_state.mouse_down[0] = false;
|
||||
input_state.mouse_down[0] = false;
|
||||
nextFrameMD = false;
|
||||
//input_state.mouse_buttons_up = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (done) break;
|
||||
|
||||
input_state.mouse_last[0] = input_state.mouse_down[0];
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "math/math_util.h"
|
||||
#include "gfx_es2/draw_buffer.h"
|
||||
|
@ -86,7 +88,7 @@ void DrawBuffer::V(float x, float y, float z, uint32 color, float u, float v) {
|
|||
}
|
||||
|
||||
void DrawBuffer::Rect(float x, float y, float w, float h, uint32 color, int align) {
|
||||
DoAlign(align, &x, &y, w, h);
|
||||
DoAlign(align, &x, &y, &w, &h);
|
||||
RectVGradient(x, y, w, h, color, color);
|
||||
}
|
||||
|
||||
|
@ -290,22 +292,33 @@ void DrawBuffer::DrawTextShadow(int font, const char *text, float x, float y, Co
|
|||
DrawText(font, text, x, y, color, flags);
|
||||
}
|
||||
|
||||
void DrawBuffer::DoAlign(int align, float *x, float *y, float w, float h) {
|
||||
if (align & ALIGN_HCENTER) *x -= w / 2;
|
||||
if (align & ALIGN_RIGHT) *x -= w;
|
||||
if (align & ALIGN_VCENTER) *y -= h / 2;
|
||||
if (align & ALIGN_BOTTOM) *y -= h;
|
||||
void DrawBuffer::DoAlign(int flags, float *x, float *y, float *w, float *h) {
|
||||
if (flags & ALIGN_HCENTER) *x -= *w / 2;
|
||||
if (flags & ALIGN_RIGHT) *x -= *w;
|
||||
if (flags & ALIGN_VCENTER) *y -= *h / 2;
|
||||
if (flags & ALIGN_BOTTOM) *y -= *h;
|
||||
if (flags & (ROTATE_90DEG_LEFT | ROTATE_90DEG_RIGHT)) {
|
||||
std::swap(*w, *h);
|
||||
std::swap(*x, *y);
|
||||
}
|
||||
}
|
||||
|
||||
// ROTATE_* doesn't yet work right.
|
||||
void DrawBuffer::DrawText(int font, const char *text, float x, float y, Color color, int flags) {
|
||||
const AtlasFont &atlasfont = *atlas->fonts[font];
|
||||
unsigned char cval;
|
||||
float w, h;
|
||||
MeasureText(font, text, &w, &h);
|
||||
if (flags) {
|
||||
DoAlign(flags, &x, &y, w, h);
|
||||
DoAlign(flags, &x, &y, &w, &h);
|
||||
}
|
||||
y+=atlasfont.ascend*fontscaley;
|
||||
|
||||
if (flags & ROTATE_90DEG_LEFT) {
|
||||
x -= atlasfont.ascend*fontscaley;
|
||||
// y += h;
|
||||
}
|
||||
else
|
||||
y += atlasfont.ascend*fontscaley;
|
||||
float sx = x;
|
||||
while ((cval = *text++) != '\0') {
|
||||
if (cval == '\n') {
|
||||
|
@ -316,17 +329,28 @@ void DrawBuffer::DrawText(int font, const char *text, float x, float y, Color co
|
|||
if (cval < 32) continue;
|
||||
if (cval > 127) continue;
|
||||
AtlasChar c = atlasfont.chars[cval - 32];
|
||||
float cx1 = x + c.ox * fontscalex;
|
||||
float cy1 = y + c.oy * fontscaley;
|
||||
float cx2 = x + (c.ox + c.pw) * fontscalex;
|
||||
float cy2 = y + (c.oy + c.ph) * fontscaley;
|
||||
float cx1, cy1, cx2, cy2;
|
||||
if (flags & ROTATE_90DEG_LEFT) {
|
||||
cy1 = y - c.ox * fontscalex;
|
||||
cx1 = x + c.oy * fontscaley;
|
||||
cy2 = y - (c.ox + c.pw) * fontscalex;
|
||||
cx2 = x + (c.oy + c.ph) * fontscaley;
|
||||
} else {
|
||||
cx1 = x + c.ox * fontscalex;
|
||||
cy1 = y + c.oy * fontscaley;
|
||||
cx2 = x + (c.ox + c.pw) * fontscalex;
|
||||
cy2 = y + (c.oy + c.ph) * fontscaley;
|
||||
}
|
||||
V(cx1, cy1, color, c.sx, c.sy);
|
||||
V(cx2, cy1, color, c.ex, c.sy);
|
||||
V(cx2, cy2, color, c.ex, c.ey);
|
||||
V(cx1, cy1, color, c.sx, c.sy);
|
||||
V(cx2, cy2, color, c.ex, c.ey);
|
||||
V(cx1, cy2, color, c.sx, c.ey);
|
||||
x += c.wx * fontscalex;
|
||||
if (flags & ROTATE_90DEG_LEFT)
|
||||
y -= c.wx * fontscalex;
|
||||
else
|
||||
x += c.wx * fontscalex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ enum {
|
|||
ALIGN_TOPRIGHT = ALIGN_TOP | ALIGN_RIGHT,
|
||||
ALIGN_BOTTOMLEFT = ALIGN_BOTTOM | ALIGN_LEFT,
|
||||
ALIGN_BOTTOMRIGHT = ALIGN_BOTTOM | ALIGN_RIGHT,
|
||||
|
||||
// Only for text drawing
|
||||
ROTATE_90DEG_LEFT = 256,
|
||||
ROTATE_90DEG_RIGHT = 512,
|
||||
ROTATE_180DEG = 1024,
|
||||
};
|
||||
|
||||
struct GLSLProgram;
|
||||
|
@ -80,7 +85,7 @@ class DrawBuffer {
|
|||
void DrawImage2GridH(int atlas_image, float x1, float y1, float x2, Color color = COLOR(0xFFFFFF), float scale = 1.0);
|
||||
|
||||
void MeasureText(int font, const char *text, float *w, float *h);
|
||||
void DrawText(int font, const char *text, float x, float y, Color color = 0xFFFFFFFF, int flags = 0);
|
||||
void DrawText(int font, const char *text, float x, float y, Color color = 0xFFFFFFFF, int flags = 0);
|
||||
void DrawTextShadow(int font, const char *text, float x, float y, Color color = 0xFFFFFFFF, int flags = 0);
|
||||
|
||||
void RotateSprite(int atlas_entry, float x, float y, float angle, float scale, Color color);
|
||||
|
@ -93,7 +98,7 @@ class DrawBuffer {
|
|||
void EnableBlend(bool enable);
|
||||
|
||||
private:
|
||||
void DoAlign(int align, float *x, float *y, float w, float h);
|
||||
void DoAlign(int flags, float *x, float *y, float *w, float *h);
|
||||
struct Vertex {
|
||||
float x, y, z;
|
||||
uint8 r, g, b, a;
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
<ClInclude Include="midi\midi_input.h" />
|
||||
<ClInclude Include="profiler\profiler.h" />
|
||||
<ClInclude Include="ui\ui.h" />
|
||||
<ClInclude Include="util\bits\bits.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="android\app-android.cpp">
|
||||
|
@ -186,6 +187,7 @@
|
|||
<ClCompile Include="midi\midi_input.cpp" />
|
||||
<ClCompile Include="profiler\profiler.cpp" />
|
||||
<ClCompile Include="ui\ui.cpp" />
|
||||
<ClCompile Include="util\bits\bits.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -156,6 +156,9 @@
|
|||
<ClInclude Include="base\mutex.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="util\bits\bits.h">
|
||||
<Filter>util</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="gfx\gl_debug_log.cpp">
|
||||
|
@ -281,6 +284,9 @@
|
|||
<ClCompile Include="android\app-android.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="util\bits\bits.cpp">
|
||||
<Filter>util</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="gfx">
|
||||
|
@ -322,5 +328,8 @@
|
|||
<Filter Include="midi">
|
||||
<UniqueIdentifier>{4710a9a2-d1fa-4920-ba1b-a7527902be53}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="util">
|
||||
<UniqueIdentifier>{e36ca540-863c-496b-b0f4-b1ece3e72feb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -37,6 +37,29 @@ inline uint32_t _rotr(uint32_t val, int shift) {
|
|||
return (val << shift) | (val >> (31 - shift));
|
||||
}
|
||||
|
||||
/*
|
||||
template <int SZ>
|
||||
class BitArray {
|
||||
public:
|
||||
BitArray() {
|
||||
memset(data, 0, sizeof(data));
|
||||
}
|
||||
|
||||
BitArray And(const BitArray &other) {
|
||||
BitArray<SZ> retVal;
|
||||
for (int i = 0; i < DATACOUNT; i++) {
|
||||
retVal.data[i] = data[i] & other.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 data[(SZ + 31) / 32];
|
||||
enum {
|
||||
DATACOUNT = (SZ + 31) / 32;
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue