1
/* Grafx2 - The Ultimate 256-color bitmap paint program
3
Copyright 2008 Yves Rizoud
4
Copyright 2007 Adrien Destugues
5
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
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
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.
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/>
21
//////////////////////////////////////////////////////////////////////////////
23
/// Functions to convert bewteen the SDL key formats and the keycode we use
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
//////////////////////////////////////////////////////////////////////////////
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
44
word Keysym_to_ANSI(SDL_keysym keysym);
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
53
word Keysym_to_keycode(SDL_keysym keysym);
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
61
word Key_for_scancode(word scancode);
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
67
const char * Key_name(word Key);
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
74
word Key_modifiers(SDLMod mod);
1
/* Grafx2 - The Ultimate 256-color bitmap paint program
3
Copyright 2008 Yves Rizoud
4
Copyright 2007 Adrien Destugues
5
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
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
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.
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/>
21
//////////////////////////////////////////////////////////////////////////////
23
/// Functions to convert bewteen the SDL key formats and the keycode we use
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
//////////////////////////////////////////////////////////////////////////////
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
44
word Keysym_to_ANSI(SDL_keysym keysym);
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
53
word Keysym_to_keycode(SDL_keysym keysym);
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
61
word Key_for_scancode(word scancode);
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
67
const char * Key_name(word Key);
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
74
word Key_modifiers(SDLMod mod);