Beispiel #1
0
    def test_SDL_Keysym(self):
        keysym = keyboard.SDL_Keysym()
        self.assertEqual(keysym.scancode, 0)
        self.assertEqual(keysym.sym, 0)
        self.assertEqual(keysym.mod, 0)

        keysym = keyboard.SDL_Keysym(1, 2, 3, ord("b"))
        self.assertEqual(keysym.scancode, 1)
        self.assertEqual(keysym.sym, 2)
        self.assertEqual(keysym.mod, 3)

        uval = "\u0220"
        if sys.version_info[0] < 3:
            uval = unichr(8224)
        keysym = keyboard.SDL_Keysym(17, 32, 88, ord(uval))
        self.assertEqual(keysym.scancode, 17)
        self.assertEqual(keysym.sym, 32)
        self.assertEqual(keysym.mod, 88)
Beispiel #2
0
    def test_SDL_Keysym(self):
        keysym = keyboard.SDL_Keysym()
        assert keysym.scancode == 0
        assert keysym.sym == 0
        assert keysym.mod == 0

        keysym = keyboard.SDL_Keysym(1, 2, 3, ord("b"))
        assert keysym.scancode == 1
        assert keysym.sym == 2
        assert keysym.mod == 3

        uval = "\u0220"
        if sys.version_info[0] < 3:
            uval = unichr(8224)
        keysym = keyboard.SDL_Keysym(17, 32, 88, ord(uval))
        assert keysym.scancode == 17
        assert keysym.sym == 32
        assert keysym.mod == 88
Beispiel #3
0
import time
import sdl2.ext
from sdl2 import joystick, keyboard
import time

sdl2.SDL_Quit(sdl2.SDL_INIT_JOYSTICK)
sdl2.SDL_Init(sdl2.SDL_INIT_JOYSTICK, sdl2.SDL_INIT_VIDEO)
# sdl2.SDL_QuitSubSystem(sdl2.SDL_INIT_VIDEO)
#  初始化
num = sdl2.joystick.SDL_NumJoysticks()
keysym = keyboard.SDL_Keysym()
# window = keyboard.SDL_GetKeyboardFocus()
print(keysym)
# keysym1 = keyboard.SDL_Keysym(1, 2, 3, ord("b"))
# print(keysym1.scancode)
# print(num)
joystick1 = sdl2.SDL_JoystickOpen(0)
# print(joystick1)
# joystick.SDL_JoystickClose(joystick1)
axes = joystick.SDL_JoystickNumAxes(joystick1)
print('axis={}'.format(axes))
balls = joystick.SDL_JoystickNumBalls(joystick1)
print('balls={}'.format(balls))
hats = joystick.SDL_JoystickNumHats(joystick1)
print('hats={}'.format(hats))
buttons = joystick.SDL_JoystickNumButtons(joystick1)
print('buttons={}'.format(buttons))
window = sdl2.ext.Window('Test', size=(640, 480))
window.show()

key_states = sdl2.SDL_GetKeyboardState(None)