2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2013-01-01 00:37:37 +00:00
|
|
|
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2013 - Daniel De Matteis
|
2011-11-30 16:24:18 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-11-30 16:24:18 +00:00
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-11-30 16:24:18 +00:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-11-30 16:24:18 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-03-05 15:57:43 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
2012-03-19 01:55:13 +00:00
|
|
|
|
2012-07-01 18:45:13 +00:00
|
|
|
#ifndef __PSL1GHT__
|
|
|
|
#include <sdk_version.h>
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 22:36:40 +00:00
|
|
|
#include <sys/memory.h>
|
2012-07-01 12:10:13 +00:00
|
|
|
|
2012-07-01 14:13:25 +00:00
|
|
|
#include "sdk_defines.h"
|
|
|
|
|
2012-01-11 21:27:07 +00:00
|
|
|
#include "ps3_input.h"
|
2012-03-05 15:57:43 +00:00
|
|
|
#include "../driver.h"
|
2012-04-09 22:22:02 +00:00
|
|
|
#include "../libretro.h"
|
2012-01-20 23:30:01 +00:00
|
|
|
#include "../general.h"
|
2011-11-30 16:24:18 +00:00
|
|
|
|
2012-06-19 03:10:42 +00:00
|
|
|
/*============================================================
|
2012-11-02 23:30:41 +00:00
|
|
|
PS3 MOUSE
|
|
|
|
============================================================ */
|
2012-06-19 03:10:42 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MOUSE
|
|
|
|
|
2012-07-01 14:32:15 +00:00
|
|
|
#ifndef __PSL1GHT__
|
2012-06-19 03:10:42 +00:00
|
|
|
#define MAX_MICE 7
|
2012-07-01 14:32:15 +00:00
|
|
|
#endif
|
2012-06-19 03:10:42 +00:00
|
|
|
|
|
|
|
static void ps3_mouse_input_deinit(void)
|
|
|
|
{
|
2012-07-16 19:49:51 +00:00
|
|
|
cellMouseEnd();
|
2012-06-19 03:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t ps3_mouse_input_mice_connected(void)
|
|
|
|
{
|
2012-07-16 19:49:51 +00:00
|
|
|
CellMouseInfo mouse_info;
|
|
|
|
cellMouseGetInfo(&mouse_info);
|
2012-06-19 03:10:42 +00:00
|
|
|
return mouse_info.now_connect;
|
|
|
|
}
|
|
|
|
|
2012-07-16 19:49:51 +00:00
|
|
|
CellMouseData ps3_mouse_input_poll_device(uint32_t id)
|
2012-06-19 03:10:42 +00:00
|
|
|
{
|
2012-07-16 19:49:51 +00:00
|
|
|
CellMouseData mouse_data;
|
2012-06-19 03:10:42 +00:00
|
|
|
|
|
|
|
// Get new pad data
|
2012-07-16 19:49:51 +00:00
|
|
|
cellMouseGetData(id, &mouse_data);
|
2012-06-19 03:10:42 +00:00
|
|
|
|
|
|
|
return mouse_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 22:36:40 +00:00
|
|
|
/*============================================================
|
2012-11-02 23:30:41 +00:00
|
|
|
PS3 PAD
|
|
|
|
============================================================ */
|
2012-03-19 01:55:13 +00:00
|
|
|
|
2012-07-25 17:35:21 +00:00
|
|
|
const struct platform_bind platform_keys[] = {
|
2012-12-14 16:42:01 +00:00
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_B), "Cross button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_Y), "Square button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT), "Select button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_START), "Start button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_UP), "D-Pad Up" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN), "D-Pad Down" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT), "D-Pad Left" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT), "D-Pad Right" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_A), "Circle button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_X), "Triangle button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_L), "L1 button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_R), "R1 button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_L2), "L2 button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_R2), "R2 button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_L3), "L3 button" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_R3), "R3 button" },
|
|
|
|
{ (1ULL << RARCH_TURBO_ENABLE), "Turbo button (Unmapped)" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_LEFT_X_PLUS), "LStick Left" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_LEFT_X_MINUS), "LStick Right" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_LEFT_Y_PLUS), "LStick Up" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_LEFT_Y_MINUS), "LStick Down" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_RIGHT_X_PLUS), "RStick Left" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_RIGHT_X_MINUS), "RStick Right" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_RIGHT_Y_PLUS), "RStick Up" },
|
|
|
|
{ (1ULL << RARCH_ANALOG_RIGHT_Y_MINUS), "RStick Down" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) | (1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT), "LStick D-Pad Left" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | (1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT), "LStick D-Pad Right" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) | (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP), "LStick D-Pad Up" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) | (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN), "LStick D-Pad Down" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) | (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT), "RStick D-Pad Left" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT), "RStick D-Pad Right" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) | (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP), "RStick D-Pad Up" },
|
|
|
|
{ (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) | (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN), "RStick D-Pad Down" },
|
2012-07-25 17:35:21 +00:00
|
|
|
};
|
|
|
|
|
2012-09-11 10:33:46 +00:00
|
|
|
const unsigned platform_keys_size = sizeof(platform_keys);
|
2012-07-25 17:35:21 +00:00
|
|
|
|
2012-03-25 22:36:40 +00:00
|
|
|
static uint64_t state[MAX_PADS];
|
2012-04-10 16:07:21 +00:00
|
|
|
static unsigned pads_connected;
|
2012-07-01 13:18:26 +00:00
|
|
|
#ifdef HAVE_MOUSE
|
2012-06-19 03:10:42 +00:00
|
|
|
static unsigned mice_connected;
|
2012-07-01 13:18:26 +00:00
|
|
|
#endif
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2011-11-30 16:24:18 +00:00
|
|
|
static void ps3_input_poll(void *data)
|
|
|
|
{
|
2012-07-16 19:49:51 +00:00
|
|
|
CellPadInfo2 pad_info;
|
2011-11-30 16:24:18 +00:00
|
|
|
(void)data;
|
2012-07-01 20:14:09 +00:00
|
|
|
|
2012-03-05 06:35:50 +00:00
|
|
|
for (unsigned i = 0; i < MAX_PADS; i++)
|
2012-07-31 22:00:44 +00:00
|
|
|
{
|
|
|
|
static CellPadData state_tmp;
|
|
|
|
cellPadGetData(i, &state_tmp);
|
|
|
|
|
|
|
|
if (state_tmp.len != 0)
|
|
|
|
{
|
2013-01-05 20:56:19 +00:00
|
|
|
uint64_t *state_cur = &state[i];
|
2013-03-12 22:44:46 +00:00
|
|
|
bool dpad_emulation = (g_settings.input.dpad_emulation[i] != DPAD_EMULATION_NONE);
|
2013-01-05 20:56:19 +00:00
|
|
|
*state_cur = 0;
|
2012-08-09 05:29:56 +00:00
|
|
|
#ifdef __PSL1GHT__
|
2013-01-05 20:56:19 +00:00
|
|
|
*state_cur |= (state_tmp.BTN_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
|
|
|
*state_cur |= (state_tmp.BTN_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
2013-03-12 22:44:46 +00:00
|
|
|
|
|
|
|
if (dpad_emulation)
|
|
|
|
{
|
|
|
|
*state_cur |= (state_tmp.ANA_L_H <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_L_H >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_L_V <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_L_V >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_R_H <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_R_H >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_R_V <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.ANA_R_V >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN) : 0;
|
|
|
|
}
|
2012-08-09 05:29:56 +00:00
|
|
|
#else
|
2013-01-05 20:56:19 +00:00
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
2013-03-12 22:44:46 +00:00
|
|
|
if (dpad_emulation)
|
|
|
|
{
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP) : 0;
|
|
|
|
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN) : 0;
|
|
|
|
}
|
2012-08-09 05:29:56 +00:00
|
|
|
#endif
|
2012-07-31 22:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-10 16:07:21 +00:00
|
|
|
|
2013-01-06 23:31:38 +00:00
|
|
|
uint64_t *state_p1 = &state[0];
|
|
|
|
uint64_t *lifecycle_state = &g_extern.lifecycle_state;
|
2013-03-12 22:44:46 +00:00
|
|
|
bool dpad_emulation = (g_settings.input.dpad_emulation[0] != DPAD_EMULATION_NONE);
|
2013-01-06 23:31:38 +00:00
|
|
|
|
|
|
|
*lifecycle_state &= ~(
|
|
|
|
(1ULL << RARCH_FAST_FORWARD_HOLD_KEY) |
|
|
|
|
(1ULL << RARCH_LOAD_STATE_KEY) |
|
|
|
|
(1ULL << RARCH_SAVE_STATE_KEY) |
|
|
|
|
(1ULL << RARCH_STATE_SLOT_PLUS) |
|
|
|
|
(1ULL << RARCH_STATE_SLOT_MINUS) |
|
|
|
|
(1ULL << RARCH_REWIND) |
|
|
|
|
(1ULL << RARCH_QUIT_KEY) |
|
2013-03-09 15:14:26 +00:00
|
|
|
(1ULL << RARCH_MENU_TOGGLE) |
|
|
|
|
(1ULL << RARCH_MENU_QUICKMENU_TOGGLE));
|
2013-01-06 23:31:38 +00:00
|
|
|
|
2013-03-12 22:44:46 +00:00
|
|
|
if (dpad_emulation)
|
|
|
|
{
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_FAST_FORWARD_HOLD_KEY);
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_LOAD_STATE_KEY);
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_SAVE_STATE_KEY);
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_STATE_SLOT_PLUS);
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_STATE_SLOT_MINUS);
|
|
|
|
if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_REWIND);
|
|
|
|
}
|
2013-01-07 23:35:49 +00:00
|
|
|
|
2013-03-11 01:07:50 +00:00
|
|
|
if (!(g_extern.frame_count < g_extern.delay_timer[0]))
|
2012-12-15 00:14:21 +00:00
|
|
|
{
|
2013-03-11 01:07:50 +00:00
|
|
|
if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
|
|
|
if (!(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
|
|
|
|
{
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
|
|
|
*lifecycle_state |= (1ULL << RARCH_MENU_QUICKMENU_TOGGLE);
|
|
|
|
}
|
2012-12-15 00:14:21 +00:00
|
|
|
}
|
2012-12-14 17:37:18 +00:00
|
|
|
|
2012-07-16 19:49:51 +00:00
|
|
|
cellPadGetInfo2(&pad_info);
|
2012-07-01 20:14:09 +00:00
|
|
|
pads_connected = pad_info.now_connect;
|
2012-06-19 03:10:42 +00:00
|
|
|
#ifdef HAVE_MOUSE
|
|
|
|
mice_connected = ps3_mouse_input_mice_connected();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_MOUSE
|
|
|
|
|
|
|
|
static int16_t ps3_mouse_device_state(void *data, unsigned player, unsigned id)
|
|
|
|
{
|
2012-07-16 19:49:51 +00:00
|
|
|
CellMouseData mouse_state = ps3_mouse_input_poll_device(player);
|
2012-06-19 03:10:42 +00:00
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
|
|
|
return (!mice_connected ? 0 : mouse_state.buttons & CELL_MOUSE_BUTTON_1);
|
|
|
|
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
|
|
|
return (!mice_connected ? 0 : mouse_state.buttons & CELL_MOUSE_BUTTON_2);
|
|
|
|
case RETRO_DEVICE_ID_MOUSE_X:
|
|
|
|
return (!mice_connected ? 0 : mouse_state.x_axis);
|
|
|
|
case RETRO_DEVICE_ID_MOUSE_Y:
|
|
|
|
return (!mice_connected ? 0 : mouse_state.y_axis);
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-30 16:24:18 +00:00
|
|
|
}
|
|
|
|
|
2012-06-19 03:10:42 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-07 15:19:32 +00:00
|
|
|
static int16_t ps3_input_state(void *data, const struct retro_keybind **binds,
|
2012-04-09 23:00:25 +00:00
|
|
|
unsigned port, unsigned device,
|
2011-12-02 01:34:06 +00:00
|
|
|
unsigned index, unsigned id)
|
2011-11-30 16:24:18 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
|
2012-04-09 23:00:25 +00:00
|
|
|
unsigned player = port;
|
|
|
|
uint64_t button = binds[player][id].joykey;
|
2012-06-19 03:10:42 +00:00
|
|
|
int16_t retval = 0;
|
2012-04-10 16:07:21 +00:00
|
|
|
|
2013-01-17 13:03:55 +00:00
|
|
|
if (player < pads_connected)
|
2012-06-19 03:10:42 +00:00
|
|
|
{
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2012-07-31 22:00:44 +00:00
|
|
|
retval = (state[player] & button) ? 1 : 0;
|
2012-06-19 03:10:42 +00:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_MOUSE
|
|
|
|
case RETRO_DEVICE_MOUSE:
|
2012-11-02 23:30:41 +00:00
|
|
|
retval = ps3_mouse_device_state(data, player, id);
|
2012-06-19 03:10:42 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
2012-11-02 23:30:41 +00:00
|
|
|
}
|
2011-11-30 16:24:18 +00:00
|
|
|
|
2012-04-10 16:07:21 +00:00
|
|
|
return retval;
|
2011-11-30 16:24:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 22:36:40 +00:00
|
|
|
/*============================================================
|
2012-11-02 23:30:41 +00:00
|
|
|
ON-SCREEN KEYBOARD UTILITY
|
|
|
|
============================================================ */
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2012-06-19 03:10:42 +00:00
|
|
|
#ifdef HAVE_OSKUTIL
|
|
|
|
|
2012-04-10 19:23:42 +00:00
|
|
|
#define OSK_IN_USE 1
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2012-09-11 10:33:46 +00:00
|
|
|
void oskutil_init(oskutil_params *params, unsigned containersize)
|
2012-03-25 22:36:40 +00:00
|
|
|
{
|
|
|
|
params->flags = 0;
|
2013-01-17 13:03:55 +00:00
|
|
|
if (containersize)
|
2012-03-25 22:36:40 +00:00
|
|
|
params->osk_memorycontainer = containersize;
|
|
|
|
else
|
2013-01-17 09:40:35 +00:00
|
|
|
params->osk_memorycontainer = 1024*1024*2;
|
2012-03-25 22:36:40 +00:00
|
|
|
}
|
|
|
|
|
2012-04-10 01:14:21 +00:00
|
|
|
static bool oskutil_enable_key_layout (void)
|
2012-03-25 22:36:40 +00:00
|
|
|
{
|
2012-07-01 18:45:13 +00:00
|
|
|
int ret = pOskSetKeyLayoutOption(CELL_OSKDIALOG_10KEY_PANEL | \
|
2012-11-02 23:30:41 +00:00
|
|
|
CELL_OSKDIALOG_FULLKEY_PANEL);
|
2012-03-25 22:36:40 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return (false);
|
|
|
|
else
|
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void oskutil_create_activation_parameters(oskutil_params *params)
|
|
|
|
{
|
|
|
|
params->dialogParam.controlPoint.x = 0.0;
|
|
|
|
params->dialogParam.controlPoint.y = 0.0;
|
|
|
|
|
|
|
|
int32_t LayoutMode = CELL_OSKDIALOG_LAYOUTMODE_X_ALIGN_CENTER | CELL_OSKDIALOG_LAYOUTMODE_Y_ALIGN_TOP;
|
2012-07-01 18:45:13 +00:00
|
|
|
pOskSetLayoutMode(LayoutMode);
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2012-07-01 18:45:13 +00:00
|
|
|
params->dialogParam.osk_allowed_panels =
|
2012-11-02 23:30:41 +00:00
|
|
|
CELL_OSKDIALOG_PANELMODE_ALPHABET |
|
|
|
|
CELL_OSKDIALOG_PANELMODE_NUMERAL |
|
|
|
|
CELL_OSKDIALOG_PANELMODE_NUMERAL_FULL_WIDTH |
|
|
|
|
CELL_OSKDIALOG_PANELMODE_ENGLISH;
|
2012-03-25 22:36:40 +00:00
|
|
|
|
|
|
|
params->dialogParam.firstViewPanel = CELL_OSKDIALOG_PANELMODE_ENGLISH;
|
2012-07-01 18:45:13 +00:00
|
|
|
params->dialogParam.osk_prohibit_flags = 0;
|
2012-03-25 22:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void oskutil_write_message(oskutil_params *params, const wchar_t* msg)
|
|
|
|
{
|
2012-07-01 18:45:13 +00:00
|
|
|
params->inputFieldInfo.osk_inputfield_message = (uint16_t*)msg;
|
2012-03-25 22:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void oskutil_write_initial_message(oskutil_params *params, const wchar_t* msg)
|
|
|
|
{
|
2012-07-01 18:45:13 +00:00
|
|
|
params->inputFieldInfo.osk_inputfield_starttext = (uint16_t*)msg;
|
2012-03-25 22:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool oskutil_start(oskutil_params *params)
|
|
|
|
{
|
|
|
|
if (params->flags & OSK_IN_USE)
|
2013-01-17 09:40:35 +00:00
|
|
|
{
|
|
|
|
RARCH_WARN("OSK util already initialized and in use\n");
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 09:40:35 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
ret = sys_memory_container_create(¶ms->containerid, params->osk_memorycontainer);
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 13:03:55 +00:00
|
|
|
if (ret < 0)
|
2013-01-17 09:40:35 +00:00
|
|
|
goto do_deinit;
|
|
|
|
|
|
|
|
params->outputInfo.osk_callback_return_param = CELL_OSKDIALOG_INPUT_FIELD_RESULT_OK;
|
|
|
|
params->outputInfo.osk_callback_num_chars = 256;
|
|
|
|
params->outputInfo.osk_callback_return_string = (uint16_t *)params->text_buf;
|
|
|
|
|
|
|
|
memset(params->text_buf, 0, sizeof(*params->text_buf));
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2012-07-01 18:45:13 +00:00
|
|
|
params->inputFieldInfo.osk_inputfield_max_length = CELL_OSKDIALOG_STRING_SIZE;
|
2012-03-25 22:36:40 +00:00
|
|
|
|
|
|
|
oskutil_create_activation_parameters(params);
|
|
|
|
|
2013-01-17 13:03:55 +00:00
|
|
|
if (!oskutil_enable_key_layout())
|
2012-03-25 22:36:40 +00:00
|
|
|
return (false);
|
|
|
|
|
2012-07-01 18:45:13 +00:00
|
|
|
ret = pOskLoadAsync(params->containerid, ¶ms->dialogParam, ¶ms->inputFieldInfo);
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 09:40:35 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto do_deinit;
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 09:40:35 +00:00
|
|
|
params->flags |= OSK_IN_USE;
|
|
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_OSK_DRAW);
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 09:40:35 +00:00
|
|
|
return true;
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2013-01-17 09:40:35 +00:00
|
|
|
do_deinit:
|
|
|
|
RARCH_ERR("Could not properly initialize OSK util.\n");
|
|
|
|
return false;
|
2012-03-25 22:36:40 +00:00
|
|
|
}
|
2012-06-19 03:10:42 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-25 22:36:40 +00:00
|
|
|
/*============================================================
|
2012-11-02 23:30:41 +00:00
|
|
|
RetroArch PS3 INPUT DRIVER
|
|
|
|
============================================================ */
|
2012-03-25 22:36:40 +00:00
|
|
|
|
2012-07-27 23:37:15 +00:00
|
|
|
static void ps3_input_set_analog_dpad_mapping(unsigned device, unsigned map_dpad_enum, unsigned controller_id)
|
2012-03-03 13:57:28 +00:00
|
|
|
{
|
2012-07-27 23:37:15 +00:00
|
|
|
(void)device;
|
|
|
|
|
2012-04-10 19:23:42 +00:00
|
|
|
switch(map_dpad_enum)
|
|
|
|
{
|
|
|
|
case DPAD_EMULATION_NONE:
|
2012-08-22 12:04:33 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_NONE;
|
2012-12-14 16:42:01 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[RETRO_DEVICE_ID_JOYPAD_UP].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[RETRO_DEVICE_ID_JOYPAD_DOWN].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[RETRO_DEVICE_ID_JOYPAD_LEFT].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey;
|
2012-11-02 23:30:41 +00:00
|
|
|
break;
|
2012-04-10 19:23:42 +00:00
|
|
|
case DPAD_EMULATION_LSTICK:
|
2012-08-22 12:04:33 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_LSTICK;
|
2012-12-14 16:42:01 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[RARCH_ANALOG_LEFT_Y_DPAD_UP].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[RARCH_ANALOG_LEFT_Y_DPAD_DOWN].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[RARCH_ANALOG_LEFT_X_DPAD_LEFT].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[RARCH_ANALOG_LEFT_X_DPAD_RIGHT].joykey;
|
2012-11-02 23:30:41 +00:00
|
|
|
break;
|
2012-04-10 19:23:42 +00:00
|
|
|
case DPAD_EMULATION_RSTICK:
|
2012-08-22 12:04:33 +00:00
|
|
|
g_settings.input.dpad_emulation[controller_id] = DPAD_EMULATION_RSTICK;
|
2012-12-14 16:42:01 +00:00
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_UP].joykey = platform_keys[RARCH_ANALOG_RIGHT_Y_DPAD_UP].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = platform_keys[RARCH_ANALOG_RIGHT_Y_DPAD_DOWN].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_LEFT].joykey;
|
|
|
|
g_settings.input.binds[controller_id][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = platform_keys[RARCH_ANALOG_RIGHT_X_DPAD_RIGHT].joykey;
|
2012-11-02 23:30:41 +00:00
|
|
|
break;
|
2012-04-10 19:23:42 +00:00
|
|
|
}
|
2012-01-11 21:27:07 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 23:50:29 +00:00
|
|
|
static void ps3_input_free_input(void *data)
|
2012-07-27 13:46:15 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
//cellPadEnd();
|
|
|
|
}
|
|
|
|
|
2013-03-12 23:12:29 +00:00
|
|
|
static void ps3_set_default_keybind_lut(unsigned device, unsigned port)
|
|
|
|
{
|
|
|
|
(void)device;
|
|
|
|
(void)port;
|
|
|
|
|
|
|
|
for (int i = 0; i < RARCH_CUSTOM_BIND_LIST_END; i++)
|
|
|
|
g_settings.input.default_binds[i] = platform_keys[i].joykey;
|
|
|
|
}
|
2012-07-27 23:37:15 +00:00
|
|
|
|
2013-03-12 23:34:46 +00:00
|
|
|
static void* ps3_input_init(void)
|
2012-07-27 13:46:15 +00:00
|
|
|
{
|
2013-03-12 23:34:46 +00:00
|
|
|
cellPadInit(MAX_PADS);
|
|
|
|
#ifdef HAVE_MOUSE
|
|
|
|
cellMouseInit(MAX_MICE);
|
|
|
|
#endif
|
|
|
|
|
2013-03-12 23:12:29 +00:00
|
|
|
for(unsigned i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
{
|
|
|
|
ps3_set_default_keybind_lut(0, i);
|
|
|
|
rarch_input_set_default_keybinds(i);
|
|
|
|
}
|
|
|
|
|
2013-01-17 13:03:55 +00:00
|
|
|
for (unsigned i = 0; i < MAX_PADS; i++)
|
2013-03-12 23:12:29 +00:00
|
|
|
ps3_input_set_analog_dpad_mapping(0, g_settings.input.dpad_emulation[i], i);
|
2013-03-12 23:34:46 +00:00
|
|
|
|
|
|
|
return (void*)-1;
|
2012-07-27 13:46:15 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 23:50:29 +00:00
|
|
|
static bool ps3_input_key_pressed(void *data, int key)
|
2011-12-02 01:34:06 +00:00
|
|
|
{
|
2012-12-23 13:44:46 +00:00
|
|
|
return (g_extern.lifecycle_state & (1ULL << key));
|
2011-11-30 16:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const input_driver_t input_ps3 = {
|
2012-11-26 23:50:29 +00:00
|
|
|
.init = ps3_input_init,
|
2011-11-30 16:24:18 +00:00
|
|
|
.poll = ps3_input_poll,
|
|
|
|
.input_state = ps3_input_state,
|
2012-11-26 23:50:29 +00:00
|
|
|
.key_pressed = ps3_input_key_pressed,
|
|
|
|
.free = ps3_input_free_input,
|
2012-07-25 19:02:01 +00:00
|
|
|
.set_default_keybind_lut = ps3_set_default_keybind_lut,
|
2012-07-27 13:46:15 +00:00
|
|
|
.set_analog_dpad_mapping = ps3_input_set_analog_dpad_mapping,
|
|
|
|
.max_pads = MAX_PADS,
|
2011-12-02 01:22:29 +00:00
|
|
|
.ident = "ps3",
|
2011-11-30 16:24:18 +00:00
|
|
|
};
|
2011-12-11 12:14:44 +00:00
|
|
|
|