aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-18 11:36:35 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-18 11:36:35 -0700
commit705f29464e34738718a6278f08e71b7c21ee996e (patch)
tree6f8f105a7ae2e0e829c02116c59c9b18deaa1091
parent5abf3660a6a4c111b5a858b1deb1a1aaa27461a6 (diff)
parent450f1578683e85719c77ef1b3df42ae2ae05ca33 (diff)
Merge pull request #2241 from Noxalus/incoming
Complete the list of properly supported keys
-rw-r--r--src/library_sdl.js198
1 files changed, 122 insertions, 76 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 2606bafc..3d96a693 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -83,27 +83,27 @@ var LibrarySDL = {
DOMEventToSDLEvent: {},
keyCodes: { // DOM code ==> SDL code. See https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/KeyboardEvent and SDL_keycode.h
+ // For keys that don't have unicode value, we map DOM codes with the corresponding scan codes + 1024 (using "| 1 << 10")
+ 16: 225 | 1<<10, // shift
+ 17: 224 | 1<<10, // control (right, or left)
+ 18: 226 | 1<<10, // alt
+ 20: 57 | 1<<10, // caps lock
+
+ 33: 75 | 1<<10, // pagedup
+ 34: 78 | 1<<10, // pagedown
+ 35: 77 | 1<<10, // end
+ 36: 74 | 1<<10, // home
+ 37: 80 | 1<<10, // left arrow
+ 38: 82 | 1<<10, // up arrow
+ 39: 79 | 1<<10, // right arrow
+ 40: 81 | 1<<10, // down arrow
+ 44: 316, // print screen
+ 45: 73 | 1<<10, // insert
46: 127, // SDLK_DEL == '\177'
- 38: 1106, // up arrow
- 40: 1105, // down arrow
- 37: 1104, // left arrow
- 39: 1103, // right arrow
-
- 33: 1099, // pagedup
- 34: 1102, // pagedown
-
- 35: 1101, // end
- 36: 1098, // home
- 45: 1097, // insert
-
- 17: 1248, // control (right, or left)
- 18: 1250, // alt
- 173: 45, // minus
- 16: 1249, // shift
+ 91: 227 | 1<<10, // windows key or super key on linux (doesn't work on Mac)
+ 93: 101 | 1<<10, // application
- 20: 301, // caps lock
-
96: 98 | 1<<10, // keypad 0
97: 89 | 1<<10, // keypad 1
98: 90 | 1<<10, // keypad 2
@@ -114,16 +114,11 @@ var LibrarySDL = {
103: 95 | 1<<10, // keypad 7
104: 96 | 1<<10, // keypad 8
105: 97 | 1<<10, // keypad 9
-
106: 85 | 1<<10, // keypad multiply
107: 87 | 1<<10, // keypad plus
- 109: 86 | 1<<10, // keypad minus
- 111: 84 | 1<<10, // keypad divide
-
+ 109: 86 | 1<<10, // keypad minus
110: 99 | 1<<10, // keypad decimal point
-
- 144: 83 | 1<<10, // keypad num lock
-
+ 111: 84 | 1<<10, // keypad divide
112: 58 | 1<<10, // F1
113: 59 | 1<<10, // F2
114: 60 | 1<<10, // F3
@@ -135,70 +130,121 @@ var LibrarySDL = {
120: 66 | 1<<10, // F9
121: 67 | 1<<10, // F10
122: 68 | 1<<10, // F11
- 123: 69 | 1<<10, // F12
+ 123: 69 | 1<<10, // F12
+ 124: 104 | 1<<10, // F13
+ 125: 105 | 1<<10, // F14
+ 126: 106 | 1<<10, // F15
+ 127: 107 | 1<<10, // F16
+ 128: 108 | 1<<10, // F17
+ 129: 109 | 1<<10, // F18
+ 130: 110 | 1<<10, // F19
+ 131: 111 | 1<<10, // F20
+ 132: 112 | 1<<10, // F21
+ 133: 113 | 1<<10, // F22
+ 134: 114 | 1<<10, // F23
+ 135: 115 | 1<<10, // F24
+ 144: 83 | 1<<10, // keypad num lock
+
+ 160: 94, // caret
+ 161: 33, // exclaim
+ 162: 34, // double quote
+ 163: 35, // hash
+ 164: 36, // dollar
+ 165: 37, // percent
+ 166: 38, // ampersand
+ 167: 95, // underscore
+ 168: 40, // open parenthesis
+ 169: 41, // close parenthesis
+ 170: 42, // asterix
+ 171: 43, // plus
+ 172: 124, // pipe
+ 173: 45, // minus
+ 174: 123, // open curly bracket
+ 175: 125, // close curly bracket
+ 176: 126, // tilde
+
+ 181: 127, // audio mute
+ 182: 129, // audio volume down
+ 183: 128, // audio volume up
+
188: 44, // comma
190: 46, // period
191: 47, // slash (/)
192: 96, // backtick/backquote (`)
+ 219: 91, // open square bracket
+ 220: 92, // back slash
+ 221: 93, // close square bracket
+ 222: 39, // quote
},
scanCodes: { // SDL keycode ==> SDL scancode. See SDL_scancode.h
+ 8: 42, // backspace
+ 9: 43, // tab
+ 13: 40, // return
+ 27: 41, // escape
+ 32: 44, // space
+ 35: 204, // hash
+
+ 39: 53, // grave
+
+ 44: 54, // comma
+ 46: 55, // period
+ 47: 56, // slash
+ 48: 39, // 0
+ 49: 30, // 1
+ 50: 31, // 2
+ 51: 32, // 3
+ 52: 33, // 4
+ 53: 34, // 5
+ 54: 35, // 6
+ 55: 36, // 7
+ 56: 37, // 8
+ 57: 38, // 9
+ 58: 203, // colon
+ 59: 51, // semicolon
+
+ 61: 46, // equals
+
+ 91: 47, // left bracket
+ 92: 49, // backslash
+ 93: 48, // right bracket
+
+ 96: 52, // apostrophe
97: 4, // A
- 98: 5,
- 99: 6,
- 100: 7,
- 101: 8,
- 102: 9,
- 103: 10,
- 104: 11,
- 105: 12,
- 106: 13,
- 107: 14,
- 108: 15,
- 109: 16,
- 110: 17,
- 111: 18,
- 112: 19,
- 113: 20,
- 114: 21,
- 115: 22,
- 116: 23,
- 117: 24,
- 118: 25,
- 119: 26,
- 120: 27,
- 121: 28,
+ 98: 5, // B
+ 99: 6, // C
+ 100: 7, // D
+ 101: 8, // E
+ 102: 9, // F
+ 103: 10, // G
+ 104: 11, // H
+ 105: 12, // I
+ 106: 13, // J
+ 107: 14, // K
+ 108: 15, // L
+ 109: 16, // M
+ 110: 17, // N
+ 111: 18, // O
+ 112: 19, // P
+ 113: 20, // Q
+ 114: 21, // R
+ 115: 22, // S
+ 116: 23, // T
+ 117: 24, // U
+ 118: 25, // V
+ 119: 26, // W
+ 120: 27, // X
+ 121: 28, // Y
122: 29, // Z
- 49: 30, // 1
- 50: 31,
- 51: 32,
- 52: 33,
- 53: 34,
- 54: 35,
- 55: 36,
- 56: 37,
- 57: 38, // 9
- 48: 39, // 0
- 13: 40, // return
- 27: 41, // escape
- 8: 42, // backspace
- 9: 43, // tab
- 301: 57, // caps lock
- 32: 44, // space
- 61: 46, // equals
- 91: 47, // left bracket
- 93: 48, // right bracket
- 92: 49, // backslash
- 96: 43, // grave
- 59: 51, // ;
- 96: 52, // apostrophe
- 44: 54, // comma
- 46: 55, // period
- 47: 56, // slash
+
127: 76, // delete
+
305: 224, // ctrl
+
308: 226, // alt
+
+ 316: 70, // print screen
},
loadRect: function(rect) {
return {