mirror of https://github.com/encounter/SDL.git
Formatting
This commit is contained in:
parent
4f9fde8766
commit
a4ddb175f1
|
@ -172,10 +172,6 @@ VITAAUD_Init(SDL_AudioDriverImpl * impl)
|
||||||
|
|
||||||
impl->OnlyHasDefaultInputDevice = 1;
|
impl->OnlyHasDefaultInputDevice = 1;
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
impl->DetectDevices = DSOUND_DetectDevices;
|
|
||||||
impl->Deinitialize = DSOUND_Deinitialize;
|
|
||||||
*/
|
|
||||||
return 1; /* this audio target is available. */
|
return 1; /* this audio target is available. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,5 @@ struct SDL_PrivateAudioData {
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SDL_vitaaudio_h */
|
#endif /* _SDL_vitaaudio_h */
|
||||||
/* vim: ts=4 sw=4
|
|
||||||
*/
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -208,7 +208,6 @@ VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function to open a joystick for use.
|
/* Function to open a joystick for use.
|
||||||
The joystick to open is specified by the device index.
|
The joystick to open is specified by the device index.
|
||||||
This should fill the nbuttons and naxes fields of the joystick structure.
|
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();
|
return SDL_Unsupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_JoystickDriver SDL_VITA_JoystickDriver =
|
SDL_JoystickDriver SDL_VITA_JoystickDriver =
|
||||||
{
|
{
|
||||||
VITA_JoystickInit,
|
VITA_JoystickInit,
|
||||||
|
@ -414,8 +412,6 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver =
|
||||||
VITA_JoystickQuit,
|
VITA_JoystickQuit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_VITA */
|
#endif /* SDL_JOYSTICK_VITA */
|
||||||
|
|
||||||
/* vim: ts=4 sw=4
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
*/
|
|
||||||
|
|
|
@ -19,4 +19,5 @@
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "../../SDL_internal.h"
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -159,5 +159,4 @@ int SDL_SemPost(SDL_sem *sem)
|
||||||
|
|
||||||
#endif /* SDL_THREAD_VITA */
|
#endif /* SDL_THREAD_VITA */
|
||||||
|
|
||||||
/* vim: ts=4 sw=4
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
*/
|
|
||||||
|
|
|
@ -108,5 +108,4 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||||
|
|
||||||
#endif /* SDL_THREAD_VITA */
|
#endif /* SDL_THREAD_VITA */
|
||||||
|
|
||||||
/* vim: ts=4 sw=4
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
*/
|
|
||||||
|
|
|
@ -22,3 +22,5 @@
|
||||||
#include <psp2/types.h>
|
#include <psp2/types.h>
|
||||||
|
|
||||||
typedef SceUID SYS_ThreadHandle;
|
typedef SceUID SYS_ThreadHandle;
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -87,5 +87,4 @@ void SDL_Delay(Uint32 ms)
|
||||||
|
|
||||||
#endif /* SDL_TIMER_VITA */
|
#endif /* SDL_TIMER_VITA */
|
||||||
|
|
||||||
/* vim: ts=4 sw=4
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
*/
|
|
||||||
|
|
|
@ -42,157 +42,157 @@ Uint8 lock_key_down = 0;
|
||||||
void
|
void
|
||||||
VITA_InitKeyboard(void)
|
VITA_InitKeyboard(void)
|
||||||
{
|
{
|
||||||
sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
|
sceHidKeyboardEnumerate(&keyboard_hid_handle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VITA_PollKeyboard(void)
|
VITA_PollKeyboard(void)
|
||||||
{
|
{
|
||||||
// We skip polling keyboard if no window is created
|
// We skip polling keyboard if no window is created
|
||||||
if (Vita_Window == NULL)
|
if (Vita_Window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (keyboard_hid_handle > 0)
|
if (keyboard_hid_handle > 0)
|
||||||
{
|
{
|
||||||
int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
|
int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);
|
||||||
|
|
||||||
if (numReports < 0) {
|
if (numReports < 0) {
|
||||||
keyboard_hid_handle = 0;
|
keyboard_hid_handle = 0;
|
||||||
}
|
}
|
||||||
else if (numReports) {
|
else if (numReports) {
|
||||||
// Numlock and Capslock state changes only on a SDL_PRESSED event
|
// Numlock and Capslock state changes only on a SDL_PRESSED event
|
||||||
// The k_report only reports the state of the LED
|
// The k_report only reports the state of the LED
|
||||||
if (k_reports[numReports - 1].modifiers[1] & 0x1) {
|
if (k_reports[numReports - 1].modifiers[1] & 0x1) {
|
||||||
if (!(locks & 0x1)) {
|
if (!(locks & 0x1)) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||||
locks |= 0x1;
|
locks |= 0x1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (locks & 0x1) {
|
if (locks & 0x1) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||||
locks &= ~0x1;
|
locks &= ~0x1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k_reports[numReports - 1].modifiers[1] & 0x2) {
|
if (k_reports[numReports - 1].modifiers[1] & 0x2) {
|
||||||
if (!(locks & 0x2)) {
|
if (!(locks & 0x2)) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||||
locks |= 0x2;
|
locks |= 0x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (locks & 0x2) {
|
if (locks & 0x2) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||||
locks &= ~0x2;
|
locks &= ~0x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k_reports[numReports - 1].modifiers[1] & 0x4) {
|
if (k_reports[numReports - 1].modifiers[1] & 0x4) {
|
||||||
if (!(locks & 0x4)) {
|
if (!(locks & 0x4)) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK);
|
||||||
locks |= 0x4;
|
locks |= 0x4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (locks & 0x4) {
|
if (locks & 0x4) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK);
|
||||||
locks &= ~0x4;
|
locks &= ~0x4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
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 {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x02) {
|
if (changed_modifiers & 0x02) {
|
||||||
if (prev_modifiers & 0x02) {
|
if (prev_modifiers & 0x02) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x04) {
|
if (changed_modifiers & 0x04) {
|
||||||
if (prev_modifiers & 0x04) {
|
if (prev_modifiers & 0x04) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x08) {
|
if (changed_modifiers & 0x08) {
|
||||||
if (prev_modifiers & 0x08) {
|
if (prev_modifiers & 0x08) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x10) {
|
if (changed_modifiers & 0x10) {
|
||||||
if (prev_modifiers & 0x10) {
|
if (prev_modifiers & 0x10) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x20) {
|
if (changed_modifiers & 0x20) {
|
||||||
if (prev_modifiers & 0x20) {
|
if (prev_modifiers & 0x20) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x40) {
|
if (changed_modifiers & 0x40) {
|
||||||
if (prev_modifiers & 0x40) {
|
if (prev_modifiers & 0x40) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed_modifiers & 0x80) {
|
if (changed_modifiers & 0x80) {
|
||||||
if (prev_modifiers & 0x80) {
|
if (prev_modifiers & 0x80) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
|
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI);
|
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_modifiers = k_reports[numReports - 1].modifiers[0];
|
prev_modifiers = k_reports[numReports - 1].modifiers[0];
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
|
|
||||||
int keyCode = k_reports[numReports - 1].keycodes[i];
|
int keyCode = k_reports[numReports - 1].keycodes[i];
|
||||||
|
|
||||||
if (keyCode != prev_keys[i]) {
|
if (keyCode != prev_keys[i]) {
|
||||||
|
|
||||||
if (prev_keys[i]) {
|
if (prev_keys[i]) {
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]);
|
SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]);
|
||||||
}
|
}
|
||||||
if (keyCode) {
|
if (keyCode) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, keyCode);
|
SDL_SendKeyboardKey(SDL_PRESSED, keyCode);
|
||||||
}
|
}
|
||||||
prev_keys[i] = keyCode;
|
prev_keys[i] = keyCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||||
|
|
|
@ -38,7 +38,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
SceMsgDialogUserMessageParam msgParam;
|
SceMsgDialogUserMessageParam msgParam;
|
||||||
SceMsgDialogButtonsParam buttonParam;
|
SceMsgDialogButtonsParam buttonParam;
|
||||||
SceDisplayFrameBuf dispparam;
|
SceDisplayFrameBuf dispparam;
|
||||||
|
|
||||||
SceMsgDialogResult dialog_result;
|
SceMsgDialogResult dialog_result;
|
||||||
SceCommonDialogErrorCode init_result;
|
SceCommonDialogErrorCode init_result;
|
||||||
SDL_bool setup_minimal_gxm = SDL_FALSE;
|
SDL_bool setup_minimal_gxm = SDL_FALSE;
|
||||||
|
@ -76,7 +76,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
dispparam.size = sizeof(dispparam);
|
dispparam.size = sizeof(dispparam);
|
||||||
|
|
||||||
init_result = sceMsgDialogInit(¶m);
|
init_result = sceMsgDialogInit(¶m);
|
||||||
|
|
||||||
// Setup display if it hasn't been initialized before
|
// Setup display if it hasn't been initialized before
|
||||||
if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED)
|
if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,53 +40,53 @@ Uint8 prev_buttons = 0;
|
||||||
void
|
void
|
||||||
VITA_InitMouse(void)
|
VITA_InitMouse(void)
|
||||||
{
|
{
|
||||||
sceHidMouseEnumerate(&mouse_hid_handle, 1);
|
sceHidMouseEnumerate(&mouse_hid_handle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VITA_PollMouse(void)
|
VITA_PollMouse(void)
|
||||||
{
|
{
|
||||||
// We skip polling mouse if no window is created
|
// We skip polling mouse if no window is created
|
||||||
if (Vita_Window == NULL)
|
if (Vita_Window == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mouse_hid_handle > 0)
|
if (mouse_hid_handle > 0)
|
||||||
{
|
{
|
||||||
int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
|
int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT);
|
||||||
if (numReports > 0)
|
if (numReports > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= numReports - 1; i++)
|
for (int i = 0; i <= numReports - 1; i++)
|
||||||
{
|
{
|
||||||
Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons;
|
Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons;
|
||||||
|
|
||||||
if (changed_buttons & 0x1) {
|
if (changed_buttons & 0x1) {
|
||||||
if (prev_buttons & 0x1)
|
if (prev_buttons & 0x1)
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||||
else
|
else
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||||
}
|
}
|
||||||
if (changed_buttons & 0x2) {
|
if (changed_buttons & 0x2) {
|
||||||
if (prev_buttons & 0x2)
|
if (prev_buttons & 0x2)
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
|
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
|
||||||
else
|
else
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
|
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
|
||||||
}
|
}
|
||||||
if (changed_buttons & 0x4) {
|
if (changed_buttons & 0x4) {
|
||||||
if (prev_buttons & 0x4)
|
if (prev_buttons & 0x4)
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||||
else
|
else
|
||||||
SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE);
|
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)
|
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);
|
SDL_SendMouseMotion(Vita_Window, 0, 1, m_reports[i].rel_x, m_reports[i].rel_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_VITA */
|
#endif /* SDL_VIDEO_DRIVER_VITA */
|
||||||
|
|
|
@ -45,124 +45,124 @@ struct{
|
||||||
void
|
void
|
||||||
VITA_InitTouch(void)
|
VITA_InitTouch(void)
|
||||||
{
|
{
|
||||||
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
|
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
|
||||||
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
|
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
|
||||||
sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
|
sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
|
||||||
sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
|
sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
|
||||||
|
|
||||||
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
|
||||||
SceTouchPanelInfo panelinfo;
|
SceTouchPanelInfo panelinfo;
|
||||||
sceTouchGetPanelInfo(port, &panelinfo);
|
sceTouchGetPanelInfo(port, &panelinfo);
|
||||||
|
|
||||||
area_info[port].x = (float)panelinfo.minAaX;
|
area_info[port].x = (float)panelinfo.minAaX;
|
||||||
area_info[port].y = (float)panelinfo.minAaY;
|
area_info[port].y = (float)panelinfo.minAaY;
|
||||||
area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX);
|
area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX);
|
||||||
area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY);
|
area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY);
|
||||||
|
|
||||||
force_info[port].min = (float)panelinfo.minForce;
|
force_info[port].min = (float)panelinfo.minForce;
|
||||||
force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce);
|
force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support passing both front and back touch devices in events
|
// Support passing both front and back touch devices in events
|
||||||
SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
|
SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
|
||||||
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back");
|
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VITA_QuitTouch(void){
|
VITA_QuitTouch(void){
|
||||||
sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
|
sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
|
||||||
sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
|
sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VITA_PollTouch(void)
|
VITA_PollTouch(void)
|
||||||
{
|
{
|
||||||
SDL_FingerID finger_id = 0;
|
SDL_FingerID finger_id = 0;
|
||||||
int port;
|
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;
|
||||||
|
|
||||||
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++) {
|
||||||
sceTouchPeek(port, &touch[port], 1);
|
sceTouchPeek(port, &touch[port], 1);
|
||||||
if (touch[port].reportNum > 0) {
|
if (touch[port].reportNum > 0) {
|
||||||
for (int i = 0; i < touch[port].reportNum; i++)
|
for (int i = 0; i < touch[port].reportNum; i++)
|
||||||
{
|
{
|
||||||
// adjust coordinates and forces to return normalized values
|
// adjust coordinates and forces to return normalized values
|
||||||
// for the front, screen area is used as a reference (for direct touch)
|
// for the front, screen area is used as a reference (for direct touch)
|
||||||
// e.g. touch_x = 1.0 corresponds to screen_x = 960
|
// e.g. touch_x = 1.0 corresponds to screen_x = 960
|
||||||
// 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;
|
||||||
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);
|
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
|
||||||
SDL_SendTouch((SDL_TouchID)port,
|
SDL_SendTouch((SDL_TouchID)port,
|
||||||
finger_id,
|
finger_id,
|
||||||
Vita_Window,
|
Vita_Window,
|
||||||
SDL_TRUE,
|
SDL_TRUE,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
force);
|
force);
|
||||||
|
|
||||||
// Always send the motion
|
// Always send the motion
|
||||||
SDL_SendTouchMotion((SDL_TouchID)port,
|
SDL_SendTouchMotion((SDL_TouchID)port,
|
||||||
finger_id,
|
finger_id,
|
||||||
Vita_Window,
|
Vita_Window,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
force);
|
force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// some fingers might have been let go
|
// some fingers might have been let go
|
||||||
if (touch_old[port].reportNum > 0) {
|
if (touch_old[port].reportNum > 0) {
|
||||||
for (int i = 0; i < touch_old[port].reportNum; i++) {
|
for (int i = 0; i < touch_old[port].reportNum; i++) {
|
||||||
int finger_up = 1;
|
int finger_up = 1;
|
||||||
if (touch[port].reportNum > 0) {
|
if (touch[port].reportNum > 0) {
|
||||||
for (int j = 0; j < touch[port].reportNum; j++) {
|
for (int j = 0; j < touch[port].reportNum; j++) {
|
||||||
if (touch[port].report[j].id == touch_old[port].report[i].id ) {
|
if (touch[port].report[j].id == touch_old[port].report[i].id ) {
|
||||||
finger_up = 0;
|
finger_up = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (finger_up == 1) {
|
if (finger_up == 1) {
|
||||||
float x = 0;
|
float x = 0;
|
||||||
float y = 0;
|
float y = 0;
|
||||||
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);
|
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,
|
||||||
finger_id,
|
finger_id,
|
||||||
Vita_Window,
|
Vita_Window,
|
||||||
SDL_FALSE,
|
SDL_FALSE,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
force);
|
force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) {
|
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 x = (vita_x - area_info[port].x) / area_info[port].w;
|
||||||
float y = (vita_y - area_info[port].y) / area_info[port].h;
|
float y = (vita_y - area_info[port].y) / area_info[port].h;
|
||||||
|
|
||||||
x = SDL_max(x, 0.0);
|
x = SDL_max(x, 0.0);
|
||||||
x = SDL_min(x, 1.0);
|
x = SDL_min(x, 1.0);
|
||||||
|
|
||||||
y = SDL_max(y, 0.0);
|
y = SDL_max(y, 0.0);
|
||||||
y = SDL_min(y, 1.0);
|
y = SDL_min(y, 1.0);
|
||||||
|
|
||||||
*sdl_x = x;
|
*sdl_x = x;
|
||||||
*sdl_y = y;
|
*sdl_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
typedef struct SDL_VideoData
|
typedef struct SDL_VideoData
|
||||||
{
|
{
|
||||||
SDL_bool egl_initialized; /* OpenGL device initialization status */
|
SDL_bool egl_initialized; /* OpenGL device initialization status */
|
||||||
uint32_t egl_refcount; /* OpenGL reference count */
|
uint32_t egl_refcount; /* OpenGL reference count */
|
||||||
|
|
||||||
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
||||||
SDL_bool ime_active;
|
SDL_bool ime_active;
|
||||||
|
|
||||||
} SDL_VideoData;
|
} SDL_VideoData;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue