~ubuntu-branches/ubuntu/trusty/grafx2/trusty

« back to all changes in this revision

Viewing changes to keyboard.h

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2009-09-21 14:24:19 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921142419-lhpqq102buior0ol
Tags: 2.1-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  Grafx2 - The Ultimate 256-color bitmap paint program
2
 
 
3
 
    Copyright 2008 Yves Rizoud
4
 
    Copyright 2007 Adrien Destugues
5
 
    Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
6
 
 
7
 
    Grafx2 is free software; you can redistribute it and/or
8
 
    modify it under the terms of the GNU General Public License
9
 
    as published by the Free Software Foundation; version 2
10
 
    of the License.
11
 
 
12
 
    Grafx2 is distributed in the hope that it will be useful,
13
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
    GNU General Public License for more details.
16
 
 
17
 
    You should have received a copy of the GNU General Public License
18
 
    along with Grafx2; if not, see <http://www.gnu.org/licenses/>
19
 
*/
20
 
 
21
 
//////////////////////////////////////////////////////////////////////////////
22
 
///@file keyboard.h
23
 
/// Functions to convert bewteen the SDL key formats and the keycode we use
24
 
/// in grafx2.
25
 
/// The keycode we're using is generalized to handle mouse and joystick shortcuts
26
 
/// as well. The format can be broken down as:
27
 
/// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number.
28
 
/// - 0x0000 + SDLK_LAST+1: Mouse middle button.
29
 
/// - 0x0000 + SDLK_LAST+2: Mouse wheel up.
30
 
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
31
 
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
32
 
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
33
 
/// Add 0x1000 for the Shift modifier MOD_SHIFT
34
 
/// Add 0x2000 for the Control modifier ::MOD_CONTROL
35
 
/// Add 0x4000 for the Alt modifier ::MOD_ALT
36
 
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
37
 
//////////////////////////////////////////////////////////////////////////////
38
 
 
39
 
/*!
40
 
  Convert an SDL keysym to an ANSI/ASCII character.
41
 
  This is used to type text and numeric values in input boxes.
42
 
  @param keysym SDL symbol to convert
43
 
*/
44
 
word Keysym_to_ANSI(SDL_keysym keysym);
45
 
 
46
 
/*!
47
 
  Convert an SDL keysym to an internal keycode number.
48
 
  This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
49
 
  We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
50
 
  See the notice at the beginning of keyboard.h for the format of a keycode.
51
 
  @param keysym SDL symbol to convert
52
 
*/
53
 
word Keysym_to_keycode(SDL_keysym keysym);
54
 
 
55
 
/*!
56
 
    Helper function to convert between SDL system and the old coding for PC keycodes.
57
 
    This is only used to convert configuration files from the DOS version of 
58
 
    Grafx2, where keyboard codes are in in the IBM PC AT form.
59
 
  @param scancode Scancode to convert
60
 
*/
61
 
word Key_for_scancode(word scancode);
62
 
 
63
 
/*!
64
 
    Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
65
 
  @param Key keycode of the key to translate, including modifiers
66
 
*/
67
 
const char * Key_name(word Key);
68
 
 
69
 
/*!
70
 
  Gets the modifiers in our format from the SDL_Mod information.
71
 
  Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL
72
 
  @param mod SDL modifiers state
73
 
*/
74
 
word Key_modifiers(SDLMod mod);
75
 
 
 
1
/*  Grafx2 - The Ultimate 256-color bitmap paint program
 
2
 
 
3
    Copyright 2008 Yves Rizoud
 
4
    Copyright 2007 Adrien Destugues
 
5
    Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
 
6
 
 
7
    Grafx2 is free software; you can redistribute it and/or
 
8
    modify it under the terms of the GNU General Public License
 
9
    as published by the Free Software Foundation; version 2
 
10
    of the License.
 
11
 
 
12
    Grafx2 is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU General Public License
 
18
    along with Grafx2; if not, see <http://www.gnu.org/licenses/>
 
19
*/
 
20
 
 
21
//////////////////////////////////////////////////////////////////////////////
 
22
///@file keyboard.h
 
23
/// Functions to convert bewteen the SDL key formats and the keycode we use
 
24
/// in grafx2.
 
25
/// The keycode we're using is generalized to handle mouse and joystick shortcuts
 
26
/// as well. The format can be broken down as:
 
27
/// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number.
 
28
/// - 0x0000 + SDLK_LAST+1: Mouse middle button.
 
29
/// - 0x0000 + SDLK_LAST+2: Mouse wheel up.
 
30
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
 
31
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
 
32
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
 
33
/// Add 0x1000 for the Shift modifier MOD_SHIFT
 
34
/// Add 0x2000 for the Control modifier ::MOD_CONTROL
 
35
/// Add 0x4000 for the Alt modifier ::MOD_ALT
 
36
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
 
37
//////////////////////////////////////////////////////////////////////////////
 
38
 
 
39
/*!
 
40
  Convert an SDL keysym to an ANSI/ASCII character.
 
41
  This is used to type text and numeric values in input boxes.
 
42
  @param keysym SDL symbol to convert
 
43
*/
 
44
word Keysym_to_ANSI(SDL_keysym keysym);
 
45
 
 
46
/*!
 
47
  Convert an SDL keysym to an internal keycode number.
 
48
  This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
 
49
  We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
 
50
  See the notice at the beginning of keyboard.h for the format of a keycode.
 
51
  @param keysym SDL symbol to convert
 
52
*/
 
53
word Keysym_to_keycode(SDL_keysym keysym);
 
54
 
 
55
/*!
 
56
    Helper function to convert between SDL system and the old coding for PC keycodes.
 
57
    This is only used to convert configuration files from the DOS version of 
 
58
    Grafx2, where keyboard codes are in in the IBM PC AT form.
 
59
  @param scancode Scancode to convert
 
60
*/
 
61
word Key_for_scancode(word scancode);
 
62
 
 
63
/*!
 
64
    Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
 
65
  @param Key keycode of the key to translate, including modifiers
 
66
*/
 
67
const char * Key_name(word Key);
 
68
 
 
69
/*!
 
70
  Gets the modifiers in our format from the SDL_Mod information.
 
71
  Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL
 
72
  @param mod SDL modifiers state
 
73
*/
 
74
word Key_modifiers(SDLMod mod);
 
75