Skip to content

Commit

Permalink
VITA: Fix Caps Lock and Num Lock BT keys
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Dec 24, 2017
1 parent 39d5687 commit c40c62b
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/video/psp2/SDL_psp2keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ Uint8 locks = 0;

const int numkeys = 0xE8;
const int keymap[0xE8] = {
255, 255, 255, 255, SDLK_a, SDLK_b, SDLK_c, SDLK_d,
0, 0, 0, 0, SDLK_a, SDLK_b, SDLK_c, SDLK_d,
SDLK_e, SDLK_f, SDLK_g, SDLK_h, SDLK_i, SDLK_j, SDLK_k, SDLK_l,
SDLK_m, SDLK_n, SDLK_o, SDLK_p, SDLK_q, SDLK_r, SDLK_s, SDLK_t,
SDLK_u, SDLK_v, SDLK_w, SDLK_x, SDLK_y, SDLK_z, SDLK_1, SDLK_2,
SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0,
SDLK_RETURN, SDLK_ESCAPE, SDLK_BACKSPACE, SDLK_TAB, SDLK_SPACE, SDLK_MINUS, SDLK_EQUALS, SDLK_LEFTBRACKET,
SDLK_RIGHTBRACKET, SDLK_BACKSLASH, 255, SDLK_SEMICOLON, SDLK_BACKQUOTE, SDLK_QUOTE, SDLK_COMMA, SDLK_PERIOD,
SDLK_RIGHTBRACKET, SDLK_BACKSLASH, SDLK_HASH, SDLK_SEMICOLON, SDLK_BACKQUOTE, SDLK_QUOTE, SDLK_COMMA, SDLK_PERIOD,
SDLK_SLASH, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6,
SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12, SDLK_PRINT, SDLK_SCROLLOCK,
SDLK_BREAK, SDLK_INSERT, SDLK_HOME, SDLK_PAGEUP, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN, SDLK_RIGHT,
SDLK_LEFT, SDLK_DOWN, SDLK_UP, SDLK_NUMLOCK, SDLK_KP_DIVIDE, SDLK_KP_MULTIPLY, SDLK_KP_MINUS, SDLK_KP_PLUS,
SDLK_KP_ENTER, SDLK_KP1, SDLK_KP2, SDLK_KP3, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP7,
SDLK_KP8, SDLK_KP9, SDLK_KP0, SDLK_KP_PERIOD, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
SDLK_LCTRL, SDLK_LSHIFT, SDLK_LALT, SDLK_LSUPER, SDLK_RCTRL, SDLK_RSHIFT, SDLK_RALT, SDLK_RSUPER
SDLK_KP8, SDLK_KP9, SDLK_KP0, SDLK_KP_PERIOD, SDLK_KP_EQUALS, SDLK_F13, SDLK_F14, SDLK_F15,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
SDLK_LCTRL, SDLK_LSHIFT, SDLK_LALT, SDLK_LMETA, SDLK_RCTRL, SDLK_RSHIFT, SDLK_RALT, SDLK_RMETA
};

const int SCANCODE_NUMLOCKCLEAR = 0x53;
Expand Down Expand Up @@ -123,6 +123,8 @@ PSP2_PollKeyboard(void)
SDL_keysym keysym;
if (keyboard_hid_handle > 0)
{
// Capslock and Numlock keys only change state on SDL_PRESSED

int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT);

if (numReports < 0) {
Expand All @@ -138,7 +140,7 @@ PSP2_PollKeyboard(void)
}
else {
if (locks & 0x1) {
SDL_PrivateKeyboard(SDL_RELEASED, PSP2_TranslateKey(SCANCODE_NUMLOCKCLEAR, &keysym, 0));
SDL_PrivateKeyboard(SDL_PRESSED, PSP2_TranslateKey(SCANCODE_NUMLOCKCLEAR, &keysym, 0));
locks &= ~0x1;
}
}
Expand All @@ -151,8 +153,8 @@ PSP2_PollKeyboard(void)
}
else {
if (locks & 0x2) {
SDL_PrivateKeyboard(SDL_RELEASED, PSP2_TranslateKey(SCANCODE_CAPSLOCK, &keysym, 0));
locks &= 0x2;
SDL_PrivateKeyboard(SDL_PRESSED, PSP2_TranslateKey(SCANCODE_CAPSLOCK, &keysym, 0));
locks &= ~0x2;
}
}

Expand Down Expand Up @@ -243,9 +245,9 @@ PSP2_PollKeyboard(void)
int keyCode = k_reports[numReports-1].keycodes[i];

if (keyCode != prev_keys[i]) {

SDL_PrivateKeyboard(SDL_RELEASED, PSP2_TranslateKey(prev_keys[i], &keysym, 0));

if (prev_keys[i]) {
SDL_PrivateKeyboard(SDL_RELEASED, PSP2_TranslateKey(prev_keys[i], &keysym, 0));
}
if (keyCode) {
SDL_PrivateKeyboard(SDL_PRESSED, PSP2_TranslateKey(keyCode, &keysym, 1));
}
Expand Down

0 comments on commit c40c62b

Please sign in to comment.