mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
PS3: WIP on keyboard support
This commit is contained in:
parent
b4c30b7122
commit
fba5faa5ee
@ -6,6 +6,9 @@
|
|||||||
ifeq ($(strip $(PS3DEV)),)
|
ifeq ($(strip $(PS3DEV)),)
|
||||||
$(error "Please set PS3DEV in your environment. export PS3DEV=<path>")
|
$(error "Please set PS3DEV in your environment. export PS3DEV=<path>")
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(strip $(PSL1GHT)),)
|
||||||
|
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
|
||||||
|
endif
|
||||||
|
|
||||||
include $(PS3DEV)/ppu_rules
|
include $(PS3DEV)/ppu_rules
|
||||||
|
|
||||||
|
@ -288,6 +288,7 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||||||
union SocketAddress {
|
union SocketAddress {
|
||||||
struct sockaddr raw;
|
struct sockaddr raw;
|
||||||
struct sockaddr_in v4;
|
struct sockaddr_in v4;
|
||||||
|
struct sockaddr_storage total; // matches max size of addr returned by getaddrinfo
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ParseHost(union SocketAddress* addr, const char* host) {
|
static int ParseHost(union SocketAddress* addr, const char* host) {
|
||||||
|
@ -463,7 +463,7 @@ static void Networking_LoadIOPModules(void) {
|
|||||||
union SocketAddress {
|
union SocketAddress {
|
||||||
struct sockaddr raw;
|
struct sockaddr raw;
|
||||||
struct sockaddr_in v4;
|
struct sockaddr_in v4;
|
||||||
struct sockaddr_storage total; // matches size of addr returned by getaddrinfo
|
struct sockaddr_storage total; // matches max size of addr returned by getaddrinfo
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ParseHost(union SocketAddress* addr, const char* host) {
|
static int ParseHost(union SocketAddress* addr, const char* host) {
|
||||||
|
@ -393,8 +393,8 @@ static void InitNetworking(void) {
|
|||||||
SceNetInitParam param;
|
SceNetInitParam param;
|
||||||
|
|
||||||
param.memory = net_memory;
|
param.memory = net_memory;
|
||||||
param.size = sizeof(net_memory);
|
param.size = sizeof(net_memory);
|
||||||
param.flags = 0;
|
param.flags = 0;
|
||||||
|
|
||||||
int ret = sceNetInit(¶m);
|
int ret = sceNetInit(¶m);
|
||||||
if (ret < 0) Platform_Log1("Network init failed: %i", &ret);
|
if (ret < 0) Platform_Log1("Network init failed: %i", &ret);
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
#include <sysutil/video.h>
|
#include <sysutil/video.h>
|
||||||
|
|
||||||
static cc_bool launcherMode;
|
static cc_bool launcherMode;
|
||||||
static padInfo pad_info;
|
static padInfo pad_info;
|
||||||
static padData pad_data;
|
static padData pad_data;
|
||||||
static KbInfo kb_info;
|
static KbInfo kb_info;
|
||||||
static KbData kb_data;
|
static KbData kb_data;
|
||||||
|
static KbConfig kb_config;
|
||||||
|
|
||||||
struct _DisplayData DisplayInfo;
|
struct _DisplayData DisplayInfo;
|
||||||
struct _WinData WindowInfo;
|
struct _WinData WindowInfo;
|
||||||
@ -62,7 +63,8 @@ void Window_Init(void) {
|
|||||||
DisplayInfo.ContentOffsetY = 10;
|
DisplayInfo.ContentOffsetY = 10;
|
||||||
|
|
||||||
ioPadInit(MAX_PORT_NUM);
|
ioPadInit(MAX_PORT_NUM);
|
||||||
//ioKbInit(MAX_KB_PORT_NUM);
|
ioKbInit(MAX_KB_PORT_NUM);
|
||||||
|
ioKbGetConfiguration(0, &kb_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create2D(int width, int height) {
|
void Window_Create2D(int width, int height) {
|
||||||
@ -91,6 +93,41 @@ void Window_Close(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*--------------------------------------------------Keyboard processing----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
static KbMkey old_mods;
|
||||||
|
#define ToggleMod(field, btn) if (diff._KbMkeyU._KbMkeyS. field) Input_Set(btn, mods->_KbMkeyU._KbMkeyS. field);
|
||||||
|
static void ProcessKBModifiers(KbMkey* mods) {
|
||||||
|
KbMkey diff;
|
||||||
|
diff._KbMkeyU.mkeys = mods->_KbMkeyU.mkeys ^ old_mods._KbMkeyU.mkeys;
|
||||||
|
|
||||||
|
ToggleMod(l_alt, CCKEY_LALT);
|
||||||
|
ToggleMod(r_alt, CCKEY_RALT);
|
||||||
|
ToggleMod(l_ctrl, CCKEY_LCTRL);
|
||||||
|
ToggleMod(r_ctrl, CCKEY_RCTRL);
|
||||||
|
ToggleMod(l_shift, CCKEY_LSHIFT);
|
||||||
|
ToggleMod(r_shift, CCKEY_RSHIFT);
|
||||||
|
ToggleMod(l_win, CCKEY_LWIN);
|
||||||
|
ToggleMod(r_win, CCKEY_RWIN);
|
||||||
|
|
||||||
|
old_mods = *mods;
|
||||||
|
}
|
||||||
|
// TODO ProcessKBButtons()
|
||||||
|
// TODO: Call at init ioKbSetCodeType(0, KB_CODETYPE_RAW); ioKbSetReadMode(0, KB_RMODE_INPUTCHAR);
|
||||||
|
static void ProcessKBTextInput(void) {
|
||||||
|
for (int i = 0; i < kb_data.nb_keycode; i++)
|
||||||
|
{
|
||||||
|
int rawcode = kb_data.keycode[i];
|
||||||
|
if (!rawcode) continue;
|
||||||
|
int unicode = ioKbCnvRawCode(kb_config.mapping, kb_data.mkey, kb_data.led, rawcode);
|
||||||
|
|
||||||
|
char C = unicode;
|
||||||
|
//Platform_Log4("%i --> %i / %h / %r", &rawcode, &unicode, &unicode, &C);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*----------------------------------------------------Input processing-----------------------------------------------------*
|
*----------------------------------------------------Input processing-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -114,6 +151,7 @@ static void HandleButtons(padData* data) {
|
|||||||
Input_SetNonRepeatable(CCPAD_ZL, data->BTN_L2);
|
Input_SetNonRepeatable(CCPAD_ZL, data->BTN_L2);
|
||||||
Input_SetNonRepeatable(CCPAD_ZR, data->BTN_R2);
|
Input_SetNonRepeatable(CCPAD_ZR, data->BTN_R2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleJoystick_Left(int x, int y) {
|
static void HandleJoystick_Left(int x, int y) {
|
||||||
if (Math_AbsI(x) <= 32) x = 0;
|
if (Math_AbsI(x) <= 32) x = 0;
|
||||||
if (Math_AbsI(y) <= 32) y = 0;
|
if (Math_AbsI(y) <= 32) y = 0;
|
||||||
@ -122,6 +160,7 @@ static void HandleJoystick_Left(int x, int y) {
|
|||||||
Input.JoystickMovement = true;
|
Input.JoystickMovement = true;
|
||||||
Input.JoystickAngle = Math_Atan2(x, -y);
|
Input.JoystickAngle = Math_Atan2(x, -y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleJoystick_Right(int x, int y, double delta) {
|
static void HandleJoystick_Right(int x, int y, double delta) {
|
||||||
float scale = (delta * 60.0) / 64.0f;
|
float scale = (delta * 60.0) / 64.0f;
|
||||||
|
|
||||||
@ -137,6 +176,7 @@ static void ProcessPadInput(double delta, padData* pad) {
|
|||||||
HandleJoystick_Right(pad->ANA_R_H - 0x80, pad->ANA_R_V - 0x80, delta);
|
HandleJoystick_Right(pad->ANA_R_H - 0x80, pad->ANA_R_V - 0x80, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Window_ProcessEvents(double delta) {
|
void Window_ProcessEvents(double delta) {
|
||||||
Input.JoystickMovement = false;
|
Input.JoystickMovement = false;
|
||||||
|
|
||||||
@ -146,11 +186,15 @@ void Window_ProcessEvents(double delta) {
|
|||||||
ProcessPadInput(delta, &pad_data);
|
ProcessPadInput(delta, &pad_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ioKbGetInfo(&kb_info);
|
// TODO set InputSource keyboard
|
||||||
//if (kb_info.status[0]) {
|
ioKbGetInfo(&kb_info);
|
||||||
// int RES = ioKbRead(0, &kb_data);
|
if (kb_info.status[0]) {
|
||||||
// Platform_Log1("RES: %i", &RES);
|
int res = ioKbRead(0, &kb_data);
|
||||||
//}
|
if (res == 0 && kb_data.nb_keycode > 0) {
|
||||||
|
ProcessKBModifiers(&kb_data.mkey);
|
||||||
|
ProcessKBTextInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
void Cursor_SetPosition(int x, int y) { } // Makes no sense for PS Vita
|
||||||
|
Loading…
x
Reference in New Issue
Block a user