initial move to namespaces
This commit is contained in:
parent
bcdbdd4fb0
commit
93944aa85a
@ -1,5 +1,5 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
_SDL = ctypes.cdll.LoadLibrary('/usr/local/lib/libSDL-1.3.so.0.0.0')
|
from .internal import _SDL
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
class INIT(object):
|
class INIT(object):
|
||||||
@ -107,10 +107,11 @@ class Version(ctypes.Structure):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{0}.{1}.{2}'.format(self.major,
|
return '{0}.{1}.{2}'.format(self.major, self.minor, self.patch)
|
||||||
self.minor,
|
|
||||||
self.patch)
|
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Version({0},{1},{2})'.format(self.major, self.minor,
|
||||||
|
self.patch)
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
v = Version()
|
v = Version()
|
||||||
@ -124,55 +125,6 @@ def get_revision():
|
|||||||
|
|
||||||
#### System Information
|
#### System Information
|
||||||
|
|
||||||
_SDL.SDL_GetPlatform.restype = ctypes.c_char_p
|
|
||||||
def get_platform():
|
|
||||||
return _SDL.SDL_GetPlatform()
|
|
||||||
|
|
||||||
def get_cpu_cache_line_size():
|
|
||||||
return _SDL.SDL_GetCPUCacheLineSize()
|
|
||||||
|
|
||||||
def get_cpu_count():
|
|
||||||
return _SDL.SDL_GetCPUCount()
|
|
||||||
|
|
||||||
def has_3DNow():
|
|
||||||
return _SDL.SDL_Has3DNow() == 1
|
|
||||||
|
|
||||||
def has_AltiVec():
|
|
||||||
return _SDL.SDL_HasAltiVec() == 1
|
|
||||||
|
|
||||||
def has_MMX():
|
|
||||||
return _SDL.SDL_HasMMX() == 1
|
|
||||||
|
|
||||||
def has_RDTSC():
|
|
||||||
return _SDL.SDL_HasRDTSC() == 1
|
|
||||||
|
|
||||||
def has_SSE():
|
|
||||||
return _SDL.SDL_HasSSE() == 1
|
|
||||||
|
|
||||||
def has_SSE2():
|
|
||||||
return _SDL.SDL_HasSSE2() == 1
|
|
||||||
|
|
||||||
def has_SSE3():
|
|
||||||
return _SDL.SDL_HasSSE3() == 1
|
|
||||||
|
|
||||||
def has_SSE41():
|
|
||||||
return _SDL.SDL_HasSSE3() == 1
|
|
||||||
|
|
||||||
def has_SSE42():
|
|
||||||
return _SDL.SDL_HasSSE42() == 1
|
|
||||||
|
|
||||||
def get_power_info():
|
|
||||||
seconds = ctypes.c_int()
|
|
||||||
percent = ctypes.c_int()
|
|
||||||
state = _SDL.SDL_GetPowerInfo(ctypes.byref(seconds),
|
|
||||||
ctypes.byref(percent))
|
|
||||||
state = {0: 'UNKNOWN', 1: 'ON_BATTERY', 2: 'NO_BATTERY', 3: 'CHARGING',
|
|
||||||
4: 'CHARGED'}[state]
|
|
||||||
return state, seconds.value, percent.value
|
|
||||||
|
|
||||||
|
|
||||||
#### video
|
|
||||||
|
|
||||||
class DisplayMode(ctypes.Structure):
|
class DisplayMode(ctypes.Structure):
|
||||||
_fields_ = (
|
_fields_ = (
|
||||||
('format', ctypes.c_uint32),
|
('format', ctypes.c_uint32),
|
||||||
@ -487,6 +439,9 @@ class Point(ctypes.Structure):
|
|||||||
('y', ctypes.c_int),
|
('y', ctypes.c_int),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Point({0}, {1})'.format(self.x, self.y)
|
||||||
|
|
||||||
def get_display_bounds(display_index):
|
def get_display_bounds(display_index):
|
||||||
rect = Rect()
|
rect = Rect()
|
||||||
errcheck(_SDL.SDL_GetDisplayBounds(display_index, ctypes.byref(rect)))
|
errcheck(_SDL.SDL_GetDisplayBounds(display_index, ctypes.byref(rect)))
|
||||||
|
2
csdl/internal.py
Normal file
2
csdl/internal.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import ctypes
|
||||||
|
_SDL = ctypes.cdll.LoadLibrary('/usr/local/lib/libSDL-1.3.so.0.0.0')
|
48
csdl/sysinfo.py
Normal file
48
csdl/sysinfo.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
_SDL.SDL_GetPlatform.restype = ctypes.c_char_p
|
||||||
|
|
||||||
|
def get_platform():
|
||||||
|
return _SDL.SDL_GetPlatform()
|
||||||
|
|
||||||
|
def get_cpu_cache_line_size():
|
||||||
|
return _SDL.SDL_GetCPUCacheLineSize()
|
||||||
|
|
||||||
|
def get_cpu_count():
|
||||||
|
return _SDL.SDL_GetCPUCount()
|
||||||
|
|
||||||
|
def has_3DNow():
|
||||||
|
return _SDL.SDL_Has3DNow() == 1
|
||||||
|
|
||||||
|
def has_AltiVec():
|
||||||
|
return _SDL.SDL_HasAltiVec() == 1
|
||||||
|
|
||||||
|
def has_MMX():
|
||||||
|
return _SDL.SDL_HasMMX() == 1
|
||||||
|
|
||||||
|
def has_RDTSC():
|
||||||
|
return _SDL.SDL_HasRDTSC() == 1
|
||||||
|
|
||||||
|
def has_SSE():
|
||||||
|
return _SDL.SDL_HasSSE() == 1
|
||||||
|
|
||||||
|
def has_SSE2():
|
||||||
|
return _SDL.SDL_HasSSE2() == 1
|
||||||
|
|
||||||
|
def has_SSE3():
|
||||||
|
return _SDL.SDL_HasSSE3() == 1
|
||||||
|
|
||||||
|
def has_SSE41():
|
||||||
|
return _SDL.SDL_HasSSE3() == 1
|
||||||
|
|
||||||
|
def has_SSE42():
|
||||||
|
return _SDL.SDL_HasSSE42() == 1
|
||||||
|
|
||||||
|
def get_power_info():
|
||||||
|
seconds = ctypes.c_int()
|
||||||
|
percent = ctypes.c_int()
|
||||||
|
state = _SDL.SDL_GetPowerInfo(ctypes.byref(seconds),
|
||||||
|
ctypes.byref(percent))
|
||||||
|
state = {0: 'UNKNOWN', 1: 'ON_BATTERY', 2: 'NO_BATTERY', 3: 'CHARGING',
|
||||||
|
4: 'CHARGED'}[state]
|
||||||
|
return state, seconds.value, percent.value
|
||||||
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
from csdl import init, Window, SDL_INIT_EVERYTHING, Rect
|
from csdl import init, Window, INIT, Rect
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
init(SDL_INIT_EVERYTHING)
|
init(INIT.EVERYTHING)
|
||||||
window = Window('test', 100, 100, 512, 512, 0)
|
window = Window('test', 100, 100, 512, 512, 0)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from csdl import init, Window, SDL_INIT_EVERYTHING
|
from csdl import init, Window, INIT
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
init(SDL_INIT_EVERYTHING)
|
init(INIT.EVERYTHING)
|
||||||
window = Window('test', 100, 100, 512, 512, 0)
|
window = Window('test', 100, 100, 512, 512, 0)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user