--- /dev/null
+//
+// gamepad.cpp - Host joystick handling (using SDL)
+//
+// by James Hammons
+// (C) 2013 Underground Software
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -------------------------------------------------------------
+// JLH 01/05/2013 Created this file
+//
+
+#include "gamepad.h"
+
+
+bool Gamepad::GetState(int joystickID, int buttonID)
+{
+ if (buttonID & JOY_BUTTON)
+ {
+ // Handle SDL button
+ }
+ else if (buttonID & JOY_HAT)
+ {
+ // Handle SDL hats
+ int hatNumber = (buttonID & JOY_HATNUM_MASK) >> 3;
+ int hatDirection = hatMask[buttonID & JOY_HATBUT_MASK];
+ }
+
+ // Default == failure
+ return false;
+}
+
+
+int Gamepad::GetButtonID(void)
+{
+ // Return single button ID being pressed (if any)
+}
+
+
+int Gamepad::GetJoystickID(void)
+{
+ // Return joystick ID of button being pressed (if any)
+}
+
--- /dev/null
+//
+// gamepad.h: Header file
+//
+// by James Hammons
+// (C) 2013 Underground Software
+//
+
+#ifndef __GAMEPAD_H__
+#define __GAMEPAD_H__
+
+#define JOY_BUTTON 0x0100
+#define JOY_HAT 0x0200
+
+#define JOY_TYPE_MASK 0xFF00
+#define JOY_HATNUM_MASK 0x00F8
+#define JOY_HATBUT_MASK 0x0007
+
+#include <stdint.h>
+
+uint8_t hatMask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+
+// buttonID is the combination of the type (BUTTON, HAT) and the button #
+// (0-255 for buttons, 0-31 for hats). Hats also have 0-7 for a button #
+// that corresponds to a direction.
+
+class Gamepad
+{
+// really should make all methods and members be static so that we can
+// call this stuff without instantiating one. :-)
+ public:
+ Gamepad();
+ ~Gamepad();
+
+ bool GetState(int joystickID, int buttonID);
+ int GetButtonID(void);
+ int GetJoystickID(void);
+};
+
+#endif // __GAMEPAD_H__
// it will be half this number for a half frame. BUT, since we're counting
// HALF lines, we double this number and we're back at 525 for NTSC, 625 for PAL.
//
-// Scanline times are 63.5555... \0s in NTSC and 64 \0s in PAL
+// Scanline times are 63.5555... μs in NTSC and 64 μs in PAL
// Half line times are, naturally, half of this. :-P
void HalflineCallback(void)
{
src/gui/filelistmodel.h \
src/gui/filepicker.h \
src/gui/filethread.h \
+ src/gui/gamepad.h \
src/gui/generaltab.h \
src/gui/glwidget.h \
src/gui/help.h \
src/gui/filelistmodel.cpp \
src/gui/filepicker.cpp \
src/gui/filethread.cpp \
+ src/gui/gamepad.cpp \
src/gui/generaltab.cpp \
src/gui/glwidget.cpp \
src/gui/help.cpp \