Ignore:
Timestamp:
Nov 25, 2011, 12:30:26 AM (11 years ago)
Author:
sam
Message:

nacl: quick and dirty mouse support.

Location:
trunk/src/platform/nacl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/nacl/nacl_instance.cpp

    r1084 r1087  
    1818#include <ppapi/cpp/module.h>
    1919#include <ppapi/cpp/completion_callback.h>
     20#include <ppapi/cpp/input_event.h>
    2021
    2122#include "core.h"
     
    3233      m_size(0, 0)
    3334{
    34     ;
     35    RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
    3536}
    3637
     
    102103}
    103104
     105bool NaClInstance::HandleInputEvent(const pp::InputEvent& event)
     106{
     107    switch (event.GetType())
     108    {
     109    case PP_INPUTEVENT_TYPE_MOUSEDOWN:
     110        Input::SetMouseButton(pp::MouseInputEvent(event).GetButton());
     111        break;
     112    case PP_INPUTEVENT_TYPE_MOUSEUP:
     113        Input::UnsetMouseButton(pp::MouseInputEvent(event).GetButton());
     114        break;
     115    case PP_INPUTEVENT_TYPE_MOUSEMOVE:
     116        Input::SetMousePos(ivec2(pp::MouseInputEvent(event).GetPosition().x(), opengl_context_->GetSize().height() - 1 - pp::MouseInputEvent(event).GetPosition().y()));
     117        break;
     118    default:
     119        break;
     120    }
     121    return true;
     122}
     123
    104124void NaClInstance::DrawSelf()
    105125{
  • trunk/src/platform/nacl/nacl_instance.h

    r1084 r1087  
    3737  //void InitializeMethods(ScriptingBridge* bridge);
    3838
     39
    3940  // Called to draw the contents of the module's browser area.
    40   void DrawSelf();
     41    virtual bool HandleInputEvent(const pp::InputEvent& event);
    4142
    42 // private:
    43   // Browser connectivity and scripting support.
    44 //  ScriptingBridge scripting_bridge_;
     43    void DrawSelf();
    4544
    46   SharedOpenGLContext opengl_context_;
     45    SharedOpenGLContext opengl_context_;
    4746
    4847    ivec2 m_size;
  • trunk/src/platform/nacl/opengl_context.h

    r1084 r1087  
    6262  void ResizeContext(const pp::Size& size);
    6363
     64  pp::Size const& GetSize() { return size_; }
     65
    6466  /// The OpenGL ES 2.0 interface.
    6567  const struct PPB_OpenGLES2* gles2() const {
Note: See TracChangeset for help on using the changeset viewer.