The controller I made for Osu!taiko was a drum shape device
that mapped input in the game according to the direction the controller is tilted
in. The conceptual model was meant to have the logos of the taiko characters on
the top of the drum to make it relate to the game itself. After spending time working
on the frame for the controller, I had to scrap that idea due to how I made the
framing. Covering the controller in something was honestly the hardest part out
of the whole project, it was a struggle to find something that would cover it
and also stay on the controller as the user is tilting it. Ended up going with
a thick string that I had in my house, it is not the greatest looking thing but
it got the job done and that was what I was worried about. The way the input
works on the controller is the accelerometer registers input through numbers,
and if the controller is tilted far enough in one direction, it registers that
as input. The output is a press of a certain key on the keyboard, and each
direction results in a different key being pressed. This allows us to play
Osu!taiko because there are only four inputs in the game and only the keyboard is
being used. The drum shape of the controller is due to the nature of the game itself,
the player is meant to be hitting a drum in accordance with the notes that are
appearing on the screen.
The hardest part for me by far was the physical design of the controller. If you were to make edits to the design how would you go about it and what would you do differently?
#include "Adafruit_TinyUSB.h"#include <Adafruit_CircuitPlayground.h>#include <Adafruit_Circuit_Playground.h>//Code by Gianni Rodriguez//USB set up codeuint8_t const desc_hid_report[] ={TUD_HID_REPORT_DESC_KEYBOARD()};Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), HID_ITF_PROTOCOL_KEYBOARD, 2, false);const int Time = 100;void setup() {Serial.begin(9600);CircuitPlayground.begin();usb_hid.begin();}void loop() {//USB keyboard setupuint8_t const report_id = 0;uint8_t const modifier = 0;uint8_t keycode[6] = {0};//Setting up X axis for accelerometerfloat horizontal = CircuitPlayground.motionX();//Setting up Y axis for accelerometerfloat vertical = CircuitPlayground.motionY();//Forward tilt presses the "X" keyif (vertical >= 4) {keycode[0] = HID_KEY_X;usb_hid.keyboardReport(report_id, modifier, keycode);delay(150);usb_hid.keyboardRelease(0);}//Right tilt presses the "Z" keyif (horizontal >= 4) {keycode[0] = HID_KEY_Z;usb_hid.keyboardReport(report_id, modifier, keycode);delay(250);usb_hid.keyboardRelease(0);}//Back tilt presses the "C" keyif (vertical <= -4) {keycode[0] = HID_KEY_C;usb_hid.keyboardReport(report_id, modifier, keycode);delay(250);usb_hid.keyboardRelease(0);}//Left tilt presses the "V" keyif (horizontal <= -4) {keycode[0] = HID_KEY_V;usb_hid.keyboardReport(report_id, modifier, keycode);delay(250);usb_hid.keyboardRelease(0);}}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.