SDL中按键对应的值

  想用SDL的按键检测,网上找了半天都没找到SDL中按键的值的定义,索性自己去看头文件,在SDL_keysym.h中。

  其实很多键的值和它们的ASCII码是相同的。

  其他更多的用法,可以参考这篇博客:http://blog.chinaunix.net/uid-28482676-id-3444915.html/

typedef enum {
        /** @name ASCII mapped keysyms
         *  The keyboard syms have been cleverly chosen to map to ASCII
         */
        /*@{*/
    SDLK_UNKNOWN        = 0,
    SDLK_FIRST        = 0,
    SDLK_BACKSPACE        = 8,
    SDLK_TAB        = 9,
    SDLK_CLEAR        = 12,
    SDLK_RETURN        = 13,
    SDLK_PAUSE        = 19,
    SDLK_ESCAPE        = 27,
    SDLK_SPACE        = 32,
    SDLK_EXCLAIM        = 33,
    SDLK_QUOTEDBL        = 34,
    SDLK_HASH        = 35,
    SDLK_DOLLAR        = 36,
    SDLK_AMPERSAND        = 38,
    SDLK_QUOTE        = 39,
    SDLK_LEFTPAREN        = 40,
    SDLK_RIGHTPAREN        = 41,
    SDLK_ASTERISK        = 42,
    SDLK_PLUS        = 43,
    SDLK_COMMA        = 44,
    SDLK_MINUS        = 45,
    SDLK_PERIOD        = 46,
    SDLK_SLASH        = 47,
    SDLK_0            = 48,
    SDLK_1            = 49,
    SDLK_2            = 50,
    SDLK_3            = 51,
    SDLK_4            = 52,
    SDLK_5            = 53,
    SDLK_6            = 54,
    SDLK_7            = 55,
    SDLK_8            = 56,
    SDLK_9            = 57,
    SDLK_COLON        = 58,
    SDLK_SEMICOLON        = 59,
    SDLK_LESS        = 60,
    SDLK_EQUALS        = 61,
    SDLK_GREATER        = 62,
    SDLK_QUESTION        = 63,
    SDLK_AT            = 64,
    /*
       Skip uppercase letters
     */
    SDLK_LEFTBRACKET    = 91,
    SDLK_BACKSLASH        = 92,
    SDLK_RIGHTBRACKET    = 93,
    SDLK_CARET        = 94,
    SDLK_UNDERSCORE        = 95,
    SDLK_BACKQUOTE        = 96,
    SDLK_a            = 97,
    SDLK_b            = 98,
    SDLK_c            = 99,
    SDLK_d            = 100,
    SDLK_e            = 101,
    SDLK_f            = 102,
    SDLK_g            = 103,
    SDLK_h            = 104,
    SDLK_i            = 105,
    SDLK_j            = 106,
    SDLK_k            = 107,
    SDLK_l            = 108,
    SDLK_m            = 109,
    SDLK_n            = 110,
    SDLK_o            = 111,
    SDLK_p            = 112,
    SDLK_q            = 113,
    SDLK_r            = 114,
    SDLK_s            = 115,
    SDLK_t            = 116,
    SDLK_u            = 117,
    SDLK_v            = 118,
    SDLK_w            = 119,
    SDLK_x            = 120,
    SDLK_y            = 121,
    SDLK_z            = 122,
    SDLK_DELETE        = 127,
    /* End of ASCII mapped keysyms */
        /*@}*/

    /** @name International keyboard syms */
        /*@{*/
    SDLK_WORLD_0        = 160,        /* 0xA0 */
    SDLK_WORLD_1        = 161,
    SDLK_WORLD_2        = 162,
    SDLK_WORLD_3        = 163,
    SDLK_WORLD_4        = 164,
    SDLK_WORLD_5        = 165,
    SDLK_WORLD_6        = 166,
    SDLK_WORLD_7        = 167,
    SDLK_WORLD_8        = 168,
    SDLK_WORLD_9        = 169,
    SDLK_WORLD_10        = 170,
    SDLK_WORLD_11        = 171,
    SDLK_WORLD_12        = 172,
    SDLK_WORLD_13        = 173,
    SDLK_WORLD_14        = 174,
    SDLK_WORLD_15        = 175,
    SDLK_WORLD_16        = 176,
    SDLK_WORLD_17        = 177,
    SDLK_WORLD_18        = 178,
    SDLK_WORLD_19        = 179,
    SDLK_WORLD_20        = 180,
    SDLK_WORLD_21        = 181,
    SDLK_WORLD_22        = 182,
    SDLK_WORLD_23        = 183,
    SDLK_WORLD_24        = 184,
    SDLK_WORLD_25        = 185,
    SDLK_WORLD_26        = 186,
    SDLK_WORLD_27        = 187,
    SDLK_WORLD_28        = 188,
    SDLK_WORLD_29        = 189,
    SDLK_WORLD_30        = 190,
    SDLK_WORLD_31        = 191,
    SDLK_WORLD_32        = 192,
    SDLK_WORLD_33        = 193,
    SDLK_WORLD_34        = 194,
    SDLK_WORLD_35        = 195,
    SDLK_WORLD_36        = 196,
    SDLK_WORLD_37        = 197,
    SDLK_WORLD_38        = 198,
    SDLK_WORLD_39        = 199,
    SDLK_WORLD_40        = 200,
    SDLK_WORLD_41        = 201,
    SDLK_WORLD_42        = 202,
    SDLK_WORLD_43        = 203,
    SDLK_WORLD_44        = 204,
    SDLK_WORLD_45        = 205,
    SDLK_WORLD_46        = 206,
    SDLK_WORLD_47        = 207,
    SDLK_WORLD_48        = 208,
    SDLK_WORLD_49        = 209,
    SDLK_WORLD_50        = 210,
    SDLK_WORLD_51        = 211,
    SDLK_WORLD_52        = 212,
    SDLK_WORLD_53        = 213,
    SDLK_WORLD_54        = 214,
    SDLK_WORLD_55        = 215,
    SDLK_WORLD_56        = 216,
    SDLK_WORLD_57        = 217,
    SDLK_WORLD_58        = 218,
    SDLK_WORLD_59        = 219,
    SDLK_WORLD_60        = 220,
    SDLK_WORLD_61        = 221,
    SDLK_WORLD_62        = 222,
    SDLK_WORLD_63        = 223,
    SDLK_WORLD_64        = 224,
    SDLK_WORLD_65        = 225,
    SDLK_WORLD_66        = 226,
    SDLK_WORLD_67        = 227,
    SDLK_WORLD_68        = 228,
    SDLK_WORLD_69        = 229,
    SDLK_WORLD_70        = 230,
    SDLK_WORLD_71        = 231,
    SDLK_WORLD_72        = 232,
    SDLK_WORLD_73        = 233,
    SDLK_WORLD_74        = 234,
    SDLK_WORLD_75        = 235,
    SDLK_WORLD_76        = 236,
    SDLK_WORLD_77        = 237,
    SDLK_WORLD_78        = 238,
    SDLK_WORLD_79        = 239,
    SDLK_WORLD_80        = 240,
    SDLK_WORLD_81        = 241,
    SDLK_WORLD_82        = 242,
    SDLK_WORLD_83        = 243,
    SDLK_WORLD_84        = 244,
    SDLK_WORLD_85        = 245,
    SDLK_WORLD_86        = 246,
    SDLK_WORLD_87        = 247,
    SDLK_WORLD_88        = 248,
    SDLK_WORLD_89        = 249,
    SDLK_WORLD_90        = 250,
    SDLK_WORLD_91        = 251,
    SDLK_WORLD_92        = 252,
    SDLK_WORLD_93        = 253,
    SDLK_WORLD_94        = 254,
    SDLK_WORLD_95        = 255,        /* 0xFF */
        /*@}*/

    /** @name Numeric keypad */
        /*@{*/
    SDLK_KP0        = 256,
    SDLK_KP1        = 257,
    SDLK_KP2        = 258,
    SDLK_KP3        = 259,
    SDLK_KP4        = 260,
    SDLK_KP5        = 261,
    SDLK_KP6        = 262,
    SDLK_KP7        = 263,
    SDLK_KP8        = 264,
    SDLK_KP9        = 265,
    SDLK_KP_PERIOD        = 266,
    SDLK_KP_DIVIDE        = 267,
    SDLK_KP_MULTIPLY    = 268,
    SDLK_KP_MINUS        = 269,
    SDLK_KP_PLUS        = 270,
    SDLK_KP_ENTER        = 271,
    SDLK_KP_EQUALS        = 272,
        /*@}*/

    /** @name Arrows + Home/End pad */
        /*@{*/
    SDLK_UP            = 273,
    SDLK_DOWN        = 274,
    SDLK_RIGHT        = 275,
    SDLK_LEFT        = 276,
    SDLK_INSERT        = 277,
    SDLK_HOME        = 278,
    SDLK_END        = 279,
    SDLK_PAGEUP        = 280,
    SDLK_PAGEDOWN        = 281,
        /*@}*/

    /** @name Function keys */
        /*@{*/
    SDLK_F1            = 282,
    SDLK_F2            = 283,
    SDLK_F3            = 284,
    SDLK_F4            = 285,
    SDLK_F5            = 286,
    SDLK_F6            = 287,
    SDLK_F7            = 288,
    SDLK_F8            = 289,
    SDLK_F9            = 290,
    SDLK_F10        = 291,
    SDLK_F11        = 292,
    SDLK_F12        = 293,
    SDLK_F13        = 294,
    SDLK_F14        = 295,
    SDLK_F15        = 296,
        /*@}*/

    /** @name Key state modifier keys */
        /*@{*/
    SDLK_NUMLOCK        = 300,
    SDLK_CAPSLOCK        = 301,
    SDLK_SCROLLOCK        = 302,
    SDLK_RSHIFT        = 303,
    SDLK_LSHIFT        = 304,
    SDLK_RCTRL        = 305,
    SDLK_LCTRL        = 306,
    SDLK_RALT        = 307,
    SDLK_LALT        = 308,
    SDLK_RMETA        = 309,
    SDLK_LMETA        = 310,
    SDLK_LSUPER        = 311,        /**< Left "Windows" key */
    SDLK_RSUPER        = 312,        /**< Right "Windows" key */
    SDLK_MODE        = 313,        /**< "Alt Gr" key */
    SDLK_COMPOSE        = 314,        /**< Multi-key compose key */
        /*@}*/

    /** @name Miscellaneous function keys */
        /*@{*/
    SDLK_HELP        = 315,
    SDLK_PRINT        = 316,
    SDLK_SYSREQ        = 317,
    SDLK_BREAK        = 318,
    SDLK_MENU        = 319,
    SDLK_POWER        = 320,        /**< Power Macintosh power key */
    SDLK_EURO        = 321,        /**< Some european keyboards */
    SDLK_UNDO        = 322,        /**< Atari keyboard has Undo */
        /*@}*/

    /* Add any other keys here */

    SDLK_LAST
} SDLKey;

原文地址:https://www.cnblogs.com/urriia/p/10668229.html

时间: 2024-10-22 13:50:48

SDL中按键对应的值的相关文章

20150218【改进】IMX257实现GPIO-IRQ中断按键获取键值驱动程序

[改进]IMX257实现GPIO-IRQ中断按键获取键值驱动程序 2015-02-18 李海沿 一.使用struct pin_desc 管理按键的值 1.定义结构体 2.将前面我们申请中断时写的(void *)1修改为 &pins_desc[n] 在ioctl中,设置中断中修改 在key_release中释放中修改 3.在中断程序中利用我们定义的struc pins_desc判断并得到按键的值 4.得到按键键值后,唤醒程序,在read函数中返回键值 附上驱动源程序: 1 /***********

20150218【改进信号量】IMX257实现GPIO-IRQ中断按键获取键值驱动程序

[改进信号量]IMX257实现GPIO-IRQ中断按键获取键值驱动程序 2015-02-18 李海沿 前面我们使用POLL查询方式来实现GPIO-IRQ按键中断程序 这里我们来使用信号量,让我们的驱动同时只能有一个应用程序打开. 一.首先在前面代码的基础上来一个简单的信号 1.定义一个全局的整形变量 2.在打开函数中,每次进入打开函数canopen都自减1, 3.当我们不使用时,在realease 中canopen自加1 4.这样就实现了一个简单的信号量,我们编译,测试 当我们使用两个应用程序来

20150218【改进Poll定时查询】IMX257实现GPIO-IRQ中断按键获取键值驱动程序

[改进Poll定时查询]IMX257实现GPIO-IRQ中断按键获取键值驱动程序 2015-02-18 李海沿 按键驱动程序中,如果不使用read函数中使程序休眠的,而是还是使用查询方式的话,可以使用Poll函数,来控制一定时间内,如果有按键发生,则立即返回键值. 同时,poll也可以同时监控多个(比如说按键,鼠标,等)一旦发生事件则立即返回. 我们在linux查看帮助: 从帮助中的说明得知, poll, ppoll - wait for some event on a file descrip

如何在makfile中查看变量的值

在makefile中查看变量的取值是多少应该是一个比较麻烦的问题,但是本大神自己研究出一个十分方便的方法.这个方法十分简单.现在介绍如下 如果在一个十分复杂庞大的makefile文件中,有个地方用到一个变量SRC_FILE,你很想知道makefile运行到此处的时候这个变量的值为多少.那么你可以在这个变量的下面写两行东东: $(shell echo $(SRC_FILE) > readme.txt ) rrrrrrrrrrrrrrrrrrr 第一行其实是调用shell命令来将这个变量的值输入到r

使用LINQ获取List列表中的某个字段值

使用LINQ获取列表中的某个字段值,下面以获取员工列表中的编号字段为例子. 1.使用Select方法 1 List<Emplayee> emplayeeList = GetEmplayeeList(); //获取员工信息列表 2 int[] empIds = emplayeeList.Select(a => a.Id).ToArray(); //获取员工编号数组 2.使用ForEach方法 1 List<Emplayee> emplayeeList = GetEmplayee

Action 名称搜索顺序&amp;Action配置中的各项默认值

Action 名称的搜索顺序  一级一级往上,若命名空间包存在,但Action不存在,则跑到默认命名空间. Action 配置中的各项默认值    默认类class:ActionSupport    默认方法method:action的 execute    默认result name :success

C/C++ 语言中的表达式求值

蛱酝缒 C/C++ 语言中的表达式求值

JAVA-栈实现中序表达式求值

中序表达式对我们而言是很直观的(我们平时接触的就是这个),但计算机处理起来比较麻烦(括号.优先级之类的),前序和后序表达式中没有括号,而且在计算中只需单向扫描,不需要考虑运算符的优先级.如2*3/(2-1)+3*(4-1) 前序表达式就是前缀表达式,不含括号的算术表达式,而且它是将运算符写在前面,操作数写在后面的表达式,例如:+/*23-21*3-4,也称为"波兰式". 后序表达式与前序表达式扫描方式正好相反,例如:23*21-/341-*+. 用两个栈实现中序表达式求值,表达式中只支

Linq 中按照多个值进行分组(GroupBy)

Linq 中按照多个值进行分组(GroupBy) .GroupBy(x => new { x.Age, x.Sex }) group emp by new { emp.Age, emp.Sex } into g // 实现多key分组的扩展函数版本 var sums = empList .GroupBy(x => new { x.Age, x.Sex }) .Select(group => new { Peo = group.Key, Count = group.Count() });