Monday 25 January 2016

I has keys..and mice

One oddity of the Raspberry Pi seems to be its key and mouse handling. I am not a Linux coder, and am very deliberately trying to avoid doing anything with Linux beyond letting it compile and boot my programs remotely with VisualGBD, but there are a few things I still need it to do, especially when accessing any attached hardware to the Pi. For example Keys and Mice..

Documentation on how to access input systems, was sparse, mainly of course because sensible people usually are using some kind of library like SDL2 which itself handles all the key and mouse input.

I am however loathed to add SDL2 or any other large libs to my project as I try to emulate working on the machine as bare as possible. I want to maintain a promise to use only what the machine comes equipped with. Some libs will be needed, my screen loader and audio for example which would take far too long to do anything low end with. But the less the better. If we assume our lowest system is a Raspberry Pi A, we only have 256Mb of ram, I don't want that filled up with API's that use memory for code we never use, the lighter the project the more effective it will be.

Fortunately a fellow grumpy old git developer came to my rescue with some code that showed me how to get it working, and as a bonus is a good intro to threads and multi core coding. It still took a bit of twiddling with to get it to compile, but eventually it all clicked and ran on the Pi :D I will of course be giving Gareth Lewis an appropriate credit for his invaluable assistance. I think I would have been some time getting that to work on my own, and probably have to hit the Linux manuals (shudder)

So I now have a fully working and very small Input system that gives me key presses and mouse input, the rest of the process should now be fairly easy...fingers crossed!

Also I found a retail supplier for a new Pi zero, the teeny weeny version of it that was sold on a magazine for £5 last year...sadly I had to pay 3 times that but its ok I want to be sure my projects will also run on the lesser Pi's. I already have a B+ and I put in an ebay bid for an older A+ that should be plenty to ensure the projects reach the largest capture. They can still be bought retail though for $20 or so.

I also have a Pine64 on the way after the kickstarter program I backed was fully funded by some margin, which though not a Pi, shares the basic architecture of it and then some, and also runs Linux, so hopefully I can get that to also work and demo a higher powered system.

I must say I am REALLY enjoying writing this book, I am coding and also I feel I am teaching again, which is not something I get a sense of with our new V2 system. I can safely say I am laying down all my old course work into this book and it should help anyone who wants to write games, even if they don't want to use the Pi.




Ahthankyew

No comments: