Blob Blame History Raw
/*********************************************************/
/*  ptycon: a pty-console bridge                         */
/*  Copyright (C) 2016--2017  SysDeer Technologies, LLC  */
/*  Released under GPLv2 and GPLv3; see COPYING.PTYCON.  */
/*********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntcon/ntcon.h>
#include <ntcon/ntcon_vkcode.h>

#include <ptycon/ptycon.h>
#include "ptycon_bridge_impl.h"

#define P0()            {(const unsigned char[]){0},0}
#define P1(a)           {(const unsigned char[]){a,0},1}
#define P2(a,b)         {(const unsigned char[]){a,b,0},2}
#define P3(a,b,c)       {(const unsigned char[]){a,b,c,0},3}
#define P4(a,b,c,d)     {(const unsigned char[]){a,b,c,d,0},4}
#define P5(a,b,c,d,e)   {(const unsigned char[]){a,b,c,d,e,0},5}
#define P6(a,b,c,d,e,f) {(const unsigned char[]){a,b,c,d,e,f,0},6}

const struct ptyc_vkcode ptyc_vkcode[0x100] = {
	[VK_LBUTTON] =            P0(),
	[VK_RBUTTON] =            P0(),
	[VK_CANCEL] =             P0(),
	[VK_MBUTTON] =            P0(),
	[VK_XBUTTON1] =           P0(),
	[VK_XBUTTON2] =           P0(),
	[VK_BACK] =               P0(),
	[VK_TAB] =                P0(),
	[VK_CLEAR] =              P0(),
	[VK_RETURN] =             P0(),
	[VK_SHIFT] =              P0(),
	[VK_CONTROL] =            P0(),
	[VK_MENU] =               P0(),
	[VK_PAUSE] =              P0(),
	[VK_CAPITAL] =            P0(),
	[VK_HANGUL] =             P0(),
	[VK_JUNJA] =              P0(),
	[VK_FINAL] =              P0(),
	[VK_KANJI] =              P0(),
	[VK_ESCAPE] =             P0(),
	[VK_CONVERT] =            P0(),
	[VK_NONCONVERT] =         P0(),
	[VK_ACCEPT] =             P0(),
	[VK_MODECHANGE] =         P0(),
	[VK_SPACE] =              P0(),
	[VK_PRIOR] =              P4(0x1b,0x5b,0x35,0x7e),
	[VK_NEXT] =               P4(0x1b,0x5b,0x36,0x7e),
	[VK_END] =                P3(0x1b,0x5b,0x46),
	[VK_HOME] =               P3(0x1b,0x5b,0x48),
	[VK_LEFT] =               P3(0x1b,0x5b,0x44),
	[VK_UP] =                 P3(0x1b,0x5b,0x41),
	[VK_RIGHT] =              P3(0x1b,0x5b,0x43),
	[VK_DOWN] =               P3(0x1b,0x5b,0x42),
	[VK_SELECT] =             P0(),
	[VK_PRINT] =              P0(),
	[VK_EXECUTE] =            P0(),
	[VK_SNAPSHOT] =           P0(),
	[VK_INSERT] =             P4(0x1b,0x5b,0x32,0x7e),
	[VK_DELETE] =             P4(0x1b,0x5b,0x33,0x7e),
	[VK_HELP] =               P0(),
	[VK_LWIN] =               P0(),
	[VK_RWIN] =               P0(),
	[VK_APPS] =               P0(),
	[VK_SLEEP] =              P0(),
	[VK_NUMPAD0] =            P0(),
	[VK_NUMPAD1] =            P0(),
	[VK_NUMPAD2] =            P0(),
	[VK_NUMPAD3] =            P0(),
	[VK_NUMPAD4] =            P0(),
	[VK_NUMPAD5] =            P0(),
	[VK_NUMPAD6] =            P0(),
	[VK_NUMPAD7] =            P0(),
	[VK_NUMPAD8] =            P0(),
	[VK_NUMPAD9] =            P0(),
	[VK_MULTIPLY] =           P0(),
	[VK_ADD] =                P0(),
	[VK_SEPARATOR] =          P0(),
	[VK_SUBTRACT] =           P0(),
	[VK_DECIMAL] =            P0(),
	[VK_DIVIDE] =             P0(),
	[VK_F1] =                 P3(0x1b,0x4f,0x50),
	[VK_F2] =                 P3(0x1b,0x4f,0x51),
	[VK_F3] =                 P3(0x1b,0x4f,0x52),
	[VK_F4] =                 P3(0x1b,0x4f,0x53),
	[VK_F5] =                 P5(0x1b,0x5b,0x31,0x35,0x7e),
	[VK_F6] =                 P5(0x1b,0x5b,0x31,0x37,0x7e),
	[VK_F7] =                 P5(0x1b,0x5b,0x31,0x38,0x7e),
	[VK_F8] =                 P5(0x1b,0x5b,0x31,0x39,0x7e),
	[VK_F9] =                 P5(0x1b,0x5b,0x32,0x30,0x7e),
	[VK_F10] =                P5(0x1b,0x5b,0x32,0x31,0x7e),
	[VK_F11] =                P5(0x1b,0x5b,0x32,0x33,0x7e),
	[VK_F12] =                P5(0x1b,0x5b,0x32,0x34,0x7e),
	[VK_F13] =                P0(),
	[VK_F14] =                P0(),
	[VK_F15] =                P0(),
	[VK_F16] =                P0(),
	[VK_F17] =                P0(),
	[VK_F18] =                P0(),
	[VK_F19] =                P0(),
	[VK_F20] =                P0(),
	[VK_F21] =                P0(),
	[VK_F22] =                P0(),
	[VK_F23] =                P0(),
	[VK_F24] =                P0(),
	[VK_NUMLOCK] =            P0(),
	[VK_SCROLL] =             P0(),
	[VK_LSHIFT] =             P0(),
	[VK_RSHIFT] =             P0(),
	[VK_LCONTROL] =           P0(),
	[VK_RCONTROL] =           P0(),
	[VK_LMENU] =              P0(),
	[VK_RMENU] =              P0(),
	[VK_BROWSER_BACK] =       P0(),
	[VK_BROWSER_FORWARD] =    P0(),
	[VK_BROWSER_REFRESH] =    P0(),
	[VK_BROWSER_STOP] =       P0(),
	[VK_BROWSER_SEARCH] =     P0(),
	[VK_BROWSER_FAVORITES] =  P0(),
	[VK_BROWSER_HOME] =       P0(),
	[VK_VOLUME_MUTE] =        P0(),
	[VK_VOLUME_DOWN] =        P0(),
	[VK_VOLUME_UP] =          P0(),
	[VK_MEDIA_NEXT_TRACK] =   P0(),
	[VK_MEDIA_PREV_TRACK] =   P0(),
	[VK_MEDIA_STOP] =         P0(),
	[VK_MEDIA_PLAY_PAUSE] =   P0(),
	[VK_LAUNCH_MAIL] =        P0(),
	[VK_LAUNCH_MEDIA_SELECT] =P0(),
	[VK_LAUNCH_APP1] =        P0(),
	[VK_LAUNCH_APP2] =        P0(),
	[VK_OEM_1] =              P0(),
	[VK_OEM_PLUS] =           P0(),
	[VK_OEM_COMMA] =          P0(),
	[VK_OEM_MINUS] =          P0(),
	[VK_OEM_PERIOD] =         P0(),
	[VK_OEM_2] =              P0(),
	[VK_OEM_3] =              P0(),
	[VK_OEM_4] =              P0(),
	[VK_OEM_5] =              P0(),
	[VK_OEM_6] =              P0(),
	[VK_OEM_7] =              P0(),
	[VK_OEM_8] =              P0(),
	[VK_OEM_102] =            P0(),
	[VK_PROCESSKEY] =         P0(),
	[VK_PACKET] =             P0(),
	[VK_ATTN] =               P0(),
	[VK_CRSEL] =              P0(),
	[VK_EXSEL] =              P0(),
	[VK_EREOF] =              P0(),
	[VK_PLAY] =               P0(),
	[VK_ZOOM] =               P0(),
	[VK_NONAME] =             P0(),
	[VK_PA1] =                P0(),
	[VK_OEM_CLEAR] =          P0(),
};