mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Touchscreen: Apply weihouya's fix, add a touchscreen test screen. See #12381.
This commit is contained in:
@@ -570,3 +570,88 @@ void AnalogTestScreen::CreateViews() {
|
||||
|
||||
root_->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
}
|
||||
|
||||
bool TouchTestScreen::touch(const TouchInput &touch) {
|
||||
UIDialogScreenWithBackground::touch(touch);
|
||||
if (touch.flags & TOUCH_DOWN) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id == touch.id) {
|
||||
WLOG("Double touch");
|
||||
touches_[i].x = touch.x;
|
||||
touches_[i].y = touch.y;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id == -1) {
|
||||
touches_[i].id = touch.id;
|
||||
touches_[i].x = touch.x;
|
||||
touches_[i].y = touch.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (touch.flags & TOUCH_MOVE) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id == touch.id) {
|
||||
touches_[i].x = touch.x;
|
||||
touches_[i].y = touch.y;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
WLOG("Move without touch down: %d", touch.id);
|
||||
}
|
||||
}
|
||||
if (touch.flags & TOUCH_UP) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id == touch.id) {
|
||||
found = true;
|
||||
touches_[i].id = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
WLOG("Touch release without touch down");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TouchTestScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
|
||||
I18NCategory *di = GetI18NCategory("Dialog");
|
||||
I18NCategory *gr = GetI18NCategory("Graphics");
|
||||
root_ = new LinearLayout(ORIENT_VERTICAL);
|
||||
LinearLayout *theTwo = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0f));
|
||||
root_->Add(theTwo);
|
||||
root_->Add(new CheckBox(&g_Config.bImmersiveMode, gr->T("FullScreen", "Full Screen")))->OnClick.Handle(this, &TouchTestScreen::OnImmersiveModeChange);
|
||||
root_->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
}
|
||||
|
||||
void TouchTestScreen::render() {
|
||||
UIDialogScreenWithBackground::render();
|
||||
screenManager()->getUIContext()->BeginNoTex();
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
||||
if (touches_[i].id != -1) {
|
||||
screenManager()->getUIContext()->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0);
|
||||
}
|
||||
}
|
||||
screenManager()->getUIContext()->Flush();
|
||||
}
|
||||
|
||||
void RecreateActivity();
|
||||
|
||||
UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) {
|
||||
System_SendMessage("immersive", "");
|
||||
if (g_Config.iAndroidHwScale != 0) {
|
||||
RecreateActivity();
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user