add touchscreen input
This commit is contained in:
parent
2d131dd755
commit
b59de12ce4
|
@ -36,6 +36,9 @@ u32 HotkeyPress, HotkeyRelease;
|
||||||
|
|
||||||
u32 InputMask;
|
u32 InputMask;
|
||||||
|
|
||||||
|
bool Touching;
|
||||||
|
int TouchX, TouchY;
|
||||||
|
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
|
@ -48,6 +51,10 @@ void Init()
|
||||||
ExtHotkeyMask = 0;
|
ExtHotkeyMask = 0;
|
||||||
HotkeyMask = 0;
|
HotkeyMask = 0;
|
||||||
LastHotkeyMask = 0;
|
LastHotkeyMask = 0;
|
||||||
|
|
||||||
|
Touching = false;
|
||||||
|
TouchX = 0;
|
||||||
|
TouchY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,6 +197,18 @@ void ExtHotkeyPress(int id)
|
||||||
ExtHotkeyMask |= (1<<id);
|
ExtHotkeyMask |= (1<<id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TouchScreen(int x, int y)
|
||||||
|
{
|
||||||
|
TouchX = x;
|
||||||
|
TouchY = y;
|
||||||
|
Touching = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseScreen()
|
||||||
|
{
|
||||||
|
Touching = false;
|
||||||
|
}
|
||||||
|
|
||||||
void Process()
|
void Process()
|
||||||
{
|
{
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
|
|
@ -32,6 +32,9 @@ extern SDL_Joystick* Joystick;
|
||||||
|
|
||||||
extern u32 InputMask;
|
extern u32 InputMask;
|
||||||
|
|
||||||
|
extern bool Touching;
|
||||||
|
extern int TouchX, TouchY;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// set joystickID before calling openJoystick()
|
// set joystickID before calling openJoystick()
|
||||||
|
@ -43,6 +46,9 @@ void KeyRelease(QKeyEvent* event);
|
||||||
|
|
||||||
void ExtHotkeyPress(int id);
|
void ExtHotkeyPress(int id);
|
||||||
|
|
||||||
|
void TouchScreen(int x, int y);
|
||||||
|
void ReleaseScreen();
|
||||||
|
|
||||||
void Process();
|
void Process();
|
||||||
|
|
||||||
bool HotkeyDown(int id);
|
bool HotkeyDown(int id);
|
||||||
|
|
|
@ -196,6 +196,8 @@ struct InputFrame
|
||||||
{
|
{
|
||||||
u32 FrameNum;
|
u32 FrameNum;
|
||||||
u32 KeyMask;
|
u32 KeyMask;
|
||||||
|
u32 Touching;
|
||||||
|
u32 TouchX, TouchY;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::queue<InputFrame> InputQueue;
|
std::queue<InputFrame> InputQueue;
|
||||||
|
@ -471,6 +473,9 @@ void StartLocal()
|
||||||
InputFrame frame;
|
InputFrame frame;
|
||||||
frame.FrameNum = i;
|
frame.FrameNum = i;
|
||||||
frame.KeyMask = 0xFFF;
|
frame.KeyMask = 0xFFF;
|
||||||
|
frame.Touching = 0;
|
||||||
|
frame.TouchX = 0;
|
||||||
|
frame.TouchY = 0;
|
||||||
InputQueue.push(frame);
|
InputQueue.push(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +848,10 @@ void ProcessInput()
|
||||||
InputFrame frame;
|
InputFrame frame;
|
||||||
frame.FrameNum = NDS::NumFrames + lag;
|
frame.FrameNum = NDS::NumFrames + lag;
|
||||||
frame.KeyMask = Input::InputMask;
|
frame.KeyMask = Input::InputMask;
|
||||||
// TODO: touchscreen input and other shit!
|
frame.Touching = Input::Touching ? 1:0;
|
||||||
|
frame.TouchX = Input::TouchX;
|
||||||
|
frame.TouchY = Input::TouchY;
|
||||||
|
// TODO: other shit! (some hotkeys for example?)
|
||||||
|
|
||||||
InputQueue.push(frame);
|
InputQueue.push(frame);
|
||||||
|
|
||||||
|
@ -884,6 +892,9 @@ void ProcessInput()
|
||||||
// apply this input frame
|
// apply this input frame
|
||||||
if (frame.KeyMask != 0xFFF) printf("[%08d] INPUT=%08X (%08d) (backlog=%d)\n", NDS::NumFrames, frame.KeyMask, frame.FrameNum, InputQueue.size());
|
if (frame.KeyMask != 0xFFF) printf("[%08d] INPUT=%08X (%08d) (backlog=%d)\n", NDS::NumFrames, frame.KeyMask, frame.FrameNum, InputQueue.size());
|
||||||
NDS::SetKeyMask(frame.KeyMask);
|
NDS::SetKeyMask(frame.KeyMask);
|
||||||
|
if (frame.Touching) NDS::TouchScreen(frame.TouchX, frame.TouchY);
|
||||||
|
else NDS::ReleaseScreen();
|
||||||
|
|
||||||
InputQueue.pop();
|
InputQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,6 +479,8 @@ void EmuThread::run()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NDS::SetKeyMask(Input::InputMask);
|
NDS::SetKeyMask(Input::InputMask);
|
||||||
|
if (Input::Touching) NDS::TouchScreen(Input::TouchX, Input::TouchY);
|
||||||
|
else NDS::ReleaseScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input::HotkeyPressed(HK_Lid))
|
if (Input::HotkeyPressed(HK_Lid))
|
||||||
|
@ -923,7 +925,7 @@ void ScreenHandler::screenOnMousePress(QMouseEvent* event)
|
||||||
if (Frontend::GetTouchCoords(x, y, false))
|
if (Frontend::GetTouchCoords(x, y, false))
|
||||||
{
|
{
|
||||||
touching = true;
|
touching = true;
|
||||||
NDS::TouchScreen(x, y);
|
Input::TouchScreen(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +937,7 @@ void ScreenHandler::screenOnMouseRelease(QMouseEvent* event)
|
||||||
if (touching)
|
if (touching)
|
||||||
{
|
{
|
||||||
touching = false;
|
touching = false;
|
||||||
NDS::ReleaseScreen();
|
Input::ReleaseScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +954,7 @@ void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
|
|
||||||
if (Frontend::GetTouchCoords(x, y, true))
|
if (Frontend::GetTouchCoords(x, y, true))
|
||||||
NDS::TouchScreen(x, y);
|
Input::TouchScreen(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenHandler::screenHandleTablet(QTabletEvent* event)
|
void ScreenHandler::screenHandleTablet(QTabletEvent* event)
|
||||||
|
@ -970,14 +972,14 @@ void ScreenHandler::screenHandleTablet(QTabletEvent* event)
|
||||||
if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TabletMove))
|
if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TabletMove))
|
||||||
{
|
{
|
||||||
touching = true;
|
touching = true;
|
||||||
NDS::TouchScreen(x, y);
|
Input::TouchScreen(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEvent::TabletRelease:
|
case QEvent::TabletRelease:
|
||||||
if (touching)
|
if (touching)
|
||||||
{
|
{
|
||||||
NDS::ReleaseScreen();
|
Input::ReleaseScreen();
|
||||||
touching = false;
|
touching = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1003,14 +1005,14 @@ void ScreenHandler::screenHandleTouch(QTouchEvent* event)
|
||||||
if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TouchUpdate))
|
if (Frontend::GetTouchCoords(x, y, event->type()==QEvent::TouchUpdate))
|
||||||
{
|
{
|
||||||
touching = true;
|
touching = true;
|
||||||
NDS::TouchScreen(x, y);
|
Input::TouchScreen(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEvent::TouchEnd:
|
case QEvent::TouchEnd:
|
||||||
if (touching)
|
if (touching)
|
||||||
{
|
{
|
||||||
NDS::ReleaseScreen();
|
Input::ReleaseScreen();
|
||||||
touching = false;
|
touching = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue