Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implemented Mouse and Cursor. Need to test

  • Loading branch information...
commit a95ab5ca2ab8e6d01ae4fb4f68129e858348f9d1 1 parent c8fb1e2
@kthakore kthakore authored
View
14 Build.PL
@@ -140,6 +140,20 @@ my %subsystems =
},
libraries => [qw( SDL )],
},
+ Mouse => {
+ file => {
+ from => 'src/Core/Mouse.xs',
+ to => 'lib/SDL/Mouse.xs',
+ },
+ libraries => [qw( SDL )],
+ },
+ Cursor => {
+ file => {
+ from => 'src/Core/objects/Cursor.xs',
+ to => 'lib/SDL/Cursor.xs',
+ },
+ libraries => [qw( SDL )],
+ },
TTF_Font => {
file => {
View
75 lib/SDL/Cursor.pm
@@ -1,76 +1,9 @@
-#!/usr/bin/env perl
-#
-# Cursor.pm
-#
-# Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
-#
-# ------------------------------------------------------------------------------
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# ------------------------------------------------------------------------------
-#
-# Please feel free to send questions, suggestions or improvements to:
-#
-# David J. Goehrig
-# dgoehrig@cpan.org
-#
-
package SDL::Cursor;
use strict;
use warnings;
-use Carp;
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my %options = @_;
-
- verify (%options, qw/ -data -mask -x -y /) if $SDL::DEBUG;
-
-
- my $self = \SDL::NewCursor($options{-data},$options{-mask},
- $options{-x},$options{-y});
- croak SDL::GetError() unless $$self;
- bless $self, $class;
- $self;
-}
-
-sub DESTROY ($) {
- my $self = shift;
- SDL::FreeCursor($$self);
-}
-
-sub warp ($$$) {
- my ($self,$x,$y) = @_;
- SDL::WarpMouse($x,$y);
-}
-
-sub use ($) {
- my $self = shift;
- SDL::SetCursor($$self);
-}
-
-sub get () {
- SDL::GetCursor();
-}
-
-sub show ($;$) {
- my ($self,$toggle) = @_;
- $toggle = 0 unless defined $toggle;
- SDL::ShowCursor($toggle);
-}
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Cursor;
1;
View
51 src/Core/Mouse.xs
@@ -0,0 +1,51 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::Mouse PACKAGE = SDL::Mouse PREFIX = mouse_
+
+
+void
+mouse_warp_mouse ( x, y )
+ Uint16 x
+ Uint16 y
+ CODE:
+ SDL_WarpMouse(x,y);
+
+void
+mouse_free_cursor ( cursor )
+ SDL_Cursor *cursor
+ CODE:
+ SDL_FreeCursor(cursor);
+
+void
+mouse_set_cursor ( cursor )
+ SDL_Cursor *cursor
+ CODE:
+ SDL_SetCursor(cursor);
+
+SDL_Cursor *
+mouse_get_cursor ()
+ PREINIT:
+ char* CLASS = "SDL::Cursor";
+ CODE:
+ RETVAL = SDL_GetCursor();
+ OUTPUT:
+ RETVAL
+
+int
+mouse_show_cursor ( toggle )
+ int toggle
+ CODE:
+ RETVAL = SDL_ShowCursor(toggle);
+ OUTPUT:
+ RETVAL
+
+
+
View
47 src/SDL.xs
@@ -689,53 +689,6 @@ IMG_Load ( filename )
#endif
-void
-WarpMouse ( x, y )
- Uint16 x
- Uint16 y
- CODE:
- SDL_WarpMouse(x,y);
-
-
-SDL_Cursor *
-NewCursor ( data, mask, x ,y )
- SDL_Surface *data
- SDL_Surface *mask
- int x
- int y
- CODE:
- RETVAL = SDL_CreateCursor((Uint8*)data->pixels,
- (Uint8*)mask->pixels,data->w,data->h,x,y);
- OUTPUT:
- RETVAL
-
-void
-FreeCursor ( cursor )
- SDL_Cursor *cursor
- CODE:
- SDL_FreeCursor(cursor);
-
-void
-SetCursor ( cursor )
- SDL_Cursor *cursor
- CODE:
- SDL_SetCursor(cursor);
-
-SDL_Cursor *
-GetCursor ()
- CODE:
- RETVAL = SDL_GetCursor();
- OUTPUT:
- RETVAL
-
-int
-ShowCursor ( toggle )
- int toggle
- CODE:
- RETVAL = SDL_ShowCursor(toggle);
- OUTPUT:
- RETVAL
-
=for comment
SDL_AudioSpec *
View
2  t/00-load.t
@@ -16,6 +16,8 @@ SDL::Overlay
SDL::Rect
SDL::Events
SDL::Event
+SDL::Mouse
+SDL::Cursor
/;
plan tests => scalar @modules;
View
12 t/core_mouse.t
@@ -2,11 +2,19 @@
use strict;
use SDL;
use Test::More;
+use SDL::Mouse;
+use SDL::Cursor;
+use SDL::Surface;
+
+my @done =
+qw/
+/;
+
+can_ok ('SDL::Video', @left); #change to @done later ... after tests
-my @done = qw//;
my @left = qw/
-warp_mouse
+warp_mouse
create_cursor
free_cursor
set_cursor
View
2  typemap
@@ -44,7 +44,7 @@ SDL_PixelFormat * O_OBJECT
SDL_VideoInfo * O_OBJECT
SDL_version * O_OBJECT
SDL_SysWMInfo * O_OBJECT
-SDL_Cursor * T_PTR
+SDL_Cursor * O_OBJECT
SDL_AudioSpec * O_OBJECT
SDL_AudioCVT * T_PTR
Mix_Fading T_UV
Please sign in to comment.
Something went wrong with that request. Please try again.