Browse Source

Trying callbacks but they are hard to implement.

Beoran 11 years ago
parent
commit
1b38c61352
6 changed files with 1226 additions and 0 deletions
  1. 222 0
      src/algo/al/bitmap.go
  2. 15 0
      src/algo/al/callbacks.go
  3. 460 0
      src/algo/al/display.go
  4. 225 0
      src/algo/al/joystick.go
  5. 215 0
      src/algo/al/keyboard.go
  6. 89 0
      src/algo/al/mouse.go

+ 222 - 0
src/algo/al/bitmap.go

@@ -0,0 +1,222 @@
+// albitmap
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+
+
+
+*/
+import "C"
+
+import "runtime"
+import "unsafe"
+
+// #include "_cgo_export.h"  doesn't work
+
+// Type that wraps a Bitmap
+type Bitmap struct {
+	handle *C.ALLEGRO_BITMAP
+}
+
+// Destroys a bitmap. Use this only when really needed!
+func (self *Bitmap) Destroy() {
+	if self.handle != nil {
+		C.al_destroy_bitmap(self.handle)
+	}
+	self.handle = nil
+}
+
+// Wraps a C Allegro bitmap in a Bitmap. Sets no finalizer.
+func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
+	if handle == nil {
+		return nil
+	}
+	return &Bitmap{handle}
+}
+
+// Wraps a C Allegro Bitmap in a Bitmap. Sets a finalizer that calls Destroy.
+func wrapBitmap(handle *C.ALLEGRO_BITMAP) *Bitmap {
+	self := wrapBitmapRaw(handle)
+	if self != nil {
+		runtime.SetFinalizer(self, func(me *Bitmap) { me.Destroy() })
+	}
+	return self
+}
+
+const (
+	MEMORY_BITMAP       = C.ALLEGRO_MEMORY_BITMAP
+	FORCE_LOCKING       = C.ALLEGRO_FORCE_LOCKING
+	NO_PRESERVE_TEXTURE = C.ALLEGRO_NO_PRESERVE_TEXTURE
+	MIN_LINEAR          = C.ALLEGRO_MIN_LINEAR
+	MAG_LINEAR          = C.ALLEGRO_MAG_LINEAR
+	MIPMAP              = C.ALLEGRO_MIPMAP
+	VIDEO_BITMAP        = C.ALLEGRO_VIDEO_BITMAP
+	CONVERT_BITMAP      = C.ALLEGRO_CONVERT_BITMAP
+)
+
+// Sets the format for new bitmaps that are created using CreateBitmap
+func SetNewBitmapFormat(format int) {
+	C.al_set_new_bitmap_format(C.int(format))
+}
+
+// Sets the flags for new bitmaps that are created using CreateBitmap
+func SetNewBitmapFlags(flags int) {
+	C.al_set_new_bitmap_flags(C.int(flags))
+}
+
+// Adds a flags to the flags that will be used for new bitmaps that are created 
+// using CreateBitmap
+func AddNewBitmapFlag(flags int) {
+	C.al_add_new_bitmap_flag(C.int(flags))
+}
+
+// Gets the format for new bitmaps that are created using CreateBitmap
+func NewBitmapFormat(format int) int {
+	return int(C.al_get_new_bitmap_format())
+}
+
+// Gets the flags for new bitmaps that are created using CreateBitmap
+func NewBitmapFlags(flags int) int {
+	return int(C.al_get_new_bitmap_flags())
+}
+
+// Gets the width of the bitmap.
+func (self *Bitmap) Width() int {
+	return int(C.al_get_bitmap_width(self.handle))
+}
+
+// Gets the height of the bitmap.
+func (self *Bitmap) Height() int {
+	return int(C.al_get_bitmap_height(self.handle))
+}
+
+// Gets the format of the bitmap.
+func (self *Bitmap) Format() int {
+	return int(C.al_get_bitmap_format(self.handle))
+}
+
+// Gets the flags of the bitmap.
+func (self *Bitmap) Flags() int {
+	return int(C.al_get_bitmap_flags(self.handle))
+}
+
+// Creates a new RAW bitmap. It will not be automatically destroyed!
+func CreateBitmapRaw(w, h int) *Bitmap {
+	return wrapBitmapRaw(C.al_create_bitmap(C.int(w), C.int(h)))
+}
+
+// Creates a new bitmap. It has a finalizer in place that will let it be automatically 
+// destroyed.
+func CreateBitmap(w, h int) *Bitmap {
+	return wrapBitmap(C.al_create_bitmap(C.int(w), C.int(h)))
+}
+
+/* TODO:
+AL_FUNC(ALLEGRO_BITMAP*, al_create_custom_bitmap, (int w, int h, bool (*upload)(ALLEGRO_BITMAP *bitmap, void *data), void *data));
+*/
+
+type UploadBitmapC func(bitmap C.ALLEGRO_BITMAP, data unsafe.Pointer) C.bool
+
+type UploadBitmapFunction func(bitmap *Bitmap, data unsafe.Pointer) bool
+
+func (upload *UploadBitmapFunction) toC() UploadBitmapC {
+	//    res := func
+	return nil
+}
+
+func CreateCustomBitmapRaw(w, h int, upload UploadBitmapFunction, data unsafe.Pointer) *Bitmap {
+	fn := (*C.go_upload_bitmap_function)(unsafe.Pointer(C.go_upload_bitmap_cb))
+	return wrapBitmapRaw(C.al_create_custom_bitmap(C.int(w), C.int(h), fn, data))
+}
+
+// Puts a pixel to the currently active bitmap
+func PutPixel(x, y int, color Color) {
+	C.al_put_pixel(C.int(x), C.int(y), color.toC())
+}
+
+// Blends a pixel to the currently active bitmap
+func PutBlendedPixel(x, y int, color Color) {
+	C.al_put_blended_pixel(C.int(x), C.int(y), color.toC())
+}
+
+// Gets a pixel from the bitmap
+func (self *Bitmap) GetPixel(x, y int) (color Color) {
+	return wrapColor(C.al_get_pixel(self.handle, C.int(x), C.int(y)))
+}
+
+// Converts pixels of the mask color to transparent pixels (with an alpha channel) 
+// for the given bitmap. Useful for, say "magic pink" backgrounds.
+func (self *Bitmap) ConvertMaskToAlpha(mask_color Color) {
+	C.al_convert_mask_to_alpha(self.handle, mask_color.toC())
+}
+
+// Sets the clipping rectangle for the currently active bitmap. Anything drawn outside
+// this rectangle will be cut off or "clipped".
+func SetClippingRectangle(x, y, w, h int) {
+	C.al_set_clipping_rectangle(C.int(x), C.int(y), C.int(w), C.int(h))
+}
+
+// Resets the clipping rectangle for the currently active bitmap to the full size. 
+func ResetClippingRectangle() {
+	C.al_reset_clipping_rectangle()
+}
+
+// Gets the clipping rectangle for the currently active bitmap. 
+func ClippingRectangle() (x, y, w, h int) {
+	var cx, cy, cw, ch C.int
+	C.al_get_clipping_rectangle(&cx, &cy, &cw, &ch)
+	return int(cx), int(cy), int(cw), int(ch)
+}
+
+// Creates a RAW sub bitmap of the given bitmap that must be manually destoyed with 
+// Destroy() 
+func (self *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
+	return wrapBitmapRaw(C.al_create_sub_bitmap(self.handle,
+		C.int(x), C.int(y), C.int(w), C.int(h)))
+}
+
+// Creates a sub bitmap of the given bitmap that will automatically be destoyed
+// through a finalizer. However, you must ensure that this destroy happens before the 
+// parent bitmap is disposed of. You may need to call Destroy manyally anyway. 
+func (self *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
+	return wrapBitmap(C.al_create_sub_bitmap(self.handle,
+		C.int(x), C.int(y), C.int(w), C.int(h)))
+}
+
+// Returns whether or not the bitmap is a sub bitmap 
+func (self *Bitmap) IsSubBitmap() bool {
+	return cb2b(C.al_is_sub_bitmap(self.handle))
+}
+
+// Returns the parent bitmap of this sub bitmap, or nil if there is no parent. 
+// This is a raw bitmap that has no finaliser set on it since likely 
+/// this function will only be used for inspection.
+func (self *Bitmap) Parent() *Bitmap {
+	return wrapBitmapRaw(C.al_get_parent_bitmap(self.handle))
+}
+
+// Returns a raw clone of the bitmap, that will not be automatically 
+// destroyed.
+func (self *Bitmap) CloneRaw() *Bitmap {
+	return wrapBitmapRaw(C.al_clone_bitmap(self.handle))
+}
+
+// Returns a clone of the bitmap, that will automatically be
+// destroyed.
+func (self *Bitmap) Clone() *Bitmap {
+	return wrapBitmap(C.al_clone_bitmap(self.handle))
+}
+
+// Converts the bitmap to the current screen format, to ensure the blitting goes fast
+func (self *Bitmap) Convert() {
+	C.al_convert_bitmap(self.handle)
+}
+
+// Converts all known unconverted bitmaps to the current screen format, 
+// to ensure the blitting goes fast. 
+func ConvertBitmaps() {
+	C.al_convert_bitmaps()
+}

+ 15 - 0
src/algo/al/callbacks.go

@@ -0,0 +1,15 @@
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+*/
+import "C"
+
+import "unsafe"
+
+//export go_upload_bitmap
+func go_upload_bitmap(bitmap unsafe.Pointer, data unsafe.Pointer) C.bool {
+	return false
+}

+ 460 - 0
src/algo/al/display.go

@@ -0,0 +1,460 @@
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+*/
+import "C"
+
+import "runtime"
+
+// Usful regexp for KATE:  ALLEGRO_([A-Z0-9_]+)(.*) -> \1 = C.ALLEGRO_\1
+
+// Display functions.
+
+// Possible bit combinations for the flags parameter of CreateDisplay.
+const (
+	WINDOWED                  = C.ALLEGRO_WINDOWED
+	FULLSCREEN                = C.ALLEGRO_FULLSCREEN
+	OPENGL                    = C.ALLEGRO_OPENGL
+	DIRECT3D_INTERNAL         = C.ALLEGRO_DIRECT3D_INTERNAL
+	RESIZABLE                 = C.ALLEGRO_RESIZABLE
+	FRAMELESS                 = C.ALLEGRO_FRAMELESS
+	NOFRAME                   = C.ALLEGRO_NOFRAME
+	GENERATE_EXPOSE_EVENTS    = C.ALLEGRO_GENERATE_EXPOSE_EVENTS
+	OPENGL_3_0                = C.ALLEGRO_OPENGL_3_0
+	OPENGL_FORWARD_COMPATIBLE = C.ALLEGRO_OPENGL_FORWARD_COMPATIBLE
+	FULLSCREEN_WINDOW         = C.ALLEGRO_FULLSCREEN_WINDOW
+	MINIMIZED                 = C.ALLEGRO_MINIMIZED
+)
+
+/* Possible parameters for SetDisplayOption. */
+const (
+	RED_SIZE               = C.ALLEGRO_RED_SIZE
+	GREEN_SIZE             = C.ALLEGRO_GREEN_SIZE
+	BLUE_SIZE              = C.ALLEGRO_BLUE_SIZE
+	ALPHA_SIZE             = C.ALLEGRO_ALPHA_SIZE
+	RED_SHIFT              = C.ALLEGRO_RED_SHIFT
+	GREEN_SHIFT            = C.ALLEGRO_GREEN_SHIFT
+	BLUE_SHIFT             = C.ALLEGRO_BLUE_SHIFT
+	ALPHA_SHIFT            = C.ALLEGRO_ALPHA_SHIFT
+	ACC_RED_SIZE           = C.ALLEGRO_ACC_RED_SIZE
+	ACC_GREEN_SIZE         = C.ALLEGRO_ACC_GREEN_SIZE
+	ACC_BLUE_SIZE          = C.ALLEGRO_ACC_BLUE_SIZE
+	ACC_ALPHA_SIZE         = C.ALLEGRO_ACC_ALPHA_SIZE
+	STEREO                 = C.ALLEGRO_STEREO
+	AUX_BUFFERS            = C.ALLEGRO_AUX_BUFFERS
+	COLOR_SIZE             = C.ALLEGRO_COLOR_SIZE
+	DEPTH_SIZE             = C.ALLEGRO_DEPTH_SIZE
+	STENCIL_SIZE           = C.ALLEGRO_STENCIL_SIZE
+	SAMPLE_BUFFERS         = C.ALLEGRO_SAMPLE_BUFFERS
+	SAMPLES                = C.ALLEGRO_SAMPLES
+	RENDER_METHOD          = C.ALLEGRO_RENDER_METHOD
+	FLOAT_COLOR            = C.ALLEGRO_FLOAT_COLOR
+	FLOAT_DEPTH            = C.ALLEGRO_FLOAT_DEPTH
+	SINGLE_BUFFER          = C.ALLEGRO_SINGLE_BUFFER
+	SWAP_METHOD            = C.ALLEGRO_SWAP_METHOD
+	COMPATIBLE_DISPLAY     = C.ALLEGRO_COMPATIBLE_DISPLAY
+	UPDATE_DISPLAY_REGION  = C.ALLEGRO_UPDATE_DISPLAY_REGION
+	VSYNC                  = C.ALLEGRO_VSYNC
+	MAX_BITMAP_SIZE        = C.ALLEGRO_MAX_BITMAP_SIZE
+	SUPPORT_NPOT_BITMAP    = C.ALLEGRO_SUPPORT_NPOT_BITMAP
+	CAN_DRAW_INTO_BITMAP   = C.ALLEGRO_CAN_DRAW_INTO_BITMAP
+	SUPPORT_SEPARATE_ALPHA = C.ALLEGRO_SUPPORT_SEPARATE_ALPHA
+	DISPLAY_OPTIONS_COUNT  = C.ALLEGRO_DISPLAY_OPTIONS_COUNT
+)
+
+// Constants that determine if a setting is required or not.
+const (
+	DONTCARE = C.ALLEGRO_DONTCARE
+	REQUIRE  = C.ALLEGRO_REQUIRE
+	SUGGEST  = C.ALLEGRO_SUGGEST
+)
+
+// Display orientations
+const (
+	DISPLAY_ORIENTATION_0_DEGREES   = C.ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES
+	DISPLAY_ORIENTATION_90_DEGREES  = C.ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES
+	DISPLAY_ORIENTATION_180_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES
+	DISPLAY_ORIENTATION_270_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES
+	DISPLAY_ORIENTATION_FACE_UP     = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_UP
+	DISPLAY_ORIENTATION_FACE_DOWN   = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN
+)
+
+// Type that wraps a Display (a main window)
+type Display struct {
+	handle *C.ALLEGRO_DISPLAY
+}
+
+// Destroys a display. Use this only when really needed!
+func (self *Display) Destroy() {
+	if self.handle != nil {
+		C.al_destroy_display(self.handle)
+	}
+	self.handle = nil
+}
+
+// Wraps a C Allegro display in a Display. Sets no finalizer.
+func wrapDisplayRaw(handle *C.ALLEGRO_DISPLAY) *Display {
+	if handle == nil {
+		return nil
+	}
+	return &Display{handle}
+}
+
+// Wraps a C Allegro display in a Display. Sets a finalizer that calls Destroy
+func wrapDisplay(handle *C.ALLEGRO_DISPLAY) *Display {
+	self := wrapDisplayRaw(handle)
+	if self != nil {
+		runtime.SetFinalizer(self, func(me *Display) { me.Destroy() })
+	}
+	return self
+}
+
+// Display mode info.
+type DisplayMode C.ALLEGRO_DISPLAY_MODE
+
+// Converts display mode to C display mode 
+func (self *DisplayMode) toC() *C.ALLEGRO_DISPLAY_MODE {
+	return (*C.ALLEGRO_DISPLAY_MODE)(self)
+}
+
+// Returns the width of the display mode self.
+func (self *DisplayMode) Width() int {
+	return int(self.width)
+}
+
+// Returns the height of the display mode self.
+func (self *DisplayMode) Height() int {
+	return int(self.height)
+}
+
+// Returns the format of the display mode self.
+func (self *DisplayMode) Format() int {
+	return int(self.format)
+}
+
+// Returns the refresh rate of the display mode self.
+func (self *DisplayMode) RefreshRate() int {
+	return int(self.refresh_rate)
+}
+
+// Monitor info
+type MonitorInfo C.ALLEGRO_MONITOR_INFO
+
+// Returns the X1 of the monitor info self.
+func (self *MonitorInfo) X1() int {
+	return int(self.x1)
+}
+
+// Returns the Y1 of the monitor info self.
+func (self *MonitorInfo) Y1() int {
+	return int(self.y1)
+}
+
+// Returns the X2 of the monitor info self.
+func (self *MonitorInfo) X2() int {
+	return int(self.x2)
+}
+
+// Returns the Y2 of the monitor info self.
+func (self *MonitorInfo) Y2() int {
+	return int(self.y2)
+}
+
+const (
+	DEFAULT_DISPLAY_ADAPTER = C.ALLEGRO_DEFAULT_DISPLAY_ADAPTER
+)
+
+// Sets the flags that a display created by CreateDisplay will get after
+// this function was called.
+func SetNewDisplayFlags(flags int) {
+	C.al_set_new_display_flags(C.int(flags))
+}
+
+// Creates a new dosplay with the given size. Influenced by SetNewDisplayFlags.
+func CreateDisplay(width, height int) *Display {
+	return wrapDisplay(C.al_create_display(C.int(width), C.int(height)))
+}
+
+// Resizes the display.
+func (self *Display) Resize(width, height int) bool {
+	return bool(C.al_resize_display(self.handle, C.int(width), C.int(height)))
+}
+
+// Updates the display to the physical scree no any changes become visible
+func FlipDisplay() {
+	C.al_flip_display()
+}
+
+// Same as FlipDisplay, for mere consistency
+func (self *Display) Flip() {
+	C.al_flip_display()
+}
+
+// Color type
+type Color C.ALLEGRO_COLOR
+
+// Convert from
+func wrapColor(color C.ALLEGRO_COLOR) Color {
+	return Color(color)
+}
+
+// Convert to C
+func (self Color) toC() C.ALLEGRO_COLOR {
+	return C.ALLEGRO_COLOR(self)
+}
+
+// Creates a new color 
+func CreateColor(r, g, b, a float32) Color {
+	return Color{C.float(r), C.float(g), C.float(b), C.float(a)}
+}
+
+// Returns the R component of the color self.
+func (self Color) R() float32 {
+	return float32(self.r)
+}
+
+// Returns the G component of the color self.
+func (self Color) G() float32 {
+	return float32(self.g)
+}
+
+// Returns the B component of the color self.
+func (self Color) B() float32 {
+	return float32(self.b)
+}
+
+// Returns the A component of the color self.
+func (self Color) A() float32 {
+	return float32(self.a)
+}
+
+// Fills the current active display with a color
+func ClearToColor(color Color) {
+	C.al_clear_to_color(color.toC())
+}
+
+// Draws a pixel on the active display at the given location 
+// with the given color
+func DrawPixel(x, y float32, color Color) {
+	C.al_draw_pixel(C.float(x), C.float(y), C.ALLEGRO_COLOR(color))
+}
+
+// Sets the refresh rate that the display should have after CreateDisplay().
+func SetNewDisplayRefreshRate(refresh_rate int) {
+	C.al_set_new_display_refresh_rate(C.int(refresh_rate))
+}
+
+// Gets the refresh rate that the display should have after CreateDisplay().
+func NewDisplayRefreshRate() int {
+	return int(C.al_get_new_display_refresh_rate())
+}
+
+// Gets the display flags that the display should have after CreateDisplay().
+func NewDisplayFlags() int {
+	return int(C.al_get_new_display_flags())
+}
+
+// Gets the width of the display  in pixels
+func (self *Display) Width() int {
+	return int(C.al_get_display_width(self.handle))
+}
+
+// Gets the height of the display in pixels
+func (self *Display) Height() int {
+	return int(C.al_get_display_height(self.handle))
+}
+
+// Gets the refresh rate of the display
+func (self *Display) RefreshRate() int {
+	return int(C.al_get_display_refresh_rate(self.handle))
+}
+
+// Gets the display flags of the display
+func (self *Display) DisplayFlags() int {
+	return int(C.al_get_display_flags(self.handle))
+}
+
+// Sets a dispay flag on the display
+func (self *Display) SetDisplayFlag(flag int, onoff bool) bool {
+	return cb2b(C.al_set_display_flag(self.handle, C.int(flag), b2cb(onoff)))
+}
+
+// Returns the current display 
+func CurrentDisplay() *Display {
+	return wrapDisplayRaw(C.al_get_current_display())
+}
+
+// Sets the target C bitmap of allegro drawing 
+func setTargetCBitmap(bmp *C.ALLEGRO_BITMAP) {
+	C.al_set_target_bitmap(bmp)
+}
+
+// Sets the target bitmap of the allegro drawing
+func SetTargetBitmap(bmp Bitmap) {
+	setTargetCBitmap(bmp.handle)
+}
+
+// Sets the target C backbuffer of allegro drawing 
+func setTargetCBackbuffer(display *C.ALLEGRO_DISPLAY) {
+	C.al_set_target_backbuffer(display)
+}
+
+// Sets the target backbuffer of allegro drawing 
+func SetTargetBackbuffer(display *Display) {
+	setTargetCBackbuffer(display.handle)
+}
+
+// Gets the backbuffer bitmap of the display 
+func (self *Display) Backbuffer() *Bitmap {
+	return wrapBitmapRaw(C.al_get_backbuffer(self.handle))
+}
+
+// Gets the target bitmap of allegro drawing
+func TargetBitmap() *Bitmap {
+	return wrapBitmapRaw(C.al_get_target_bitmap())
+}
+
+// Must be called to aknowledge a RESIZE event
+func (self *Display) AcknowledgeResize() bool {
+	return cb2b(C.al_acknowledge_resize(self.handle))
+}
+
+// Updates a region of the display (not the whole display like flip does)
+func UpdateDisplayRegion(x, y, width, height int) {
+	C.al_update_display_region(C.int(x), C.int(y), C.int(width), C.int(height))
+}
+
+// Returns true of the bitmap is compatible with the currebt display, false if not. 
+func (bitmap *Bitmap) IsCompatibleBitmap() bool {
+	return cb2b(C.al_is_compatible_bitmap(bitmap.handle))
+}
+
+// Returns the number of display modes available to Allegro
+func NumDisplayModes() int {
+	return int(C.al_get_num_display_modes())
+}
+
+// Returns the index'th display mode. Pass in a DisplayMode struct to store the display
+// mode info in. 
+func (self *DisplayMode) Get(index int) *DisplayMode {
+	return (*DisplayMode)(C.al_get_display_mode(C.int(index), self.toC()))
+}
+
+// Gets display mode info for the index'th display mode
+func GetDisplayMode(index int) *DisplayMode {
+	var mode DisplayMode
+	if (&mode).Get(index) != nil {
+		return &mode
+	}
+	return nil
+}
+
+// Waits for the vertical retrace of the monitor to lessen tearing.
+func WaitForVsync() {
+	C.al_wait_for_vsync()
+}
+
+// Gets the event source of the display to registeron an event queue 
+// with RegisterEventSource.
+func (self *Display) GetEventSource() *EventSource {
+	return (*EventSource)(C.al_get_display_event_source(self.handle))
+}
+
+// Sets the display icon the window manager should use for the display window
+func (self *Display) SetDisplayIcon(bitmap *Bitmap) {
+	C.al_set_display_icon(self.handle, bitmap.handle)
+}
+
+// Gets the number of available video adapters (I.E. grapic cards)
+func NumVideoAdapters() int {
+	return int(C.al_get_num_video_adapters())
+}
+
+// Converts a monitor info pointer to a C  * ALLEGRO_MONITOR_INFO
+func (self *MonitorInfo) toC() *C.ALLEGRO_MONITOR_INFO {
+	return (*C.ALLEGRO_MONITOR_INFO)(self)
+}
+
+// Gets the monitor info for the index'th video adapter
+func (self *MonitorInfo) Get(index int) bool {
+	return cb2b(C.al_get_monitor_info(C.int(index), self.toC()))
+}
+
+// Gets the monitor info for the index'th video adapter
+func GetMonitorInfo(index int) *MonitorInfo {
+	var info MonitorInfo
+	if (&info).Get(index) {
+		return &info
+	}
+	return nil
+}
+
+// Returns the number of the display adapter where new dsplays will be created
+func NewDisplayAdapter() int {
+	return int(C.al_get_new_display_adapter())
+}
+
+// Sets the number of the display adapter where new dsplays will be created
+func SetNewDisplayAdapter(adapter int) {
+	C.al_set_new_display_adapter(C.int(adapter))
+}
+
+// Returns the position where new windowed displays will be created
+func NewWindowPosition() (x, y int) {
+	var cx, cy C.int
+	C.al_get_new_window_position(&cx, &cy)
+	return int(cx), int(cy)
+}
+
+// Sets the position where new windowed displays will be created
+func SetNewWindowPosition(x, y int) {
+	C.al_set_new_window_position(C.int(x), C.int(y))
+}
+
+// Returns the current position of the windowed display
+func (self *Display) WindowPosition() (x, y int) {
+	var cx, cy C.int
+	C.al_get_window_position(self.handle, &cx, &cy)
+	return int(cx), int(cy)
+}
+
+// Sets the position where new windowed displays will be created
+func (self *Display) SetWindowPosition(x, y int) {
+	C.al_set_window_position(self.handle, C.int(x), C.int(y))
+}
+
+// Sets the title of the windowed display
+func (self *Display) SetTitle(str string) {
+	cstr := cstr(str)
+	defer cstrFree(cstr)
+	C.al_set_window_title(self.handle, cstr)
+}
+
+// Sets a display option to be used when a new display is created
+func SetNewDisplayOption(option, value, importance int) {
+	C.al_set_new_display_option(C.int(option), C.int(value), C.int(importance))
+}
+
+// Resets all display oprions for new displays to their default values.
+func ResetNewDisplayOptions() {
+	C.al_reset_new_display_options()
+}
+
+// Gets the display option of this display
+func (self *Display) DisplayOption(option int) int {
+	return int(C.al_get_display_option(self.handle, C.int(option)))
+}
+
+// Allows to speed up drawing by holding the display . Only bitmap functions and font 
+// drawing, as well as tranformations shouldbe done until the hold is released
+func HoldBitmapDrawing(hold bool) {
+	C.al_hold_bitmap_drawing(b2cb(hold))
+}
+
+// Returns whether or not the bitmap drawing was held
+func IsBitmapDrawingHeld() bool {
+	return cb2b(C.al_is_bitmap_drawing_held())
+}

+ 225 - 0
src/algo/al/joystick.go

@@ -0,0 +1,225 @@
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+*/
+import "C"
+
+import "runtime"
+
+// Usful regexp for KATE:  ALLEGRO_([A-Z0-9_]+)(.*) -> \1 = C.ALLEGRO_\1
+
+// Joystick functionality.
+
+type Joystick struct {
+    handle *C.ALLEGRO_JOYSTICK
+}
+
+// Destroyst he joystick. According to the Allegro documentation, this 
+// does nothing.
+func (self *Joystick) Destroy() {
+    // Some problems is this is enabled so make sure this does nothing...
+    // C.al_release_joystick(self.handle)
+}
+
+// Wraps a C joystick handler into the Go Joystick wrapper.
+func wrapJoystickRaw(handle *C.ALLEGRO_JOYSTICK) *Joystick {
+    if handle == nil {
+        return nil
+    }
+    return &Joystick{handle}
+}
+
+// Wraps a C joystick handler into the Go Joystick wrapper.
+// Also sets a finalizer that calls joystick.Destroy().
+func wrapJoystick(handle *C.ALLEGRO_JOYSTICK) *Joystick {
+    self := wrapJoystickRaw(handle)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Joystick) { me.Destroy() })
+    }
+    return self
+}
+
+// Struct that holds the state of the joystick.
+type JoystickState C.ALLEGRO_JOYSTICK_STATE
+
+// Converts a wrapped joystick state to a C joystick state.
+func (self *JoystickState) toC() *C.ALLEGRO_JOYSTICK_STATE {
+    return (*C.ALLEGRO_JOYSTICK_STATE)(self)
+}
+
+// Gets the state of the axis for the given stick on the joystick.
+// returns 0.0 if the stick or axis are out of range. May return
+// garbage for nonexisting sticks and axes.
+func (self *JoystickState) GetStickAxis(stick, axis int) float32 {
+    if stick >= int(C._AL_MAX_JOYSTICK_STICKS) {
+        return 0.0
+    }
+    if axis >= int(C._AL_MAX_JOYSTICK_AXES) {
+        return 0.0
+    }
+    if axis < 0 {
+        return 0.0
+    }
+    if stick < 0 {
+        return 0.0
+    }
+    return float32(self.stick[C.int(stick)].axis[C.int(axis)])
+}
+
+// Gerts the state of the button with the given index on the joystick.
+// Will return -1 if the button is out of range.
+func (self *JoystickState) GetButton(button int) int {
+    if button >= int(C._AL_MAX_JOYSTICK_BUTTONS) {
+        return -1
+    }
+    if button < 0 {
+        return -1
+    }
+    return int(self.button[C.int(button)])
+}
+
+// Joystick flags that determine the type of the joystick.
+const (
+    JOYFLAG_DIGITAL  = C.ALLEGRO_JOYFLAG_DIGITAL
+    JOYFLAG_ANALOGUE = C.ALLEGRO_JOYFLAG_ANALOGUE
+)
+
+// Installs the Allegro Joystick module.
+func InstallJoystick() bool {
+    return bool(C.al_install_joystick())
+}
+
+// Uninstalls the Allegro Joystick module.
+func UninstallJoystick() {
+    C.al_uninstall_joystick()
+}
+
+// Returns true if the Allegro joystick module ws instaled, false if not.
+func IsJoystickInstalled() bool {
+    return bool(C.al_is_joystick_installed())
+}
+
+// Returns the amount of joysticks detected.
+func GetNumJoysticks() int {
+    return int(C.al_get_num_joysticks())
+}
+
+// Returns the joyn'th joystick, or nil if no such stick exists. 
+func GetJoystick(joyn int) *Joystick {
+    return wrapJoystick(C.al_get_joystick(C.int(joyn)))
+}
+
+// Joystick properties.
+
+// Returns true if the joystick self is active, false if not.
+func (self *Joystick) IsActive() bool {
+    return bool(C.al_get_joystick_active(self.handle))
+}
+
+// Returns the name of the joystick self.
+func (self *Joystick) GetName() string {
+    return gostr(C.al_get_joystick_name(self.handle))
+}
+
+// Returns the amount of sticks the joystick self has.
+func (self *Joystick) GetNumSticks() int {
+    return int(C.al_get_joystick_num_sticks(self.handle))
+}
+
+// Returns the joystick flags for the numbered stick on the joystick self.
+func (self *Joystick) GetStickFlags(stick int) int {
+    return int(C.al_get_joystick_stick_flags(self.handle, C.int(stick)))
+}
+
+// Returns true if the numbered stick on joystick self is digital, false if not.
+// Note that theoretically, a stick could be both digital and analog...
+func (self *Joystick) IsStickDigital(stick int) bool {
+    return (JOYFLAG_DIGITAL & self.GetStickFlags(stick)) == JOYFLAG_DIGITAL
+}
+
+// Returns true if the numbered stick on joystick self is analog, false if not
+// Note that theoretically, a stick could be both digital and analog...
+func (self *Joystick) IsStickAnalog(stick int) bool {
+    return (JOYFLAG_ANALOGUE & self.GetStickFlags(stick)) == JOYFLAG_ANALOGUE
+}
+
+// Returns a string that describes the joystick flags for the numbered stick 
+// on the joystick self. Will return "Analog" for an analog joystick, 
+// "Digital" for a digital joystick, "Hybrid" fo one that's both and 
+// "None" for one that's neither
+func (self *Joystick) GetStickFlagsName(stick int) string {
+    if self.IsStickAnalog(stick) {
+        if self.IsStickDigital(stick) {
+            return "Hybrid"
+        } else {
+            return "Analog"
+        }
+    }
+    if self.IsStickDigital(stick) {
+        return "Digital"
+    }
+    return "None"
+}
+
+// Returns the name of the stick on the joystick self.
+func (self *Joystick) GetStickName(stick int) string {
+    return gostr(C.al_get_joystick_stick_name(self.handle, C.int(stick)))
+}
+
+// Returns the amount of axes for the stick on the joystick self.
+func (self *Joystick) GetNumAxes(stick int) int {
+    return int(C.al_get_joystick_num_axes(self.handle, C.int(stick)))
+}
+
+// Returns the name of the axis for the stick on the joystick self.
+func (self *Joystick) GetAxisName(stick, axis int) string {
+    return gostr(C.al_get_joystick_axis_name(self.handle, C.int(stick), C.int(axis)))
+}
+
+// Returns the amount of buttons on the joystick self.
+func (self *Joystick) GetNumButtons() int {
+    return int(C.al_get_joystick_num_buttons(self.handle))
+}
+
+// Returns the name of the button on the joystick self.
+func (self *Joystick) GetButtonName(button int) string {
+    return gostr(C.al_get_joystick_button_name(self.handle, C.int(button)))
+}
+
+// Gets the state of the joystick
+func (self *Joystick) GetState() *JoystickState {
+    state := &JoystickState{}
+    C.al_get_joystick_state(self.handle, state.toC())
+    return state
+}
+
+/*
+AL_FUNC(bool,           al_install_joystick,    (void));
+AL_FUNC(void,           al_uninstall_joystick,  (void));
+AL_FUNC(bool,           al_is_joystick_installed, (void));
+AL_FUNC(bool,           al_reconfigure_joysticks, (void));
+
+AL_FUNC(int,            al_get_num_joysticks,   (void));
+AL_FUNC(ALLEGRO_JOYSTICK *, al_get_joystick,    (int joyn));
+AL_FUNC(void,           al_release_joystick,    (ALLEGRO_JOYSTICK *));
+AL_FUNC(bool,           al_get_joystick_active, (ALLEGRO_JOYSTICK *));
+AL_FUNC(const char*,    al_get_joystick_name,   (ALLEGRO_JOYSTICK *));
+
+AL_FUNC(int,            al_get_joystick_num_sticks, (ALLEGRO_JOYSTICK *));
+AL_FUNC(int, al_get_joystick_stick_flags, (ALLEGRO_JOYSTICK *, int stick)); 
+
+AL_FUNC(const char*,    al_get_joystick_stick_name, (ALLEGRO_JOYSTICK *, int stick));
+
+AL_FUNC(int,            al_get_joystick_num_axes,   (ALLEGRO_JOYSTICK *, int stick));
+AL_FUNC(const char*,    al_get_joystick_axis_name,  (ALLEGRO_JOYSTICK *, int stick, int axis));
+
+AL_FUNC(int,            al_get_joystick_num_buttons,  (ALLEGRO_JOYSTICK *));
+AL_FUNC(const char*,    al_get_joystick_button_name,  (ALLEGRO_JOYSTICK *, int buttonn));
+
+AL_FUNC(void,           al_get_joystick_state,  (ALLEGRO_JOYSTICK *, ALLEGRO_JOYSTICK_STATE *ret_state));
+
+AL_FUNC(ALLEGRO_EVENT_SOURCE *, al_get_joystick_event_source, (void));
+*/

+ 215 - 0
src/algo/al/keyboard.go

@@ -0,0 +1,215 @@
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+*/
+import "C"
+
+// Usful regexp for KATE:  ALLEGRO_([A-Z0-9_]+)(.*) -> \1 = C.ALLEGRO_\1
+
+// Keyboard functionality.
+
+// Checks if the Allegro keyboard module is installed or not.
+func IsKeyboardInstalled() bool {
+    return bool(C.al_is_keyboard_installed())
+}
+
+// Installs the Allegro keyboard module.
+func InstallKeyboard() bool {
+    return bool(C.al_install_keyboard())
+}
+
+// Uninstalls the Allegro keyboard module.
+func UninstallKeyboard() {
+    C.al_uninstall_keyboard()
+}
+
+// Gets the name of te given keucode as a string.
+func KeycodeToName(keycode int) string {
+    return gostr(C.al_keycode_to_name(C.int(keycode)))
+}
+
+// KeyboardState isn't very interesting for now, so don't wrap it
+// and let KeyDown work as a global function
+
+// Gets the state of a given keyboard key by keycode. True is down, false is up.
+func KeyDown(keycode int) bool {
+    state := &C.ALLEGRO_KEYBOARD_STATE{}
+    C.al_get_keyboard_state(state)
+    return bool(C.al_key_down(state, C.int(keycode)))
+}
+
+// Sets the state of the leds on the keyboard.
+func SetKeyboardLeds(leds int) bool {
+    return bool(C.al_set_keyboard_leds(C.int(leds)))
+}
+
+// Returns the Keyboard event source that can be registered to an EventQueue
+// with RegisterEventSource.
+func GetKeyboardEventSource() *EventSource {
+    return (*EventSource)(C.al_get_keyboard_event_source())
+}
+
+// Keyboard constants
+const (
+    KEY_A = C.ALLEGRO_KEY_A
+    KEY_B = C.ALLEGRO_KEY_B
+    KEY_C = C.ALLEGRO_KEY_C
+    KEY_D = C.ALLEGRO_KEY_D
+    KEY_E = C.ALLEGRO_KEY_E
+    KEY_F = C.ALLEGRO_KEY_F
+    KEY_G = C.ALLEGRO_KEY_G
+    KEY_H = C.ALLEGRO_KEY_H
+    KEY_I = C.ALLEGRO_KEY_I
+    KEY_J = C.ALLEGRO_KEY_J
+    KEY_K = C.ALLEGRO_KEY_K
+    KEY_L = C.ALLEGRO_KEY_L
+    KEY_M = C.ALLEGRO_KEY_M
+    KEY_N = C.ALLEGRO_KEY_N
+    KEY_O = C.ALLEGRO_KEY_O
+    KEY_P = C.ALLEGRO_KEY_P
+    KEY_Q = C.ALLEGRO_KEY_Q
+    KEY_R = C.ALLEGRO_KEY_R
+    KEY_S = C.ALLEGRO_KEY_S
+    KEY_T = C.ALLEGRO_KEY_T
+    KEY_U = C.ALLEGRO_KEY_U
+    KEY_V = C.ALLEGRO_KEY_V
+    KEY_W = C.ALLEGRO_KEY_W
+    KEY_X = C.ALLEGRO_KEY_X
+    KEY_Y = C.ALLEGRO_KEY_Y
+    KEY_Z = C.ALLEGRO_KEY_Z
+
+    KEY_0 = C.ALLEGRO_KEY_0
+    KEY_1 = C.ALLEGRO_KEY_1
+    KEY_2 = C.ALLEGRO_KEY_2
+    KEY_3 = C.ALLEGRO_KEY_3
+    KEY_4 = C.ALLEGRO_KEY_4
+    KEY_5 = C.ALLEGRO_KEY_5
+    KEY_6 = C.ALLEGRO_KEY_6
+    KEY_7 = C.ALLEGRO_KEY_7
+    KEY_8 = C.ALLEGRO_KEY_8
+    KEY_9 = C.ALLEGRO_KEY_9
+
+    KEY_PAD_0 = C.ALLEGRO_KEY_PAD_0
+    KEY_PAD_1 = C.ALLEGRO_KEY_PAD_1
+    KEY_PAD_2 = C.ALLEGRO_KEY_PAD_2
+    KEY_PAD_3 = C.ALLEGRO_KEY_PAD_3
+    KEY_PAD_4 = C.ALLEGRO_KEY_PAD_4
+    KEY_PAD_5 = C.ALLEGRO_KEY_PAD_5
+    KEY_PAD_6 = C.ALLEGRO_KEY_PAD_6
+    KEY_PAD_7 = C.ALLEGRO_KEY_PAD_7
+    KEY_PAD_8 = C.ALLEGRO_KEY_PAD_8
+    KEY_PAD_9 = C.ALLEGRO_KEY_PAD_9
+
+    KEY_F1  = C.ALLEGRO_KEY_F1
+    KEY_F2  = C.ALLEGRO_KEY_F2
+    KEY_F3  = C.ALLEGRO_KEY_F3
+    KEY_F4  = C.ALLEGRO_KEY_F4
+    KEY_F5  = C.ALLEGRO_KEY_F5
+    KEY_F6  = C.ALLEGRO_KEY_F6
+    KEY_F7  = C.ALLEGRO_KEY_F7
+    KEY_F8  = C.ALLEGRO_KEY_F8
+    KEY_F9  = C.ALLEGRO_KEY_F9
+    KEY_F10 = C.ALLEGRO_KEY_F10
+    KEY_F11 = C.ALLEGRO_KEY_F11
+    KEY_F12 = C.ALLEGRO_KEY_F12
+
+    KEY_ESCAPE     = C.ALLEGRO_KEY_ESCAPE
+    KEY_TILDE      = C.ALLEGRO_KEY_TILDE
+    KEY_MINUS      = C.ALLEGRO_KEY_MINUS
+    KEY_EQUALS     = C.ALLEGRO_KEY_EQUALS
+    KEY_BACKSPACE  = C.ALLEGRO_KEY_BACKSPACE
+    KEY_TAB        = C.ALLEGRO_KEY_TAB
+    KEY_OPENBRACE  = C.ALLEGRO_KEY_OPENBRACE
+    KEY_CLOSEBRACE = C.ALLEGRO_KEY_CLOSEBRACE
+    KEY_ENTER      = C.ALLEGRO_KEY_ENTER
+    KEY_SEMICOLON  = C.ALLEGRO_KEY_SEMICOLON
+    KEY_QUOTE      = C.ALLEGRO_KEY_QUOTE
+    KEY_BACKSLASH  = C.ALLEGRO_KEY_BACKSLASH
+    KEY_BACKSLASH2 = C.ALLEGRO_KEY_BACKSLASH2
+    KEY_COMMA      = C.ALLEGRO_KEY_COMMA
+    KEY_FULLSTOP   = C.ALLEGRO_KEY_FULLSTOP
+    KEY_SLASH      = C.ALLEGRO_KEY_SLASH
+    KEY_SPACE      = C.ALLEGRO_KEY_SPACE
+
+    KEY_INSERT = C.ALLEGRO_KEY_INSERT
+    KEY_DELETE = C.ALLEGRO_KEY_DELETE
+    KEY_HOME   = C.ALLEGRO_KEY_HOME
+    KEY_END    = C.ALLEGRO_KEY_END
+    KEY_PGUP   = C.ALLEGRO_KEY_PGUP
+    KEY_PGDN   = C.ALLEGRO_KEY_PGDN
+    KEY_LEFT   = C.ALLEGRO_KEY_LEFT
+    KEY_RIGHT  = C.ALLEGRO_KEY_RIGHT
+    KEY_UP     = C.ALLEGRO_KEY_UP
+    KEY_DOWN   = C.ALLEGRO_KEY_DOWN
+
+    KEY_PAD_SLASH    = C.ALLEGRO_KEY_PAD_SLASH
+    KEY_PAD_ASTERISK = C.ALLEGRO_KEY_PAD_ASTERISK
+    KEY_PAD_MINUS    = C.ALLEGRO_KEY_PAD_MINUS
+    KEY_PAD_PLUS     = C.ALLEGRO_KEY_PAD_PLUS
+    KEY_PAD_DELETE   = C.ALLEGRO_KEY_PAD_DELETE
+    KEY_PAD_ENTER    = C.ALLEGRO_KEY_PAD_ENTER
+
+    KEY_PRINTSCREEN = C.ALLEGRO_KEY_PRINTSCREEN
+    KEY_PAUSE       = C.ALLEGRO_KEY_PAUSE
+
+    KEY_ABNT_C1    = C.ALLEGRO_KEY_ABNT_C1
+    KEY_YEN        = C.ALLEGRO_KEY_YEN
+    KEY_KANA       = C.ALLEGRO_KEY_KANA
+    KEY_CONVERT    = C.ALLEGRO_KEY_CONVERT
+    KEY_NOCONVERT  = C.ALLEGRO_KEY_NOCONVERT
+    KEY_AT         = C.ALLEGRO_KEY_AT
+    KEY_CIRCUMFLEX = C.ALLEGRO_KEY_CIRCUMFLEX
+    KEY_COLON2     = C.ALLEGRO_KEY_COLON2
+    KEY_KANJI      = C.ALLEGRO_KEY_KANJI
+
+    KEY_PAD_EQUALS = C.ALLEGRO_KEY_PAD_EQUALS
+    KEY_BACKQUOTE  = C.ALLEGRO_KEY_BACKQUOTE
+    KEY_SEMICOLON2 = C.ALLEGRO_KEY_SEMICOLON2
+    KEY_COMMAND    = C.ALLEGRO_KEY_COMMAND
+    KEY_UNKNOWN    = C.ALLEGRO_KEY_UNKNOWN
+
+    /* All codes up to before KEY_MODIFIERS = C.ALLEGRO_KEY_MODIFIERS
+     * assignedas additional unknown keys, like various multimedia
+     * and application keys keyboards may have.
+     */
+
+    KEY_MODIFIERS = C.ALLEGRO_KEY_MODIFIERS
+
+    KEY_LSHIFT     = C.ALLEGRO_KEY_LSHIFT
+    KEY_RSHIFT     = C.ALLEGRO_KEY_RSHIFT
+    KEY_LCTRL      = C.ALLEGRO_KEY_LCTRL
+    KEY_RCTRL      = C.ALLEGRO_KEY_RCTRL
+    KEY_ALT        = C.ALLEGRO_KEY_ALT
+    KEY_ALTGR      = C.ALLEGRO_KEY_ALTGR
+    KEY_LWIN       = C.ALLEGRO_KEY_LWIN
+    KEY_RWIN       = C.ALLEGRO_KEY_RWIN
+    KEY_MENU       = C.ALLEGRO_KEY_MENU
+    KEY_SCROLLLOCK = C.ALLEGRO_KEY_SCROLLLOCK
+    KEY_NUMLOCK    = C.ALLEGRO_KEY_NUMLOCK
+    KEY_CAPSLOCK   = C.ALLEGRO_KEY_CAPSLOCK
+
+    KEY_MAX = C.ALLEGRO_KEY_MAX
+)
+
+// Keyboard modifier constants
+const (
+    KEYMOD_SHIFT      = C.ALLEGRO_KEYMOD_SHIFT
+    KEYMOD_CTRL       = C.ALLEGRO_KEYMOD_CTRL
+    KEYMOD_ALT        = C.ALLEGRO_KEYMOD_ALT
+    KEYMOD_LWIN       = C.ALLEGRO_KEYMOD_LWIN
+    KEYMOD_RWIN       = C.ALLEGRO_KEYMOD_RWIN
+    KEYMOD_MENU       = C.ALLEGRO_KEYMOD_MENU
+    KEYMOD_ALTGR      = C.ALLEGRO_KEYMOD_ALTGR
+    KEYMOD_COMMAND    = C.ALLEGRO_KEYMOD_COMMAND
+    KEYMOD_SCROLLLOCK = C.ALLEGRO_KEYMOD_SCROLLLOCK
+    KEYMOD_NUMLOCK    = C.ALLEGRO_KEYMOD_NUMLOCK
+    KEYMOD_CAPSLOCK   = C.ALLEGRO_KEYMOD_CAPSLOCK
+    KEYMOD_INALTSEQ   = C.ALLEGRO_KEYMOD_INALTSEQ
+    KEYMOD_ACCENT1    = C.ALLEGRO_KEYMOD_ACCENT1
+    KEYMOD_ACCENT2    = C.ALLEGRO_KEYMOD_ACCENT2
+    KEYMOD_ACCENT3    = C.ALLEGRO_KEYMOD_ACCENT3
+    KEYMOD_ACCENT4    = C.ALLEGRO_KEYMOD_ACCENT4
+)

+ 89 - 0
src/algo/al/mouse.go

@@ -0,0 +1,89 @@
+package al
+
+/*
+#include <stdlib.h>
+#include <allegro5/allegro.h>
+#include "helpers.h"
+*/
+import "C"
+
+// import "unsafe"
+// import "runtime"
+
+/*
+typedef struct ALLEGRO_MOUSE ALLEGRO_MOUSE;
+
+typedef struct ALLEGRO_MOUSE_STATE ALLEGRO_MOUSE_STATE;
+
+struct ALLEGRO_MOUSE_STATE
+{
+   int x;
+   int y;
+   int z;
+   int w;
+   int more_axes[ALLEGRO_MOUSE_MAX_EXTRA_AXES];
+   int buttons;
+   float pressure;
+   struct ALLEGRO_DISPLAY *display;
+};
+
+
+typedef struct ALLEGRO_MOUSE_CURSOR ALLEGRO_MOUSE_CURSOR;
+
+typedef enum ALLEGRO_SYSTEM_MOUSE_CURSOR
+{
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE        =  0,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT     =  1,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_ARROW       =  2,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_BUSY        =  3,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_QUESTION    =  4,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT        =  5,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE        =  6,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N    =  7,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_W    =  8,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_S    =  9,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E    = 10,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW   = 11,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SW   = 12,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SE   = 13,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE   = 14,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_PROGRESS    = 15,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_PRECISION   = 16,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_LINK        = 17,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_ALT_SELECT  = 18,
+   ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE = 19,
+   ALLEGRO_NUM_SYSTEM_MOUSE_CURSORS
+} ALLEGRO_SYSTEM_MOUSE_CURSOR;
+
+
+AL_FUNC(bool,           al_is_mouse_installed,  (void));
+AL_FUNC(bool,           al_install_mouse,       (void));
+AL_FUNC(void,           al_uninstall_mouse,     (void));
+AL_FUNC(unsigned int,   al_get_mouse_num_buttons, (void));
+AL_FUNC(unsigned int,   al_get_mouse_num_axes,  (void));
+AL_FUNC(bool,           al_set_mouse_xy,        (struct ALLEGRO_DISPLAY *display, int x, int y));
+AL_FUNC(bool,           al_set_mouse_z,         (int z));
+AL_FUNC(bool,           al_set_mouse_w,         (int w));
+AL_FUNC(bool,           al_set_mouse_axis,      (int axis, int value));
+AL_FUNC(void,           al_get_mouse_state,     (ALLEGRO_MOUSE_STATE *ret_state));
+AL_FUNC(bool,           al_mouse_button_down,   (const ALLEGRO_MOUSE_STATE *state, int button));
+AL_FUNC(int,            al_get_mouse_state_axis, (const ALLEGRO_MOUSE_STATE *state, int axis));
+
+AL_FUNC(ALLEGRO_EVENT_SOURCE *, al_get_mouse_event_source, (void));
+
+struct ALLEGRO_BITMAP;
+
+AL_FUNC(ALLEGRO_MOUSE_CURSOR *, al_create_mouse_cursor, (
+        struct ALLEGRO_BITMAP *sprite, int xfocus, int yfocus));
+AL_FUNC(void, al_destroy_mouse_cursor, (ALLEGRO_MOUSE_CURSOR *));
+AL_FUNC(bool, al_set_mouse_cursor, (struct ALLEGRO_DISPLAY *display,
+                                    ALLEGRO_MOUSE_CURSOR *cursor));
+AL_FUNC(bool, al_set_system_mouse_cursor, (struct ALLEGRO_DISPLAY *display,
+                                           ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id));
+AL_FUNC(bool, al_show_mouse_cursor, (struct ALLEGRO_DISPLAY *display));
+AL_FUNC(bool, al_hide_mouse_cursor, (struct ALLEGRO_DISPLAY *display));
+AL_FUNC(bool, al_get_mouse_cursor_position, (int *ret_x, int *ret_y));
+AL_FUNC(bool, al_grab_mouse, (struct ALLEGRO_DISPLAY *display));
+AL_FUNC(bool, al_ungrab_mouse, (void));
+
+*/