Skip to content

Commit

Permalink
[SDL1] Add implementation of SDL_GetScancodeFromKey (#18060)
Browse files Browse the repository at this point in the history
Fixes: #17711
  • Loading branch information
mooosh-milllie authored Oct 17, 2022
1 parent 0c564ef commit 03ccf3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3711,7 +3711,9 @@ var LibrarySDL = {
SDL_GetCurrentAudioDriver: function() {
return allocateUTF8('Emscripten Audio');
},

SDL_GetScancodeFromKey: function (key) {
return SDL.scanCodes[key];
},
SDL_GetAudioDriver__deps: ['SDL_GetCurrentAudioDriver'],
SDL_GetAudioDriver: function(index) { return _SDL_GetCurrentAudioDriver() },

Expand Down
12 changes: 12 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,18 @@ def test_sdl_endianness(self):
self.run_process([EMXX, 'main.cpp'])
self.assertContained('1234, 1234, 4321\n', self.run_js('a.out.js'))

def test_sdl_scan_code_from_key(self):
create_file('main.cpp', r'''
#include <stdio.h>
#include <SDL/SDL_keyboard.h>
int main() {
printf("%d\n", SDL_GetScancodeFromKey(35));
return 0;
}
''')
self.do_runf('main.cpp', '204\n')

def test_sdl2_mixer_wav(self):
self.emcc(test_file('browser/test_sdl2_mixer_wav.c'), ['-sUSE_SDL_MIXER=2'], output_filename='a.out.js')

Expand Down

0 comments on commit 03ccf3a

Please sign in to comment.