# TestJoystick - rewriten for SDL2\]

**URL:** <https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124>\
**Category:** SDL Development\
**Created:** [September 13, 2012, 4:46pm UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124 "2012-09-13T16:46:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Wood](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Simon\_Wood](https://discourse.libsdl.org/u/Simon_Wood)\
**Post date:** [September 13, 2012, 4:46pm UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/1 "2012-09-13T16:46:31Z")

</div>

Hi all,  
Under SDL2 the ‘test/testjoystick.c’ has been broken for a while - #if’ed  
with a ‘fixme’ note.

So I fixed it. Enjoy  
Simon

-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: testjoystick.c  
Type: text/x-csrc  
Size: 7691 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120913/f3cb5563/attachment.c](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120913/f3cb5563/attachment.c)

---

<div class="post-metadata">

**Author:** ![icculus](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/icculus/32/81_2.png) [@icculus](https://discourse.libsdl.org/u/icculus)\
**Post date:** [September 13, 2012, 5:00pm UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/2 "2012-09-13T17:00:28Z")

</div>

> Under SDL2 the ‘test/testjoystick.c’ has been broken for a while - #if’ed  
> with a ‘fixme’ note.
> 
> So I fixed it. Enjoy

We just fixed this a few weeks ago:

```
 http://hg.libsdl.org/SDL/rev/c294faf5fce5
 http://hg.libsdl.org/SDL/rev/efdf44f20799

```

…is there anything we should grab from your version?

Thanks,  
–ryan.

---

<div class="post-metadata">

**Author:** ![Simon\_Wood](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Simon\_Wood](https://discourse.libsdl.org/u/Simon_Wood)\
**Post date:** [September 14, 2012, 4:47pm UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/3 "2012-09-14T16:47:51Z")

</div>

Hi Ryan,  
Fixed already…? Oh well, I think I learnt something in the exercise.

I based my varient on the ‘common.c’ stuff, which detects multiple renders  
and various screen sizes. Depending on the views of the SDL dev’s that  
might be a between way to go.

If so desired, I can merge the two versions to produce a patch sometime  
next week.  
Simon.

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [September 24, 2012, 12:36am UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/4 "2012-09-24T00:36:06Z")

</div>

Yeah, I’ve been trying to base all the new SDL tests on common.c so they  
have a good set of starting code framework and command line options. Feel  
free to tackle it at your leisure!On Fri, Sep 14, 2012 at 9:47 AM, wrote:

> Hi Ryan,  
> Fixed already…? Oh well, I think I learnt something in the exercise.
> 
> I based my varient on the ‘common.c’ stuff, which detects multiple renders  
> and various screen sizes. Depending on the views of the SDL dev’s that  
> might be a between way to go.
> 
> If so desired, I can merge the two versions to produce a patch sometime  
> next week.  
> Simon.
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Andreas\_Schiffler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@Andreas\_Schiffler](https://discourse.libsdl.org/u/Andreas_Schiffler)\
**Post date:** [September 24, 2012, 4:01am UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/5 "2012-09-24T04:01:58Z")

</div>

It would be great if this “test wrapper” was part of SDL2? That way  
anyone (i.e. SDL\_xyz test code) can use the same “common” API for  
tests/sample code.On 9/23/2012 5:36 PM, Sam Lantinga wrote:

> Yeah, I’ve been trying to base all the new SDL tests on common.c so  
> they have a good set of starting code framework and command line  
> options. Feel free to tackle it at your leisure!
> 
> On Fri, Sep 14, 2012 at 9:47 AM, \<simon at [mungewell.org](http://mungewell.org) \<mailto:simon at [mungewell.org](http://mungewell.org)\>\> wrote:
> 
> ```
> Hi Ryan,
> Fixed already...? Oh well, I think I learnt something in the exercise.
> 
> I based my varient on the 'common.c' stuff, which detects multiple
> renders
> and various screen sizes. Depending on the views of the SDL dev's that
> might be a between way to go.
> 
> If so desired, I can merge the two versions to produce a patch
> sometime
> next week.
> Simon.
> 
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> 
> ```
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [September 29, 2012, 8:25am UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/6 "2012-09-29T08:25:36Z")

</div>

You mean an official part of the API and included in the shared library?

The file itself is zlib licensed and can be easily dropped into any  
project… ?On Sun, Sep 23, 2012 at 9:01 PM, Andreas Schiffler wrote:

> It would be great if this “test wrapper” was part of SDL2? That way  
> anyone (i.e. SDL\_xyz test code) can use the same “common” API for  
> tests/sample code.
> 
> On 9/23/2012 5:36 PM, Sam Lantinga wrote:
> 
> Yeah, I’ve been trying to base all the new SDL tests on common.c so they  
> have a good set of starting code framework and command line options. Feel  
> free to tackle it at your leisure!
> 
> On Fri, Sep 14, 2012 at 9:47 AM, wrote:
> 
> > Hi Ryan,  
> > Fixed already…? Oh well, I think I learnt something in the exercise.
> > 
> > I based my varient on the ‘common.c’ stuff, which detects multiple renders  
> > and various screen sizes. Depending on the views of the SDL dev’s that  
> > might be a between way to go.
> > 
> > If so desired, I can merge the two versions to produce a patch sometime  
> > next week.  
> > Simon.
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
> 
> * * *
> 
> SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

---

<div class="post-metadata">

**Author:** ![Simon\_Wood](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/91b2a8/32.png) [@Simon\_Wood](https://discourse.libsdl.org/u/Simon_Wood)\
**Post date:** [October 14, 2012, 2:34am UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/7 "2012-10-14T02:34:05Z")

</div>

Attached is a patch for testjoystick to use the common state stuff, made  
against the Oct4 snapshot (SDL-2.0.0-6559). I’ve also attached the  
complete file.

Note Makefile will need to be patched to include ‘commmon.c’  
Simon

> Hi Ryan,  
> Fixed already…? Oh well, I think I learnt something in the exercise.
> 
> I based my varient on the ‘common.c’ stuff, which detects multiple renders  
> and various screen sizes. Depending on the views of the SDL dev’s that  
> might be a between way to go.
> 
> If so desired, I can merge the two versions to produce a patch sometime  
> next week.  
> Simon.

-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: testjoystick\_common.patch  
Type: text/x-patch  
Size: 8388 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20121013/d59fbf8b/attachment.bin](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20121013/d59fbf8b/attachment.bin)  
-------------- next part --------------  
A non-text attachment was scrubbed…  
Name: testjoystick.c  
Type: text/x-csrc  
Size: 8069 bytes  
Desc: not available  
URL: [http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20121013/d59fbf8b/attachment.c](http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20121013/d59fbf8b/attachment.c)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [October 14, 2012, 7:24am UTC](https://discourse.libsdl.org/t/testjoystick-rewriten-for-sdl2/19124/8 "2012-10-14T07:24:56Z")

</div>

Thanks, your patch is in!  
[http://hg.libsdl.org/SDL/rev/ab57cc69dcc0On](http://hg.libsdl.org/SDL/rev/ab57cc69dcc0On) Sat, Oct 13, 2012 at 7:34 PM, wrote:

> Attached is a patch for testjoystick to use the common state stuff, made  
> against the Oct4 snapshot (SDL-2.0.0-6559). I’ve also attached the  
> complete file.
> 
> Note Makefile will need to be patched to include ‘commmon.c’  
> Simon
> 
> > Hi Ryan,  
> > Fixed already…? Oh well, I think I learnt something in the exercise.
> > 
> > I based my varient on the ‘common.c’ stuff, which detects multiple  
> > renders  
> > and various screen sizes. Depending on the views of the SDL dev’s that  
> > might be a between way to go.
> > 
> > If so desired, I can merge the two versions to produce a patch sometime  
> > next week.  
> > Simon.
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
