ISO C90 fixes

This commit is contained in:
Ivan Epifanov
2020-12-18 14:28:09 +03:00
committed by Sam Lantinga
parent 0de7b0eca0
commit 7d89f09f74
11 changed files with 422 additions and 376 deletions
+2 -2
View File
@@ -87,8 +87,8 @@ VITAAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
} }
if(this->spec.freq < 48000) { if(this->spec.freq < 48000) {
port = SCE_AUDIO_OUT_PORT_TYPE_BGM; port = SCE_AUDIO_OUT_PORT_TYPE_BGM;
} }
this->hidden->channel = sceAudioOutOpenPort(port, this->spec.samples, this->spec.freq, format); this->hidden->channel = sceAudioOutOpenPort(port, this->spec.samples, this->spec.freq, format);
if (this->hidden->channel < 0) { if (this->hidden->channel < 0) {
+15 -13
View File
@@ -590,20 +590,22 @@ SDL_RWFromFile(const char *file, const char *mode)
rwops->close = windows_file_close; rwops->close = windows_file_close;
rwops->type = SDL_RWOPS_WINFILE; rwops->type = SDL_RWOPS_WINFILE;
#elif defined(__VITA__) #elif defined(__VITA__)
/* Try to open the file on the filesystem first */ {
FILE *fp = fopen(file, mode); /* Try to open the file on the filesystem first */
if (fp) { FILE *fp = fopen(file, mode);
return SDL_RWFromFP(fp, 1); if (fp) {
} else { return SDL_RWFromFP(fp, 1);
/* Try opening it from app0:/ container if it's a relative path */ } else {
char path[4096]; /* Try opening it from app0:/ container if it's a relative path */
SDL_snprintf(path, 4096, "app0:/%s", file); char path[4096];
fp = fopen(path, mode); SDL_snprintf(path, 4096, "app0:/%s", file);
if (fp) { fp = fopen(path, mode);
return SDL_RWFromFP(fp, 1); if (fp) {
} return SDL_RWFromFP(fp, 1);
}
}
SDL_SetError("Couldn't open %s", file);
} }
SDL_SetError("Couldn't open %s", file);
#elif HAVE_STDIO_H #elif HAVE_STDIO_H
{ {
#ifdef __APPLE__ #ifdef __APPLE__
+21 -21
View File
@@ -67,10 +67,10 @@ static point c = { 128, 32767 };
static point d = { 128, 32767 }; static point d = { 128, 32767 };
/* simple linear interpolation between two points */ /* simple linear interpolation between two points */
static SDL_INLINE void lerp (point *dest, point *a, point *b, float t) static SDL_INLINE void lerp (point *dest, point *first, point *second, float t)
{ {
dest->x = a->x + (b->x - a->x)*t; dest->x = first->x + (second->x - first->x) * t;
dest->y = a->y + (b->y - a->y)*t; dest->y = first->y + (second->y - first->y) * t;
} }
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ /* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */
@@ -93,6 +93,7 @@ static int calc_bezier_y(float t)
int VITA_JoystickInit(void) int VITA_JoystickInit(void)
{ {
int i; int i;
SceCtrlPortInfo myPortInfo;
/* Setup input */ /* Setup input */
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE);
@@ -106,27 +107,26 @@ int VITA_JoystickInit(void)
analog_map[127-i] = -1 * analog_map[i+128]; analog_map[127-i] = -1 * analog_map[i+128];
} }
SceCtrlPortInfo myPortInfo; // Assume we have at least one controller, even when nothing is paired
// This way the user can jump in, pair a controller
// and control things immediately even if it is paired
// after the app has already started.
// Assume we have at least one controller, even when nothing is paired SDL_numjoysticks = 1;
// This way the user can jump in, pair a controller
// and control things immediately even if it is paired
// after the app has already started.
SDL_numjoysticks = 1; // How many additional paired controllers are there?
sceCtrlGetControllerPortInfo(&myPortInfo);
//How many additional paired controllers are there? // On Vita TV, port 0 and 1 are the same controller
sceCtrlGetControllerPortInfo(&myPortInfo); // and that is the first one, so start at port 2
//On Vita TV, port 0 and 1 are the same controller for (i=2; i<=4; i++)
//and that is the first one, so start at port 2 {
for (i=2; i<=4; i++) if (myPortInfo.port[i]!=SCE_CTRL_TYPE_UNPAIRED)
{ {
if (myPortInfo.port[i]!=SCE_CTRL_TYPE_UNPAIRED) SDL_numjoysticks++;
{ }
SDL_numjoysticks++; }
} return SDL_numjoysticks;
}
return SDL_numjoysticks;
} }
int VITA_JoystickGetCount() int VITA_JoystickGetCount()
+56 -44
View File
@@ -470,12 +470,14 @@ VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
static int static int
VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
{ {
int color;
color_vertex *vertices;
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
cmd->data.draw.count = count; cmd->data.draw.count = count;
int color = data->drawstate.color; color = data->drawstate.color;
color_vertex *vertices = (color_vertex *)pool_memalign( vertices = (color_vertex *)pool_memalign(
data, data,
4 * count * sizeof(color_vertex), // 4 vertices * count 4 * count * sizeof(color_vertex), // 4 vertices * count
sizeof(color_vertex)); sizeof(color_vertex));
@@ -532,12 +534,13 @@ static int
VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_FRect * dstrect) const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{ {
texture_vertex *vertices;
float u0, v0, u1, v1;
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
cmd->data.draw.count = 1; cmd->data.draw.count = 1;
texture_vertex *vertices = (texture_vertex *)pool_memalign( vertices = (texture_vertex *)pool_memalign(
data, data,
4 * sizeof(texture_vertex), // 4 vertices 4 * sizeof(texture_vertex), // 4 vertices
sizeof(texture_vertex)); sizeof(texture_vertex));
@@ -545,10 +548,10 @@ VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture
cmd->data.draw.first = (size_t)vertices; cmd->data.draw.first = (size_t)vertices;
cmd->data.draw.texture = texture; cmd->data.draw.texture = texture;
const float u0 = (float)srcrect->x / (float)texture->w; u0 = (float)srcrect->x / (float)texture->w;
const float v0 = (float)srcrect->y / (float)texture->h; v0 = (float)srcrect->y / (float)texture->h;
const float u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w; u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w;
const float v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h; v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h;
vertices[0].x = dstrect->x; vertices[0].x = dstrect->x;
vertices[0].y = dstrect->y; vertices[0].y = dstrect->y;
@@ -582,11 +585,23 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
const SDL_Rect * srcrect, const SDL_FRect * dstrect, const SDL_Rect * srcrect, const SDL_FRect * dstrect,
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
{ {
texture_vertex *vertices;
float u0, v0, u1, v1;
float s, c;
float cw, sw, ch, sh;
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
const float centerx = center->x;
const float centery = center->y;
const float x = dstrect->x + centerx;
const float y = dstrect->y + centery;
const float width = dstrect->w - centerx;
const float height = dstrect->h - centery;
cmd->data.draw.count = 1; cmd->data.draw.count = 1;
texture_vertex *vertices = (texture_vertex *)pool_memalign( vertices = (texture_vertex *)pool_memalign(
data, data,
4 * sizeof(texture_vertex), // 4 vertices 4 * sizeof(texture_vertex), // 4 vertices
sizeof(texture_vertex)); sizeof(texture_vertex));
@@ -594,10 +609,10 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
cmd->data.draw.first = (size_t)vertices; cmd->data.draw.first = (size_t)vertices;
cmd->data.draw.texture = texture; cmd->data.draw.texture = texture;
float u0 = (float)srcrect->x / (float)texture->w; u0 = (float)srcrect->x / (float)texture->w;
float v0 = (float)srcrect->y / (float)texture->h; v0 = (float)srcrect->y / (float)texture->h;
float u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w; u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w;
float v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h; v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h;
if (flip & SDL_FLIP_VERTICAL) { if (flip & SDL_FLIP_VERTICAL) {
Swap(&v0, &v1); Swap(&v0, &v1);
@@ -607,20 +622,13 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
Swap(&u0, &u1); Swap(&u0, &u1);
} }
const float centerx = center->x;
const float centery = center->y;
const float x = dstrect->x + centerx;
const float y = dstrect->y + centery;
const float width = dstrect->w - centerx;
const float height = dstrect->h - centery;
float s, c;
MathSincos(degToRad(angle), &s, &c); MathSincos(degToRad(angle), &s, &c);
const float cw = c * width; cw = c * width;
const float sw = s * width; sw = s * width;
const float ch = c * height; ch = c * height;
const float sh = s * height; sh = s * height;
vertices[0].x = x - cw + sh; vertices[0].x = x - cw + sh;
vertices[0].y = y - sw - ch; vertices[0].y = y - sw - ch;
@@ -654,9 +662,11 @@ VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Textur
static int static int
VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
{ {
void *color_buffer;
float clear_color[4];
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
float clear_color[4];
clear_color[0] = (cmd->data.color.r)/255.0f; clear_color[0] = (cmd->data.color.r)/255.0f;
clear_color[1] = (cmd->data.color.g)/255.0f; clear_color[1] = (cmd->data.color.g)/255.0f;
clear_color[2] = (cmd->data.color.b)/255.0f; clear_color[2] = (cmd->data.color.b)/255.0f;
@@ -669,7 +679,6 @@ VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
sceGxmSetFragmentProgram(data->gxm_context, data->clearFragmentProgram); sceGxmSetFragmentProgram(data->gxm_context, data->clearFragmentProgram);
// set the clear color // set the clear color
void *color_buffer;
sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &color_buffer); sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &color_buffer);
sceGxmSetUniformDataF(color_buffer, data->clearClearColorParam, 0, 4, clear_color); sceGxmSetUniformDataF(color_buffer, data->clearClearColorParam, 0, 4, clear_color);
@@ -726,6 +735,7 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
SceGxmVertexProgram *vertex_program; SceGxmVertexProgram *vertex_program;
SDL_bool matrix_updated = SDL_FALSE; SDL_bool matrix_updated = SDL_FALSE;
SDL_bool program_updated = SDL_FALSE; SDL_bool program_updated = SDL_FALSE;
Uint32 texture_color;
Uint8 r, g, b, a; Uint8 r, g, b, a;
r = cmd->data.draw.r; r = cmd->data.draw.r;
@@ -802,7 +812,7 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
program_updated = SDL_TRUE; program_updated = SDL_TRUE;
} }
Uint32 texture_color = ((a << 24) | (b << 16) | (g << 8) | r); texture_color = ((a << 24) | (b << 16) | (g << 8) | r);
if (program_updated || matrix_updated) { if (program_updated || matrix_updated) {
if (data->drawstate.fragment_program == data->textureFragmentProgram) { if (data->drawstate.fragment_program == data->textureFragmentProgram) {
@@ -811,13 +821,14 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix); sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix);
} else if (data->drawstate.fragment_program == data->textureTintFragmentProgram) { } else if (data->drawstate.fragment_program == data->textureTintFragmentProgram) {
void *vertex_wvp_buffer; void *vertex_wvp_buffer;
void *texture_tint_color_buffer;
float *tint_color;
sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer); sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer);
sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix); sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix);
void *texture_tint_color_buffer;
sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer); sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer);
float *tint_color = pool_memalign( tint_color = pool_memalign(
data, data,
4 * sizeof(float), // RGBA 4 * sizeof(float), // RGBA
sizeof(float) sizeof(float)
@@ -837,9 +848,10 @@ SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool s
} else { } else {
if (data->drawstate.fragment_program == data->textureTintFragmentProgram && data->drawstate.texture_color != texture_color) { if (data->drawstate.fragment_program == data->textureTintFragmentProgram && data->drawstate.texture_color != texture_color) {
void *texture_tint_color_buffer; void *texture_tint_color_buffer;
float *tint_color;
sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer); sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer);
float *tint_color = pool_memalign( tint_color = pool_memalign(
data, data,
4 * sizeof(float), // RGBA 4 * sizeof(float), // RGBA
sizeof(float) sizeof(float)
@@ -879,8 +891,8 @@ SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
static int static int
VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
{ {
StartDrawing(renderer);
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
StartDrawing(renderer);
data->drawstate.target = renderer->target; data->drawstate.target = renderer->target;
if (!data->drawstate.target) { if (!data->drawstate.target) {
@@ -963,13 +975,16 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *
void read_pixels(int x, int y, size_t width, size_t height, void *data) { void read_pixels(int x, int y, size_t width, size_t height, void *data) {
SceDisplayFrameBuf pParam; SceDisplayFrameBuf pParam;
int i, j;
Uint32 *out32;
Uint32 *in32;
pParam.size = sizeof(SceDisplayFrameBuf); pParam.size = sizeof(SceDisplayFrameBuf);
sceDisplayGetFrameBuf(&pParam, SCE_DISPLAY_SETBUF_NEXTFRAME); sceDisplayGetFrameBuf(&pParam, SCE_DISPLAY_SETBUF_NEXTFRAME);
int i, j; out32 = (Uint32 *)data;
Uint32 *out32 = (Uint32 *)data; in32 = (Uint32 *)pParam.base;
Uint32 *in32 = (Uint32 *)pParam.base;
in32 += (x + y * pParam.pitch); in32 += (x + y * pParam.pitch);
@@ -986,11 +1001,6 @@ static int
VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
Uint32 pixel_format, void *pixels, int pitch) Uint32 pixel_format, void *pixels, int pitch)
{ {
// TODO: read from texture rendertarget. Although no-one sane should do it.
if (renderer->target) {
return SDL_Unsupported();
}
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
size_t buflen; size_t buflen;
void *temp_pixels; void *temp_pixels;
@@ -999,6 +1009,12 @@ VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
int w, h, length, rows; int w, h, length, rows;
int status; int status;
// TODO: read from texture rendertarget. Although no-one sane should do it.
if (renderer->target) {
return SDL_Unsupported();
}
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
buflen = rect->h * temp_pitch; buflen = rect->h * temp_pitch;
if (buflen == 0) { if (buflen == 0) {
@@ -1047,14 +1063,10 @@ static void
VITA_GXM_RenderPresent(SDL_Renderer *renderer) VITA_GXM_RenderPresent(SDL_Renderer *renderer)
{ {
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
SceCommonDialogUpdateParam updateParam;
// sceGxmFinish(data->gxm_context);
data->displayData.address = data->displayBufferData[data->backBufferIndex]; data->displayData.address = data->displayBufferData[data->backBufferIndex];
SceCommonDialogUpdateParam updateParam;
SDL_memset(&updateParam, 0, sizeof(updateParam)); SDL_memset(&updateParam, 0, sizeof(updateParam));
updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT; updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT;
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -137,10 +137,10 @@ SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index)
static void static void
SDL_VITA_SensorUpdate(SDL_Sensor *sensor) SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
{ {
int err = SCE_OK;
SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES]; SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES];
SDL_memset(motionState, 0, sizeof(motionState)); SDL_memset(motionState, 0, sizeof(motionState));
int err = SCE_OK;
err = sceMotionGetSensorState(motionState, SCE_MOTION_MAX_NUM_STATES); err = sceMotionGetSensorState(motionState, SCE_MOTION_MAX_NUM_STATES);
if (err != SCE_OK) if (err != SCE_OK)
{ {
+5 -5
View File
@@ -20,7 +20,7 @@
*/ */
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
#ifdef SDL_TIMERS_VITA #ifdef SDL_TIMER_VITA
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_timer.h" #include "SDL_timer.h"
@@ -53,13 +53,13 @@ SDL_TicksQuit(void)
Uint32 SDL_GetTicks(void) Uint32 SDL_GetTicks(void)
{ {
uint64_t now;
Uint32 ticks;
if (!ticks_started) { if (!ticks_started) {
SDL_TicksInit(); SDL_TicksInit();
} }
uint64_t now;
Uint32 ticks;
now = sceKernelGetProcessTimeWide(); now = sceKernelGetProcessTimeWide();
ticks = (now - start)/1000; ticks = (now - start)/1000;
return (ticks); return (ticks);
@@ -85,7 +85,7 @@ void SDL_Delay(Uint32 ms)
sceKernelDelayThreadCB(ms * 1000); sceKernelDelayThreadCB(ms * 1000);
} }
#endif /* SDL_TIMERS_VITA */ #endif /* SDL_TIMER_VITA */
/* vim: ts=4 sw=4 /* vim: ts=4 sw=4
*/ */
+5 -4
View File
@@ -81,6 +81,11 @@ VITA_GL_CreateContext(_THIS, SDL_Window * window)
EGLint num_configs; EGLint num_configs;
int i; int i;
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLCHK(display = eglGetDisplay(0)); EGLCHK(display = eglGetDisplay(0));
EGLCHK(eglInitialize(display, NULL, NULL)); EGLCHK(eglInitialize(display, NULL, NULL));
@@ -122,10 +127,6 @@ VITA_GL_CreateContext(_THIS, SDL_Window * window)
return 0; return 0;
} }
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL)); EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL));
+59 -57
View File
@@ -105,70 +105,72 @@ VITA_PollKeyboard(void)
} }
} }
Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers; {
Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers;
if (changed_modifiers & 0x01) { if (changed_modifiers & 0x01) {
if (prev_modifiers & 0x01) { if (prev_modifiers & 0x01) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL);
}
} }
if (changed_modifiers & 0x02) {
if (prev_modifiers & 0x02) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
else { else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
} }
if (changed_modifiers & 0x04) {
if (prev_modifiers & 0x04) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT);
}
}
if (changed_modifiers & 0x08) {
if (prev_modifiers & 0x08) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI);
}
}
if (changed_modifiers & 0x10) {
if (prev_modifiers & 0x10) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL);
}
} }
if (changed_modifiers & 0x02) { if (changed_modifiers & 0x20) {
if (prev_modifiers & 0x02) { if (prev_modifiers & 0x20) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT);
}
} }
else { if (changed_modifiers & 0x40) {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); if (prev_modifiers & 0x40) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT);
}
} }
} if (changed_modifiers & 0x80) {
if (changed_modifiers & 0x04) { if (prev_modifiers & 0x80) {
if (prev_modifiers & 0x04) { SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT); }
} else {
else { SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI);
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT); }
}
}
if (changed_modifiers & 0x08) {
if (prev_modifiers & 0x08) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI);
}
}
if (changed_modifiers & 0x10) {
if (prev_modifiers & 0x10) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL);
}
}
if (changed_modifiers & 0x20) {
if (prev_modifiers & 0x20) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT);
}
}
if (changed_modifiers & 0x40) {
if (prev_modifiers & 0x40) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT);
}
}
if (changed_modifiers & 0x80) {
if (prev_modifiers & 0x80) {
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
}
else {
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI);
} }
} }
+5 -5
View File
@@ -77,13 +77,13 @@ VITA_QuitTouch(void){
void void
VITA_PollTouch(void) VITA_PollTouch(void)
{ {
SDL_FingerID finger_id = 0;
int port;
// We skip polling touch if no window is created // We skip polling touch if no window is created
if (Vita_Window == NULL) if (Vita_Window == NULL)
return; return;
SDL_FingerID finger_id = 0;
int port;
memcpy(touch_old, touch, sizeof(touch_old)); memcpy(touch_old, touch, sizeof(touch_old));
for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
@@ -97,8 +97,8 @@ VITA_PollTouch(void)
// for the back panel, the active touch area is used as reference // for the back panel, the active touch area is used as reference
float x = 0; float x = 0;
float y = 0; float y = 0;
VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range; float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range;
VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
finger_id = (SDL_FingerID) touch[port].report[i].id; finger_id = (SDL_FingerID) touch[port].report[i].id;
// Send an initial touch // Send an initial touch
@@ -134,8 +134,8 @@ VITA_PollTouch(void)
if (finger_up == 1) { if (finger_up == 1) {
float x = 0; float x = 0;
float y = 0; float y = 0;
VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range; float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range;
VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
finger_id = (SDL_FingerID) touch_old[port].report[i].id; finger_id = (SDL_FingerID) touch_old[port].report[i].id;
// Finger released from screen // Finger released from screen
SDL_SendTouch((SDL_TouchID)port, SDL_SendTouch((SDL_TouchID)port,
+4 -2
View File
@@ -327,6 +327,7 @@ void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
wchar_t *title = L""; wchar_t *title = L"";
wchar_t *text = L""; wchar_t *text = L"";
SceInt32 res;
SceImeDialogParam param; SceImeDialogParam param;
sceImeDialogParamInit(&param); sceImeDialogParamInit(&param);
@@ -342,7 +343,7 @@ void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
param.initialText = text; param.initialText = text;
param.inputTextBuffer = videodata->ime_buffer; param.inputTextBuffer = videodata->ime_buffer;
SceInt32 res = sceImeDialogInit(&param); res = sceImeDialogInit(&param);
if (res < 0) { if (res < 0) {
SDL_SetError("Failed to init IME dialog"); SDL_SetError("Failed to init IME dialog");
return; return;
@@ -413,14 +414,15 @@ void VITA_PumpEvents(_THIS)
// update IME status. Terminate, if finished // update IME status. Terminate, if finished
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) {
uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
SceImeDialogResult result; SceImeDialogResult result;
SDL_memset(&result, 0, sizeof(SceImeDialogResult)); SDL_memset(&result, 0, sizeof(SceImeDialogResult));
sceImeDialogGetResult(&result); sceImeDialogGetResult(&result);
// Convert UTF16 to UTF8 // Convert UTF16 to UTF8
uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
utf16_to_utf8(videodata->ime_buffer, utf8_buffer); utf16_to_utf8(videodata->ime_buffer, utf8_buffer);
// send sdl event // send sdl event
SDL_SendKeyboardText((const char*)utf8_buffer); SDL_SendKeyboardText((const char*)utf8_buffer);