~ubuntu-branches/ubuntu/trusty/libsdl1.2/trusty

« back to all changes in this revision

Viewing changes to src/events/SDL_keyboard.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-12-08 01:50:15 UTC
  • mfrom: (2.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20091208015015-mr68dcbbctrhi5at
Tags: 1.2.14-1ubuntu1
* Merge from Debian experimental, remaining changes:
  + debian/control:
    + add libglu1-mesa-dev as a build dependency, so SDL gets built
      with OpenGL support (LP: #328932)
    - dropped build-depends on libarts1-dev, libartsc0-dev. These
      packages will disappear as part of the arts removal
      (LP: #320915)
    - Removed Package: libsdl1.2debian-arts section entirely
    - dropped depends on libsdl1.2debian-arts (= ${binary:Version})
      for libsdl1.2-debian
    - dropped recommends on libartsc0-dev for libsdl1.2-dev
    - Remove svgalib support.
  + debian/rules:
    + set --enable-arts-shared=no and --enable-arts=no in confflags
    - removed --disable-audio-arts from udeb_confflags
    - dropped arts from FLAVOURS=
    + Link using -Wl,-Bsymbolic-functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    SDL - Simple DirectMedia Layer
3
 
    Copyright (C) 1997-2006 Sam Lantinga
 
3
    Copyright (C) 1997-2009 Sam Lantinga
4
4
 
5
5
    This library is free software; you can redistribute it and/or
6
6
    modify it under the terms of the GNU Lesser General Public
48
48
        SDL_Event evt;    /* the event we are supposed to repeat */
49
49
} SDL_KeyRepeat;
50
50
 
 
51
/* Global no-lock-keys support */
 
52
static Uint8 SDL_NoLockKeys;
 
53
 
 
54
#define SDL_NLK_CAPS 0x01
 
55
#define SDL_NLK_NUM  0x02
 
56
 
51
57
/* Public functions */
52
58
int SDL_KeyboardInit(void)
53
59
{
 
60
        const char* env;
54
61
        SDL_VideoDevice *video = current_video;
55
62
        SDL_VideoDevice *this  = current_video;
56
63
 
65
72
 
66
73
        SDL_EnableKeyRepeat(0, 0);
67
74
 
 
75
        /* Allow environment override to disable special lock-key behavior */
 
76
        SDL_NoLockKeys = 0;
 
77
        env = SDL_getenv("SDL_DISABLE_LOCK_KEYS");
 
78
        if (env) {
 
79
                switch (SDL_atoi(env)) {
 
80
                        case 1:
 
81
                                SDL_NoLockKeys = SDL_NLK_CAPS | SDL_NLK_NUM;
 
82
                                break;
 
83
                        case 2:
 
84
                                SDL_NoLockKeys = SDL_NLK_CAPS;
 
85
                                break;
 
86
                        case 3:
 
87
                                SDL_NoLockKeys = SDL_NLK_NUM;
 
88
                                break;
 
89
                        default:
 
90
                                break;
 
91
                }
 
92
        }
 
93
 
68
94
        /* Fill in the blanks in keynames */
69
95
        keynames[SDLK_BACKSPACE] = "backspace";
70
96
        keynames[SDLK_TAB] = "tab";
394
420
                                break;
395
421
                        case SDLK_NUMLOCK:
396
422
                                modstate ^= KMOD_NUM;
 
423
                                if ( SDL_NoLockKeys & SDL_NLK_NUM )
 
424
                                        break;
397
425
                                if ( ! (modstate&KMOD_NUM) )
398
426
                                        state = SDL_RELEASED;
399
427
                                keysym->mod = (SDLMod)modstate;
400
428
                                break;
401
429
                        case SDLK_CAPSLOCK:
402
430
                                modstate ^= KMOD_CAPS;
 
431
                                if ( SDL_NoLockKeys & SDL_NLK_CAPS )
 
432
                                        break;
403
433
                                if ( ! (modstate&KMOD_CAPS) )
404
434
                                        state = SDL_RELEASED;
405
435
                                keysym->mod = (SDLMod)modstate;
440
470
                        case SDLK_UNKNOWN:
441
471
                                break;
442
472
                        case SDLK_NUMLOCK:
 
473
                                if ( SDL_NoLockKeys & SDL_NLK_NUM )
 
474
                                        break;
 
475
                                /* Only send keydown events */
 
476
                                return(0);
443
477
                        case SDLK_CAPSLOCK:
 
478
                                if ( SDL_NoLockKeys & SDL_NLK_CAPS )
 
479
                                        break;
444
480
                                /* Only send keydown events */
445
481
                                return(0);
446
482
                        case SDLK_LCTRL: