https://github.com/libsdl-org/SDL/commit/a4ddb175f1f1d832960c830191daaab7eb25638f
From a4ddb175f1f1d832960c830191daaab7eb25638f Mon Sep 17 00:00:00 2001
From: Ivan Epifanov <[EMAIL REDACTED]>
Date: Mon, 8 Mar 2021 19:28:58 +0300
Subject: [PATCH] Formatting
---
src/audio/vita/SDL_vitaaudio.c | 4 -
src/audio/vita/SDL_vitaaudio.h | 4 +-
src/joystick/vita/SDL_sysjoystick.c | 6 +-
src/thread/vita/SDL_sysmutex_c.h | 1 +
src/thread/vita/SDL_syssem.c | 3 +-
src/thread/vita/SDL_systhread.c | 3 +-
src/thread/vita/SDL_systhread_c.h | 2 +
src/timer/vita/SDL_systimer.c | 3 +-
src/video/vita/SDL_vitakeyboard.c | 292 ++++++++++++++--------------
src/video/vita/SDL_vitamessagebox.c | 4 +-
src/video/vita/SDL_vitamouse.c | 76 ++++----
src/video/vita/SDL_vitatouch.c | 206 ++++++++++----------
src/video/vita/SDL_vitavideo.h | 8 +-
13 files changed, 302 insertions(+), 310 deletions(-)
diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c
index 810b5f415..de2611bb5 100644
--- a/src/audio/vita/SDL_vitaaudio.c
+++ b/src/audio/vita/SDL_vitaaudio.c
@@ -172,10 +172,6 @@ VITAAUD_Init(SDL_AudioDriverImpl * impl)
impl->OnlyHasDefaultInputDevice = 1;
*/
- /*
- impl->DetectDevices = DSOUND_DetectDevices;
- impl->Deinitialize = DSOUND_Deinitialize;
- */
return 1; /* this audio target is available. */
}
diff --git a/src/audio/vita/SDL_vitaaudio.h b/src/audio/vita/SDL_vitaaudio.h
index 0c1ad523b..610a71998 100644
--- a/src/audio/vita/SDL_vitaaudio.h
+++ b/src/audio/vita/SDL_vitaaudio.h
@@ -41,5 +41,5 @@ struct SDL_PrivateAudioData {
};
#endif /* _SDL_vitaaudio_h */
-/* vim: ts=4 sw=4
- */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c
index efa78f17f..13439cad7 100644
--- a/src/joystick/vita/SDL_sysjoystick.c
+++ b/src/joystick/vita/SDL_sysjoystick.c
@@ -208,7 +208,6 @@ VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{
}
-
/* Function to open a joystick for use.
The joystick to open is specified by the device index.
This should fill the nbuttons and naxes fields of the joystick structure.
@@ -388,7 +387,6 @@ VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
return SDL_Unsupported();
}
-
SDL_JoystickDriver SDL_VITA_JoystickDriver =
{
VITA_JoystickInit,
@@ -414,8 +412,6 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver =
VITA_JoystickQuit,
};
-
#endif /* SDL_JOYSTICK_VITA */
-/* vim: ts=4 sw=4
- */
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/vita/SDL_sysmutex_c.h b/src/thread/vita/SDL_sysmutex_c.h
index 7481b6656..a05be0b26 100644
--- a/src/thread/vita/SDL_sysmutex_c.h
+++ b/src/thread/vita/SDL_sysmutex_c.h
@@ -19,4 +19,5 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c
index 466c5b136..e41946578 100644
--- a/src/thread/vita/SDL_syssem.c
+++ b/src/thread/vita/SDL_syssem.c
@@ -159,5 +159,4 @@ int SDL_SemPost(SDL_sem *sem)
#endif /* SDL_THREAD_VITA */
-/* vim: ts=4 sw=4
- */
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/vita/SDL_systhread.c b/src/thread/vita/SDL_systhread.c
index da8588c08..1664fbc6e 100644
--- a/src/thread/vita/SDL_systhread.c
+++ b/src/thread/vita/SDL_systhread.c
@@ -108,5 +108,4 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
#endif /* SDL_THREAD_VITA */
-/* vim: ts=4 sw=4
- */
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/vita/SDL_systhread_c.h b/src/thread/vita/SDL_systhread_c.h
index 80bf49d17..7084615f8 100644
--- a/src/thread/vita/SDL_systhread_c.h
+++ b/src/thread/vita/SDL_systhread_c.h
@@ -22,3 +22,5 @@
#include <psp2/types.h>
typedef SceUID SYS_ThreadHandle;
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/timer/vita/SDL_systimer.c b/src/timer/vita/SDL_systimer.c
index a9009f744..b7cbb2287 100644
--- a/src/timer/vita/SDL_systimer.c
+++ b/src/timer/vita/SDL_systimer.c
@@ -87,5 +87,4 @@ void SDL_Delay(Uint32 ms)
#endif /* SDL_TIMER_VITA */
-/* vim: ts=4 sw=4
- */
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c
index f196e3340..ed8d76987 100644
--- a/src/video/vita/SDL_vitakeyboard.c
+++ b/src/video/vita/SDL_vitakeyboard.c
@@ -42,157 +42,157 @@ Uint8 lock_key_down = 0;
void
VITA_InitKeyboard(void)
{
- sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
+ sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
}
void
VITA_PollKeyboard(void)
{
- // We skip polling keyboard if no window is created
- if (Vita_Window == NULL)
- return;
-
- if (keyboard_hid_handle > 0)
- {
- int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
-
- if (numReports < 0) {
- keyboard_hid_handle = 0;
- }
- else if (numReports) {
- // Numlock and Capslock state changes only on a SDL_PRESSED event
- // The k_report only reports the state of the LED
- if (k_reports[numReports - 1].modifiers[1] & 0x1) {
- if (!(locks & 0x1)) {
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
- locks |= 0x1;
- }
- }
- else {
- if (locks & 0x1) {
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
- locks &= ~0x1;
- }
- }
-
- if (k_reports[numReports - 1].modifiers[1] & 0x2) {
- if (!(locks & 0x2)) {
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
- locks |= 0x2;
- }
- }
- else {
- if (locks & 0x2) {
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
- locks &= ~0x2;
- }
- }
-
- if (k_reports[numReports - 1].modifiers[1] & 0x4) {
- if (!(locks & 0x4)) {
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK);
- locks |= 0x4;
- }
- }
- else {
- if (locks & 0x4) {
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK);
- locks &= ~0x4;
- }
- }
-
- {
- Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers;
-
- if (changed_modifiers & 0x01) {
- if (prev_modifiers & 0x01) {
- 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 {
- 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 & 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);
- }
- }
- }
-
- prev_modifiers = k_reports[numReports - 1].modifiers[0];
-
- for (int i = 0; i < 6; i++) {
-
- int keyCode = k_reports[numReports - 1].keycodes[i];
-
- if (keyCode != prev_keys[i]) {
-
- if (prev_keys[i]) {
- SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]);
- }
- if (keyCode) {
- SDL_SendKeyboardKey(SDL_PRESSED, keyCode);
- }
- prev_keys[i] = keyCode;
- }
- }
- }
- }
+ // We skip polling keyboard if no window is created
+ if (Vita_Window == NULL)
+ return;
+
+ if (keyboard_hid_handle > 0)
+ {
+ int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
+
+ if (numReports < 0) {
+ keyboard_hid_handle = 0;
+ }
+ else if (numReports) {
+ // Numlock and Capslock state changes only on a SDL_PRESSED event
+ // The k_report only reports the state of the LED
+ if (k_reports[numReports - 1].modifiers[1] & 0x1) {
+ if (!(locks & 0x1)) {
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
+ locks |= 0x1;
+ }
+ }
+ else {
+ if (locks & 0x1) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
+ locks &= ~0x1;
+ }
+ }
+
+ if (k_reports[numReports - 1].modifiers[1] & 0x2) {
+ if (!(locks & 0x2)) {
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
+ locks |= 0x2;
+ }
+ }
+ else {
+ if (locks & 0x2) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
+ locks &= ~0x2;
+ }
+ }
+
+ if (k_reports[numReports - 1].modifiers[1] & 0x4) {
+ if (!(locks & 0x4)) {
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK);
+ locks |= 0x4;
+ }
+ }
+ else {
+ if (locks & 0x4) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK);
+ locks &= ~0x4;
+ }
+ }
+
+ {
+ Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers;
+
+ if (changed_modifiers & 0x01) {
+ if (prev_modifiers & 0x01) {
+ 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 {
+ 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 & 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);
+ }
+ }
+ }
+
+ prev_modifiers = k_reports[numReports - 1].modifiers[0];
+
+ for (int i = 0; i < 6; i++) {
+
+ int keyCode = k_reports[numReports - 1].keycodes[i];
+
+ if (keyCode != prev_keys[i]) {
+
+ if (prev_keys[i]) {
+ SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]);
+ }
+ if (keyCode) {
+ SDL_SendKeyboardKey(SDL_PRESSED, keyCode);
+ }
+ prev_keys[i] = keyCode;
+ }
+ }
+ }
+ }
}
#endif /* SDL_VIDEO_DRIVER_VITA */
diff --git a/src/video/vita/SDL_vitamessagebox.c b/src/video/vita/SDL_vitamessagebox.c
index 76d0e9444..a1807a572 100644
--- a/src/video/vita/SDL_vitamessagebox.c
+++ b/src/video/vita/SDL_vitamessagebox.c
@@ -38,7 +38,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
SceMsgDialogUserMessageParam msgParam;
SceMsgDialogButtonsParam buttonParam;
SceDisplayFrameBuf dispparam;
-
+
SceMsgDialogResult dialog_result;
SceCommonDialogErrorCode init_result;
SDL_bool setup_minimal_gxm = SDL_FALSE;
@@ -76,7 +76,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
dispparam.size = sizeof(dispparam);
init_result = sceMsgDialogInit(¶m);
-
+
// Setup display if it hasn't been initialized before
if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED)
{
diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c
index d5af6bf23..702524d9d 100644
--- a/src/video/vita/SDL_vitamouse.c
+++ b/src/video/vita/SDL_vitamouse.c
@@ -40,53 +40,53 @@ Uint8 prev_buttons = 0;
void
VITA_InitMouse(void)
{
- sceHidMouseEnumerate(&mouse_hid_handle, 1);
+ sceHidMouseEnumerate(&mouse_hid_handle, 1);
}
void
VITA_PollMouse(void)
{
- // We skip polling mouse if no window is created
- if (Vita_Window == NULL)
- return;
+ // We skip polling mouse if no window is created
+ if (Vita_Window == NULL)
+ return;
- if (mouse_hid_handle > 0)
- {
- int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
- if (numReports > 0)
- {
- for (int i = 0; i <= numReports - 1; i++)
- {
- Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons;
+ if (mouse_hid_handle > 0)
+ {
+ int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
+ if (numReports > 0)
+ {
+ for (int i = 0; i <= numReports - 1; i++)
+ {
+ Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons;
- if (changed_buttons & 0x1) {
- if (prev_buttons & 0x1)
- SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
- else
- SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
- }
- if (changed_buttons & 0x2) {
- if (prev_buttons & 0x2)
- SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
- else
- SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
- }
- if (changed_buttons & 0x4) {
- if (prev_buttons & 0x4)
- SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
- else
- SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE);
- }
+ if (changed_buttons & 0x1) {
+ if (prev_buttons & 0x1)
+ SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
+ else
+ SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
+ }
+ if (changed_buttons & 0x2) {
+ if (prev_buttons & 0x2)
+ SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
+ else
+ SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
+ }
+ if (changed_buttons & 0x4) {
+ if (prev_buttons & 0x4)
+ SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
+ else
+ SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE);
+ }
- prev_buttons = m_reports[i].buttons;
+ prev_buttons = m_reports[i].buttons;
- if (m_reports[i].rel_x || m_reports[i].rel_y)
- {
- SDL_SendMouseMotion(Vita_Window, 0, 1, m_reports[i].rel_x, m_reports[i].rel_y);
- }
- }
- }
- }
+ if (m_reports[i].rel_x || m_reports[i].rel_y)
+ {
+ SDL_SendMouseMotion(Vita_Window, 0, 1, m_reports[i].rel_x, m_reports[i].rel_y);
+ }
+ }
+ }
+ }
}
#endif /* SDL_VIDEO_DRIVER_VITA */
diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c
index 7399618ce..ec250a31c 100644
--- a/src/video/vita/SDL_vitatouch.c
+++ b/src/video/vita/SDL_vitatouch.c
@@ -45,124 +45,124 @@ struct{
void
VITA_InitTouch(void)
{
- sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
- sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
- sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
- sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
-
- for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
- SceTouchPanelInfo panelinfo;
- sceTouchGetPanelInfo(port, &panelinfo);
-
- area_info[port].x = (float)panelinfo.minAaX;
- area_info[port].y = (float)panelinfo.minAaY;
- area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX);
- area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY);
-
- force_info[port].min = (float)panelinfo.minForce;
- force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce);
- }
-
- // Support passing both front and back touch devices in events
- SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
- SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back");
+ sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
+ sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
+ sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
+ sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
+
+ for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
+ SceTouchPanelInfo panelinfo;
+ sceTouchGetPanelInfo(port, &panelinfo);
+
+ area_info[port].x = (float)panelinfo.minAaX;
+ area_info[port].y = (float)panelinfo.minAaY;
+ area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX);
+ area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY);
+
+ force_info[port].min = (float)panelinfo.minForce;
+ force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce);
+ }
+
+ // Support passing both front and back touch devices in events
+ SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
+ SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back");
}
void
VITA_QuitTouch(void){
- sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
- sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
+ sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
+ sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
}
void
VITA_PollTouch(void)
{
- SDL_FingerID finger_id = 0;
- int port;
-
- // We skip polling touch if no window is created
- if (Vita_Window == NULL)
- return;
-
- memcpy(touch_old, touch, sizeof(touch_old));
-
- for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
- sceTouchPeek(port, &touch[port], 1);
- if (touch[port].reportNum > 0) {
- for (int i = 0; i < touch[port].reportNum; i++)
- {
- // adjust coordinates and forces to return normalized values
- // for the front, screen area is used as a reference (for direct touch)
- // e.g. touch_x = 1.0 corresponds to screen_x = 960
- // for the back panel, the active touch area is used as reference
- float x = 0;
- float y = 0;
- 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;
-
- // Send an initial touch
- SDL_SendTouch((SDL_TouchID)port,
- finger_id,
- Vita_Window,
- SDL_TRUE,
- x,
- y,
- force);
-
- // Always send the motion
- SDL_SendTouchMotion((SDL_TouchID)port,
- finger_id,
- Vita_Window,
- x,
- y,
- force);
- }
- }
-
- // some fingers might have been let go
- if (touch_old[port].reportNum > 0) {
- for (int i = 0; i < touch_old[port].reportNum; i++) {
- int finger_up = 1;
- if (touch[port].reportNum > 0) {
- for (int j = 0; j < touch[port].reportNum; j++) {
- if (touch[port].report[j].id == touch_old[port].report[i].id ) {
- finger_up = 0;
- }
- }
- }
- if (finger_up == 1) {
- float x = 0;
- float y = 0;
- 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 released from screen
- SDL_SendTouch((SDL_TouchID)port,
- finger_id,
- Vita_Window,
- SDL_FALSE,
- x,
- y,
- force);
- }
- }
- }
- }
+ SDL_FingerID finger_id = 0;
+ int port;
+
+ // We skip polling touch if no window is created
+ if (Vita_Window == NULL)
+ return;
+
+ memcpy(touch_old, touch, sizeof(touch_old));
+
+ for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
+ sceTouchPeek(port, &touch[port], 1);
+ if (touch[port].reportNum > 0) {
+ for (int i = 0; i < touch[port].reportNum; i++)
+ {
+ // adjust coordinates and forces to return normalized values
+ // for the front, screen area is used as a reference (for direct touch)
+ // e.g. touch_x = 1.0 corresponds to screen_x = 960
+ // for the back panel, the active touch area is used as reference
+ float x = 0;
+ float y = 0;
+ 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;
+
+ // Send an initial touch
+ SDL_SendTouch((SDL_TouchID)port,
+ finger_id,
+ Vita_Window,
+ SDL_TRUE,
+ x,
+ y,
+ force);
+
+ // Always send the motion
+ SDL_SendTouchMotion((SDL_TouchID)port,
+ finger_id,
+ Vita_Window,
+ x,
+ y,
+ force);
+ }
+ }
+
+ // some fingers might have been let go
+ if (touch_old[port].reportNum > 0) {
+ for (int i = 0; i < touch_old[port].reportNum; i++) {
+ int finger_up = 1;
+ if (touch[port].reportNum > 0) {
+ for (int j = 0; j < touch[port].reportNum; j++) {
+ if (touch[port].report[j].id == touch_old[port].report[i].id ) {
+ finger_up = 0;
+ }
+ }
+ }
+ if (finger_up == 1) {
+ float x = 0;
+ float y = 0;
+ 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 released from screen
+ SDL_SendTouch((SDL_TouchID)port,
+ finger_id,
+ Vita_Window,
+ SDL_FALSE,
+ x,
+ y,
+ force);
+ }
+ }
+ }
+ }
}
void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) {
- float x = (vita_x - area_info[port].x) / area_info[port].w;
- float y = (vita_y - area_info[port].y) / area_info[port].h;
+ float x = (vita_x - area_info[port].x) / area_info[port].w;
+ float y = (vita_y - area_info[port].y) / area_info[port].h;
- x = SDL_max(x, 0.0);
- x = SDL_min(x, 1.0);
+ x = SDL_max(x, 0.0);
+ x = SDL_min(x, 1.0);
- y = SDL_max(y, 0.0);
- y = SDL_min(y, 1.0);
+ y = SDL_max(y, 0.0);
+ y = SDL_min(y, 1.0);
- *sdl_x = x;
- *sdl_y = y;
+ *sdl_x = x;
+ *sdl_y = y;
}
diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h
index 63944a320..13ea895db 100644
--- a/src/video/vita/SDL_vitavideo.h
+++ b/src/video/vita/SDL_vitavideo.h
@@ -31,11 +31,11 @@
typedef struct SDL_VideoData
{
- SDL_bool egl_initialized; /* OpenGL device initialization status */
- uint32_t egl_refcount; /* OpenGL reference count */
+ SDL_bool egl_initialized; /* OpenGL device initialization status */
+ uint32_t egl_refcount; /* OpenGL reference count */
- SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
- SDL_bool ime_active;
+ SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
+ SDL_bool ime_active;
} SDL_VideoData;