Skip to content

Commit

Permalink
Make KeyCode enum available for SDL2 < 2.0.12 (#2)
Browse files Browse the repository at this point in the history
* Make KeyCode enum available for SDL2 < 2.0.12

* Define SDL_KeyCode as int
  • Loading branch information
ctreffs authored May 5, 2021
1 parent c3debd3 commit 886e655
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/CSDL2/shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@
#else
#include "other_platforms.h"
#endif



// SDL_KeyCode was introduced with 2.0.12
// <https://github.com/libsdl-org/SDL/blob/release-2.0.12/include/SDL_keycode.h#L320>
#if SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL <= 12
typedef int SDL_KeyCode;
#endif
3 changes: 3 additions & 0 deletions Sources/SDL2/SDL2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
//

@_exported import CSDL2

extension SDL_KeyCode: Equatable {}
extension SDL_KeyCode: Hashable {}
4 changes: 4 additions & 0 deletions Tests/CSDL2Tests/CSDL2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ final class CSDL2Tests: XCTestCase {
XCTAssertEqual(linked.major, 2)
XCTAssertEqual(linked.minor, 0)
}

func testKeyCodeAvailability() {
XCTAssertNotNil(SDL_KeyCode.self)
}
}

0 comments on commit 886e655

Please sign in to comment.