123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /*
- * Saitek X52 Arduino USB Host Shield Library.
- * Copyright 2016 by Thomas Buck <xythobuz@xythobuz.de>
- *
- * Based on the USB Host Library HID Joystick example
- * https://www.circuitsathome.com/mcu/hid-joystick-code-sample
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, version 2.
- */
-
- #include "data.h"
- #include "cppm.h"
- #include "events.h"
-
- //#define DEBUG_OUTPUT_RAW
- #define DEBUG_OUTPUT
-
- #define CHANNEL_THROTTLE 0
- #define CHANNEL_PITCH 2
- #define CHANNEL_ROLL 1
- #define CHANNEL_YAW 3
- #define CHANNEL_AUX1 4
- #define CHANNEL_AUX2 5
-
- JoystickEventsCPPM::JoystickEventsCPPM(JoystickEvents* client) : JoystickEvents(client) {
- for (uint8_t i = 0; i < channels; i++) {
- values[i] = 1500;
- }
-
- values[CHANNEL_AUX1] = 200;
- values[CHANNEL_AUX2] = 200;
-
- cppmInit();
- cppmCopy(values);
- }
-
- void JoystickEventsCPPM::OnGamePadChanged(const GamePadEventData& evt) {
- values[CHANNEL_THROTTLE] = evt.Z;
- values[CHANNEL_PITCH] = evt.Y;
- values[CHANNEL_ROLL] = evt.X;
- values[CHANNEL_YAW] = evt.Rz;
-
- cppmCopy(values);
- }
-
- void JoystickEventsCPPM::OnHatSwitch(uint8_t hat) {
-
- }
-
- void JoystickEventsCPPM::OnButtonUp(uint8_t but_id) {
-
- }
-
- void JoystickEventsCPPM::OnButtonDn(uint8_t but_id) {
-
- }
-
- void JoystickEventsCPPM::OnMouseMoved(uint8_t x, uint8_t y) {
-
- }
|