diff options
| -rw-r--r-- | backends/dc/dc.h | 5 | ||||
| -rw-r--r-- | backends/dc/dcmain.cpp | 2 | ||||
| -rw-r--r-- | backends/dc/display.cpp | 11 | ||||
| -rw-r--r-- | backends/dc/input.cpp | 4 | ||||
| -rw-r--r-- | backends/dc/softkbd.cpp | 13 | ||||
| -rw-r--r-- | backends/dc/softkbd.h | 8 | 
6 files changed, 39 insertions, 4 deletions
| diff --git a/backends/dc/dc.h b/backends/dc/dc.h index 5d580d4318..76d4f612af 100644 --- a/backends/dc/dc.h +++ b/backends/dc/dc.h @@ -30,6 +30,7 @@ class Interactive  {   public:    virtual int key(int k, byte &shiftFlags) = 0; +  virtual void mouse(int x, int y) = 0;  };  #include "softkbd.h" @@ -150,6 +151,10 @@ class OSystem_Dreamcast : public OSystem {    SaveFileManager *getSavefileManager(); +  // Extra SoftKbd support +  void mouseToSoftKbd(int x, int y, int &rx, int &ry) const; + +    static OSystem *create(); diff --git a/backends/dc/dcmain.cpp b/backends/dc/dcmain.cpp index 6700bdeb68..69a00a19b3 100644 --- a/backends/dc/dcmain.cpp +++ b/backends/dc/dcmain.cpp @@ -46,7 +46,7 @@ OSystem *OSystem_Dreamcast::create() {  }  OSystem_Dreamcast::OSystem_Dreamcast() -  : screen(NULL), mouse(NULL), overlay(NULL), _ms_buf(NULL), +  : screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this), _ms_buf(NULL),      _sound_proc(NULL), _timer_active(false), _current_shake_pos(0),      _aspect_stretch(false), _softkbd_on(false), _softkbd_motion(0)  { diff --git a/backends/dc/display.cpp b/backends/dc/display.cpp index 6e221941dc..66ac55f9db 100644 --- a/backends/dc/display.cpp +++ b/backends/dc/display.cpp @@ -478,6 +478,17 @@ void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,    ta_commit_list(&myvertex);  } +void OSystem_Dreamcast::mouseToSoftKbd(int x, int y, int &rx, int &ry) const +{ +  if(_softkbd_motion) { +    rx = (int)(x*_xscale - (330.0*sin(0.013*_softkbd_motion) - 320.0)); +    ry = (int)(y*_yscale + TOP_OFFSET - 200.0); +  } else { +    rx = -1; +    ry = -1; +  } +} +  void OSystem_Dreamcast::showOverlay()  { diff --git a/backends/dc/input.cpp b/backends/dc/input.cpp index 5de5115b1f..bc2b289b52 100644 --- a/backends/dc/input.cpp +++ b/backends/dc/input.cpp @@ -68,6 +68,10 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y,        mouse_x += pad->cond.mouse.axis1;        mouse_y += pad->cond.mouse.axis2; + +      if(inter) +	inter->mouse(mouse_x, mouse_y); +        pad->cond.mouse.axis1 = 0;        pad->cond.mouse.axis2 = 0;      } else if(pad->func & MAPLE_FUNC_KEYBOARD) { diff --git a/backends/dc/softkbd.cpp b/backends/dc/softkbd.cpp index d601d2ba54..7bf12d0632 100644 --- a/backends/dc/softkbd.cpp +++ b/backends/dc/softkbd.cpp @@ -60,7 +60,8 @@ static const short key_codes[] =      ~OSystem::KBD_SHIFT, ~OSystem::KBD_CTRL, ~OSystem::KBD_ALT, ' ', 8, 13    }; -SoftKeyboard::SoftKeyboard() : shiftState(0), keySel(0) +SoftKeyboard::SoftKeyboard(const OSystem_Dreamcast *_os) +  : os(_os), shiftState(0), keySel(0)  {    assert((sizeof(key_codes)/sizeof(key_codes[0])) == SK_NUM_KEYS); @@ -155,3 +156,13 @@ int SoftKeyboard::key(int k, byte &shiftFlags)    }    return 0;  } + +void SoftKeyboard::mouse(int x, int y) +{ +  os->mouseToSoftKbd(x, y, x, y); +  if(x >= 0 && x < 11*28 && y >= 0 && y < 6*28 && +     x%28 >= 4 && y%28 >= 4) +    if((keySel = 11*(y/28)+(x/28)) > 58) +      if((keySel -= 5) < 59) +	keySel = 58; +} diff --git a/backends/dc/softkbd.h b/backends/dc/softkbd.h index 33b481683d..3d0d3b0aa5 100644 --- a/backends/dc/softkbd.h +++ b/backends/dc/softkbd.h @@ -27,19 +27,23 @@  #define SK_NUM_KEYS 61 +class OSystem_Dreamcast; +  class SoftKeyboard : public Interactive  {   private: -   +  +  const OSystem_Dreamcast *os;    Label labels[2][SK_NUM_KEYS];    byte shiftState;    int8 keySel;   public: -  SoftKeyboard(); +  SoftKeyboard(const OSystem_Dreamcast *os);    void draw(float x, float y, int transp = 0);    int key(int k, byte &shiftFlags); +  void mouse(int x, int y);  };  #endif /* DC_SOFTKBD_H */ | 
