Tablet Pressure Testing via Python

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • Morning!

    I am attempting to use the wintab libraries for Python, that I may access tablet packet information. In order to open the packet stream, one needs designate the hwnd or console window handle for the application. I'm not exactly sure what this is, since I'm not much of a programmer, but I can't figure out if it's possible to acquire this integer (it is an integer, right?) from within Construct.

    This guy uses pygame to acquire it in his example, but that doesn't really work for me, and seems a bit far-reaching anyway, since Construct is generating the application, not Python. I also found it's possible with another library called wxPython, but have not tried it for the same reason.

    Is hwnd accessible within Construct?

  • Use the 'window' object, it has an expression 'get application window' which i think returns a window handle. Hope that helps.

  • That seems right!

    I got it working. ^^; Thanks.

  • Why even use Construct then?

  • Why even use anything? Nothing really matters. Abandon all hope.

    This cheerful message brought to you by deadeye, brightening your days since 2007.

  • construct and tablets? I wanna know what comes out of this =)

  • Good to know at least one person is supportive. I don't really understand newt's comment.

    So far I've got pressure sensitivity reading fine, and it even works on other computers (took a while to figure out where to store the libraries, am learning). At the moment I am in my newbish way attempting to pull further packet data from the tablet driver connection, and will likely make a thread in Tutorials about tablet support when the methods become clear.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • storing external python libraries is something no one has explained (or done at all?) yet.

    Could you post details about this?

  • Good to know at least one person is supportive. I don't really understand newt's comment.

    So far I've got pressure sensitivity reading fine, and it even works on other computers (took a while to figure out where to store the libraries, am learning). At the moment I am in my newbish way attempting to pull further packet data from the tablet driver connection, and will likely make a thread in Tutorials about tablet support when the methods become clear.

    You cant draw to the Construct window. At least thats the way I understand it.

    storing external python libraries is something no one has explained (or done at all?) yet.

    Could you post details about this?

    According to David everything should be exported to the exe. You will, however have to place the modules used into the folder construct\data\python... when everything works correctly.

  • "can't draw to the construct window" -> Certainly you can! Here's what I had back in May '09:

    <img src="http://smg.photobucket.com/albums/v325/mwahaha/screenshot/brushwin.png">

    That wasn't even with pressure sensitivity.

    [quote:2mapg3b3]storing external python libraries is something no one has explained (or done at all?) yet.

    It was not very difficult. What newt says about exporting the scripts to exe is correct - but only for scripts. If the scripts in question reference any other files, in my case a compiled .pyd file, you don't want to pack those in the same way as the scripts, because the bundled .py files are read from a zip within the Temp directory at runtime, and the scripts can't seem to reference the contents of that zip.

    At first this had me confused, but as soon as I looked at what it was doing, everything made sense. The test app was functional within Construct, because it could read the libraries the scripts were using from various locations - Construct\Data\Python, where I'd placed them manually, but also from the Python26\Lib\etc directories. Of course, for distribution, you are not going to want to require that the user install Python and a special library just to run your program. So what I did was tossed the extra, non-.py libraries in the exe's directory.

    It seems that simple!

    I've only had one friend try it, though, so if anyone with a tablet wants to help - it's rather featureless, but - here is a 7z and a zip of the test application. They are identical. In reality, people without tablets should be able to test it as well. If it's all bundled correctly, it should not pop up any errors when loading the exe.

    http://dl.dropbox.com/u/398143/Files/PressureTest.7z (1,324 KB)

    http://dl.dropbox.com/u/398143/Files/PressureTest.zip (1,906 KB)

    There is a boost_python-vc90-mt-1_39.dll in there that I don't think is actually being used. It seems to work fine without it at the moment. Wintab uses it for something, presumably - I have simply not accessed many features just yet. Also! Since I have it reading sensitivity, but not delivering any other actual information about the tablet to Construct, this is hardcoded to function properly with tablets that possess 1024 levels of pressure sensitivity alone. If tablets with different sensitivity levels exist, it will probably behave unusually.

    If you are going to bundle libraries and such accessed by your python scripts in your own project, but aren't writing all your imported scripts from scratch (such as wintab, which communicates with tablet drivers), you may need to fiddle with the directory context of the various 'import' calls within the scripts. For example, wintab is stored within cgkit in Python, but I am using it outside of cgkit, and therefore simplified the file organization. I am not really sure how intuitive Python is when it comes to importing resources (where it will look, and how deep) but the error reporting in Construct proved invaluable for rooting out which scripts needed tweaking where.

  • You cant draw to the Construct window. At least thats the way I understand it.

    Silly banana! Is Canvas so easily forgotten?

    You can draw all sorts of things.

    I've only had one friend try it, though, so if anyone with a tablet wants to help - it's rather featureless, but - here is a 7z and a zip of the test application. They are identical. In reality, people without tablets should be able to test it as well. If it's all bundled correctly, it should not pop up any errors when loading the exe.

    http://dl.dropbox.com/u/398143/Files/PressureTest.zip (1,906 KB)

    It works! Reads my tablet pressure just fine and dandy.

    You should change the thread title to "Tablet pressure test in Python" if you want more people to try it... the current title is rather ambiguous.

  • I get repeated error windows until I close the window =(

    The error is:

    [quote:3d9w9s8c]traceback (most recent call last):

    File "<string>", line 8, in <module>

    IndexError: list index out of range

  • I get repeated error windows until I close the window =(

    Same here. I get the same errors that can't be closed out until I close out the app.

    I haven't gotten a chance to mess with the new and improved Python except to confirm that now just plain Python without external libraries works correctly.

    If you are going to bundle libraries and such accessed by your python scripts in your own project, but aren't writing all your imported scripts from scratch (such as wintab, which communicates with tablet drivers), you may need to fiddle with the directory context of the various 'import' calls within the scripts.

    I see what you are getting at with this. Hopefully, there will be a more integrated/automated way though because this is far from straightforward and the changes in a large external library that would have to be made would go really deep.

  • I get the same endless errors as Madster and Scidave.

    Krush.

  • What tablets do you guys own (if any)?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)