CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/sceCtrl.h
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include "Common/CommonTypes.h"
21
22
class PointerWrap;
23
24
void Register_sceCtrl();
25
26
const int CTRL_STICK_LEFT = 0;
27
// The actual PSP only has one, but HD remasters expose this, maybe also the emulator on the PSP/Vita.
28
const int CTRL_STICK_RIGHT = 1;
29
30
#define CTRL_SQUARE 0x8000
31
#define CTRL_TRIANGLE 0x1000
32
#define CTRL_CIRCLE 0x2000
33
#define CTRL_CROSS 0x4000
34
#define CTRL_UP 0x0010
35
#define CTRL_DOWN 0x0040
36
#define CTRL_LEFT 0x0080
37
#define CTRL_RIGHT 0x0020
38
#define CTRL_START 0x0008
39
#define CTRL_SELECT 0x0001
40
#define CTRL_LTRIGGER 0x0100
41
#define CTRL_RTRIGGER 0x0200
42
43
// System-ish buttons. Not generally used by games.
44
#define CTRL_HOME 0x00010000
45
#define CTRL_HOLD 0x00020000
46
#define CTRL_WLAN 0x00040000
47
#define CTRL_REMOTE_HOLD 0x00080000
48
#define CTRL_VOL_UP 0x00100000
49
#define CTRL_VOL_DOWN 0x00200000
50
#define CTRL_SCREEN 0x00400000
51
#define CTRL_NOTE 0x00800000
52
#define CTRL_DISC 0x01000000
53
#define CTRL_MEMSTICK 0x02000000
54
#define CTRL_FORWARD 0x10000000
55
#define CTRL_BACK 0x20000000
56
#define CTRL_PLAYPAUSE 0x40000000
57
58
// Obscure extra keys that were never mapped to hardware, but can be used to bring up the debug menu in SOTN, see issue #17464
59
#define CTRL_L3 0x0002
60
#define CTRL_R3 0x0004
61
#define CTRL_L2 0x0400
62
#define CTRL_R2 0x0800
63
64
#define CTRL_MASK_DPAD (CTRL_UP | CTRL_DOWN | CTRL_LEFT | CTRL_RIGHT)
65
#define CTRL_MASK_ACTION (CTRL_SQUARE | CTRL_TRIANGLE | CTRL_CIRCLE | CTRL_CROSS)
66
#define CTRL_MASK_TRIGGER (CTRL_LTRIGGER | CTRL_RTRIGGER)
67
#define CTRL_MASK_USER (CTRL_MASK_DPAD | CTRL_MASK_ACTION | CTRL_START | CTRL_SELECT | CTRL_MASK_TRIGGER | CTRL_HOME | CTRL_HOLD | CTRL_WLAN | CTRL_REMOTE_HOLD | CTRL_VOL_UP | CTRL_VOL_DOWN | CTRL_SCREEN | CTRL_NOTE | CTRL_L2 | CTRL_L3 | CTRL_R2 | CTRL_R3)
68
69
void __CtrlInit();
70
void __CtrlDoState(PointerWrap &p);
71
void __CtrlShutdown();
72
73
// Clears and sets selected buttons. NOTE: Clearing happens first.
74
void __CtrlUpdateButtons(u32 bitsToSet, u32 bitsToClear);
75
76
// Call this to set the position of an analog stick, ideally when it changes.
77
// X and Y values should be from -1 to 1, inclusive, in a square (no need to force to a circle.)
78
// No deadzone filtering is done (but note that this applies to the actual PSP as well.)
79
void __CtrlSetAnalogXY(int stick, float x, float y);
80
void __CtrlSetAnalogX(int stick, float x);
81
void __CtrlSetAnalogY(int stick, float y);
82
83
// Call this to enable rapid-fire. This will cause buttons other than arrows to alternate.
84
void __CtrlSetRapidFire(bool state, int interval);
85
bool __CtrlGetRapidFire();
86
87
// For use by internal UI like MsgDialog
88
u32 __CtrlPeekButtons();
89
u32 __CtrlPeekButtonsVisual(); // also incorporates rapid-fire
90
void __CtrlPeekAnalog(int stick, float *x, float *y);
91
u32 __CtrlReadLatch();
92
93
void Register_sceCtrl_driver();
94
95
u16 sceCtrlGetRightVibration();
96
u16 sceCtrlGetLeftVibration();
97
98
namespace SceCtrl {
99
void SetLeftVibration(u16 lVibration);
100
void SetRightVibration(u16 rVibration);
101
void SetVibrationLeftDropout(u8 vibrationLDropout);
102
void SetVibrationRightDropout(u8 vibrationRDropout);
103
};
104
105