OSDN Git Service

adde086fd050a20ecdad302944e5239a0da99b72
[csp-qt/common_source_project-fm7.git] / source / src / qt / common / joy_thread.h
1 /*
2         Skelton for retropc emulator
3         Author : Takeda.Toshiya
4         Port to Qt : K.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2006.08.18 -
6         License : GPLv2
7         History : 2015.11.10 Split from qt_main.h
8         [ win32 main ] -> [ Qt main ] -> [Joy Stick]
9 */
10 #ifndef _CSP_QT_JOY_THREAD_H
11 #define _CSP_QT_JOY_THREAD_H
12
13 #include <QThread>
14 #include <SDL.h>
15 #include "emu.h"
16 #include "osd.h"
17
18 class EMU;
19 class QString;
20
21 QT_BEGIN_NAMESPACE
22 #if defined(USE_JOYSTICK)
23
24 class JoyThreadClass : public QThread {
25         Q_OBJECT
26  private:
27         int joy_num[16];
28         SDL_Event event;
29 #if defined(USE_SDL2)   
30         SDL_GameController *controller_table[16];
31 #endif  
32         SDL_Joystick *joyhandle[16];
33         QString names[16];
34         EMU *p_emu;
35         OSD *p_osd;
36  protected:
37         bool bRunThread;
38 #if defined(USE_JOYSTICK)       
39         void joystick_plugged(int num);
40         void joystick_unplugged(int num);
41         bool EventSDL(SDL_Event *);
42         void x_axis_changed(int, int);
43         void y_axis_changed(int, int);
44         void button_down(int, unsigned int);
45         void button_up(int, unsigned int);
46         int get_joy_num(int id);
47 # if defined(USE_SDL2)
48         int get_joyid_from_instanceID(SDL_JoystickID id);
49 # endif
50 #endif  
51  public:
52         JoyThreadClass(EMU *p, QObject *parent = 0);
53         ~JoyThreadClass();
54         void run() { doWork("");}
55         void SetEmu(EMU *p) {
56                 p_emu = p;
57         }
58 public slots:
59         void doWork(const QString &);
60         void doExit(void);
61  signals:
62         int sig_finished(void);
63         int call_joy_thread(EMU *);
64 };
65 #endif  
66
67 QT_END_NAMESPACE
68
69 #endif